|
Table of Contents
|
Preparation
- Download and burn CentOS-5 DVD
- No reason to use x86_64 even if CPU supports it (Intel Atom does) without >4GB of RAM
- Reduce power draw by using only one stick of memory: dual channel performance is unnecessary and increases power draw on systems that support it
- Run at least one full cycle of memtest from the CentOS CD/DVD with no errors
- Any error at all (ever) is unacceptable
- Place kickstart script (local.audio0.ks) in root directory of a FAT formatted USB flash drive
- Example kickstart script is generic and will prompt for location to find installation media (CD/DVD, FTP, hard disk, etc.) as a normal CentOS installation would
- Modify kickstart script to meet hardware/local needs
- Cannot do as much with kickstart on MSI Wind PC as the network adapter does not have a working driver during installation
Software Installation
- System OS is CentOS 5.2 (RHEL 5 clone)
Install using minimal kickstart script
- Boot CentOS installation on target system from DVD (works fine when connected using USB)
- Also ensure the USB flash drive with the kickstart script is connected. Assume it will be detected as device sdb but this may be different depending on what other disks are connected to the system
- Enter the following when prompted by ISOLINUX boot: prompt
linux ks=hd:sdb1:/local.audio0.ks- Example local.audio0.ks
- Reboot once installation completes, if grub bootloader has issues try changing the boot device from hd1,0 to hd0,0
- For my MSI Wind PC anaconda incorrectly assumes hd0,0 is the vestigial CompactFlash card so this change is necessary. YMMV
Configure grub bootloader
- Edit /etc/grub.conf
- Change timeout to 3
- Comment out splashimage
- Comment out hiddenmenu
- Change device from hd1,0 to hd0,0 if the change was necessary during the first boot
- Consider adding nousb to kernel arguments to disable the USB subsystem and reduce boot time by nearly 10s
Install driver for RTL8111C network adapter
This will not be necessary once the CentOS installation kernel gains working support for this adapter. As of 2008-10 this is unfortunately necessary. Don't bother with this for systems that do not have an RTL8111C adapter (Intel e1000 does not need this!)
- Download dkms and dkms-r8168 RPM packages from an RPMforge mirror and place them on the USB flash drive
- Mount the USB flash disk under /mnt
mount /dev/sdb1 /mnt - Install the packages
rpm -i /mnt/dkms-*.rpm /mnt/dkms-r8168-*.rpm- Ignore the warning about DSA signature. The rpmforge signing key is not yet installed
- Edit /etc/modprobe.conf to ensure eth0 uses the correct module
- Want to have this: alias eth0 r8168 (will be configured to load r8169 before the change)
- If system is connected to a gigabit network it will not always autonegotiate properly. Can ensure that gigabit is used by adding this to /etc/sysconfig/network-scripts/ifcfg-eth0
ETHTOOL_OPTS="speed 1000 duplex full"- Also add wol g to the ETHTOOL_OPTS statement to enable Wake-On-LAN support (i.e. ETHTOOL_OPTS="wol g speed 1000 duplex full")
- Reboot, verify that the network is working
- Can verify speed, duplex, WOL status using
ethtool eth0
- Can verify speed, duplex, WOL status using
Set system clock
- Enable NTP service
chkconfig ntpd on && service ntpd start - Force update of local clock
ntpdate -u pool.ntp.org
Configure YUM package manager
- Install yum-priorities, see http://wiki.centos.org/PackageManagement/Yum/Priorities
yum install yum-priorities - Edit /etc/yum/pluginconf.d/priorities.conf
- Add check_obsoletes = 1
- Edit /etc/yum/yum.repos.d/CentOS-Base.repo by adding priority=1 to all INI sections except [centosplus] ([centosplus] is disabled by default, and there's no need to enable it)
- Install EPEL repo package
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm- Set priority=10 in /etc/yum.repos.d/epel.repo
- Add SqueezeCenter repo package
rpm -Uvh http://repos.slimdevices.com/yum/squeezecenter/squeezecenter-repo-1-4.noarch.rpm- Set priority=20 in /etc/yum.repos.d/squeezecenter.repo
- Add rpmforge repo package
rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm- Set priority=30 in /etc/yum.repos.d/rpmforge.repo
- Also add includepkgs=dkms-* lame-* to /etc/yum.repos.d/rpmforge.repo to prevent rpmforge from replacing unintended packages
- Edit /etc/yum.conf to keep only one extra kernel, uncomment and ensure installonly_limit=1
- Trust the CentOS application signing keys
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5 /etc/pki/rpm-gpg/RPM-GPG-KEY-beta - Install additional packages (would normally be installed by anaconda during kickstart process, but MSI Wind PC lacks network access during setup)
yum install hddtemp flac lame kmod-xfs xfsdump xfsprogs - Update everything to latest version
yum update
Configure hardware monitor sensors (lm_sensors)
- Page through the sensors-detect discovery process
sensors-detect - Enable and start the lm_sensors service (this inserts the configured modules into the running kernel)
chkconfig lm_sensors on && service lm_sensors start - View results by running sensors
Configure disk temperature sensors (hddtemp)
- Add the following to the end of the default /etc/sysconfig/hddtemp
HDDTEMP_OPTIONS+=" /dev/sda" - Enable and start the hddtemp service
chkconfig hddtemp on && service hddtemp start
Monitor system statistics (collectd)
- Install collectd from EPEL repository (still in testing as of 2008-09-27)
yum --enablerepo=epel-testing install collectd collectd-sensors collectd-rrdtool - Configure /etc/collectd.conf to gather the information you care about. Working example from my system
- /etc/collectd.conf
- /etc/collectd.d/sensors.conf
- Enable and start collectd service
chkconfig collectd on && service collectd start
Configure web interface for collectd
- Procure the source package for collectd. It includes a simple CGI frontend called collection.cgi that can be used to graph system data. Place it in //var/www/cgi-bin/collection.cgi
- Unfortunately the RPM packages in EPEL do not include this CGI script
- Be sure the CGI script is executable and owned by root
- Install perl modules necessary for CGI script
yum install perl-HTML-Parser perl-URI rrdtool-perl - Add configuration file for CGI script in /etc/collection.conf
datadir: "/var/lib/collectd/"
libdir: "/usr/lib/collectd/" - Edit /etc/sysconfig/httpd to uncomment HTTPD=/usr/sbin/httpd.worker (worker MPM saves memory in this case)
- Ensure httpd service is running
chkconfig httpd on && service httpd start
Create audio partition
- Create LVM logical volume for audio data
lvcreate --size 500G --name audio00 vg0 - Format newly created volume
mkfs -t xfs -L audio00 /dev/vg0/audio00 - Create mount point for volume
mkdir -p /mnt/audio/00
- Edit /etc/fstab so volume is mounted at boot, add:
LABEL=audio00 /mnt/audio/00 xfs defaults 1 2 - Mount volume
mount /mnt/audio/00
Install SqueezeCenter
- Install SqueezeCenter server software
yum install squeezecenter- Note that SqueezeCenter, unlike (nearly?) software installed from CentOS-Base, will automatically start itself as part of package installation. No need to use the service command to start it as it will be running by the time yum returns. I consider this bad package (non-standard) package design and hope things change in the future to follow standard packaging practices
- Make sure SqueezeCenter is set to run at boot
chkconfig squeezecenter on
Configure SqueezeCenter paths (audiodir, playlistdir)
- Create audiodir and playlistdir for SqueezeCenter
mkdir -p /var/lib/squeezecenter/audiodir /var/lib/squeezecenter/playlistdir- Set permissions so squeezecenter, rsyncd, and samba can write to these directories
chown audiodir:squeezecenter /var/lib/squeezecenter/audiodir /var/lib/squeezecenter/playlistdir
- Set permissions so squeezecenter, rsyncd, and samba can write to these directories
- Link audio volume to audiodir. This allows SqueezeCenter to see the audio files stored there. Execute this command from within /var/lib/squeezecenter/audiodir
ln -s /mnt/audio/00 .- Over time additional disks may be mounted using different index numbers (e.g. 02, 03, etc.)
- This is not exactly what I use as I have additional directory structure on the /mnt/audio/00 partition to accommodate
- Add audiodir user account for audio library administration
useradd -M -d /var/lib/squeezecenter/audiodir -g squeezecenter -s /sbin/nologin audiodir- This user account will be used for insecure/anonymous maintenance of the files in the audiodir
- Probably not a good idea to use this approach for environments where security/audit concerns exist, but works fine for local home use. Set up explicit user accounts and allow only secure access to the library
- Be sure the audiodir user owns the audio files
chown -R audiodir /mnt/audio/*
Configure access to audiodir to maintain library
via rsync
- Edit the /etc/rsyncd.conf file to configure rsync daemon
- An example /etc/rsyncd.conf is available
- Add rsync to services supported editing /etc/xinetd.d/rsync: change the value of disable to no
- Restart xinetd service to enable rsyncd
service xinetd restart
via CIFS/SMB
- Edit /etc/samba/smb.conf to meet your needs
- See example /etc/samba/smb.conf
- Example uses the audiodir user account as a guest to read/write the SqueezeCenter audiodir, playlistdir, and plugin directories. There is also a share to view system log files
- Restart the samba service to effect changes
chkconfig smb on && service smb start
Configure Firewall
| Port Number | Protocol | Service | Description |
|---|---|---|---|
| 22 | TCP | sshd | remote console/admin |
| 21 | TCP | ftpd | FTP access to audiodir |
| 80 | TCP | httpd | web server for system statistics |
| 873 | TCP | rsyncd | Remote access to audiodir |
| 445 | TCP | samba | CIFS/SMB access to audiodir |
| 137 | UDP | samba | CIFS/SMB access to audiodir |
| 138 | UDP | samba | CIFS/SMB access to audiodir |
| 139 | TCP | samba | CIFS/SMB access to audiodir |
| 3483 | TCP | squeezecenter | SqueezeCenter control |
| 3483 | UDP | squeezecenter | SqueezeCenter discovery |
| 9000 | TCP | squeezecenter | SqueezeCenter web interface |
| 9090 | TCP | squeezecenter | SqueezeCenter CLI interface (remote access not allowed) |
system-config-securitylevel-tui --quiet --enabled \
--port=22:tcp \
--port=21:tcp \
--port=80:tcp \
--port=873:tcp \
--port=445:tcp --port=137:udp --port=138:udp --port=139:tcp \
--port=3483:udp --port=3483:tcp --port=9000:tcp
Specify filesystem mount options
Will not need atime on a dedicated SqueezeCenter system, so add noatime,nodiratime to mount options in /etc/fstab where defaults is specified (especially for / and the SC audiodir)
Optional Features
Mount audio partition(s) readonly
As the audio partitions are probably the largest filesystems, mounting them readonly will limit the risk of power outages and unclean shutdowns. It also helps enforce discipline to keep backups in sync as console access is required to remount partitions for writing (use the same console session to sync the backup!)
- Edit /etc/fstab and change defaults to defaults,ro for each audio partition (e.g. /mnt/audio/00)
- This will cause the system to mount the partition readonly by default
- To enable writing to partition, run the following command (change /mnt/audio/00 to suit)
mount -o remount,rw /mnt/audio/00- This can be done while system is running and accessing the filesystem. No need to restart SqueezeCenter, Samba, etc.
- To return partition to original readonly state
mount -o remount,ro /mnt/audio/00- This can also be done while system is running and accessing the filesystem. No need to restart SqueezeCenter, Samba, etc.
Enable console on serial port
CentOS will automatically configure itself to use a serial console if it is installed using one. If system is installed using video console, support for a serial console can be added but will require the system to be rebooted using process below
- Initiate reboot, or power on system
- When prompted by bootloader (grub), interrupt the startup process
- Edit the kernel options (you will see the nousb option you specified earlier) to add the following
console=tty0 console=ttyS0,115200- ttyS0 means the first serial post (e.g. COM1). ttyS1 is COM2
- Example is for 115200bps, could also use 9600, 19200, etc.
- The most important thing is that the serial console is the *last* one specified. The tty0 definition ensures that the video console is also configured (as a secondary console)
- Continue booting the system, which will automatically configure the serial console. You will see the kernel messages scroll by on the serial console and be prompted to log in
- Once system is running you may reboot again and load the original (video console only) settings. The serial console will still be set up for logins (i.e. init will run an agetty on the port using the previously set speed) though it won't receive kernel messages unless it is the last console listed on the kernel command line (edit /etc/grub.conf to make the serial console the primary if you like, by adding the console= lines above)
- Can only have one "primary" console that receives kernel messages, so make the primary console the one you will use for debugging (probably determined by your platform's hardware/BIOS)
Configure suspend/hibernate and WOL
Some systems will work without any configuration. Most have special needs to accommodate their ACPI S3 and S4 and WOL support.
Must do this for each network adapter which will be able to wake system using magic packet. This is particularly useful if the system is configured to suspend/hibernate/poweroff when players are idle as SqueezeBox players will send a WOL "magic packet" to wake/power-on the SqueezeCenter server when the user powers on the player and SqueezeCenter does not respond
- SB3 will display "Waking SqueezeCenter…" when it sends the WOL packet
- After sending the WOL packet, the SB3 will display "Connecting to SqueezeCenter…" while it waits for SqueezeCenter to become available
To enable WOL in RHEL/CentOS for the first network adapter (eth0):
- Edit /etc/sysconfig/network-scripts/ifcfg-eth0 (for eth0, eth1, etc.) and ensure that wol g is included in the ETHTOOL_OPTS parameter. There may already be other ETHTOOL_OPTS settings as well (for duplex, speed, etc.), in this case just add wol g to the list. If there is not ETHTOOL_OPTS parameter then add this line:
ETHTOOL_OPTS="wol g" - Restart network service to apply the new setting
network restart - Configure pm-utils to remove specific modules before suspend/hibernate. USB keyboards seem to need this, as does the SIS900 network adapter (contrast with RTL8111C, which does not seem to need its r8168 module to be reloaded to configure WOL). Create/edit /etc/pm/config.d/modules
# Must remove USB keyboard module or it will not work after resume
#
SUSPEND_MODULES="uhci_hcd"
RESUME_MODULES="uhci_hcd"
# FOR D201GLY2
# Need to also remove network driver module sis900 or WOL setting will not be applied
#
# Have pre-pended "mii" module as it depends on "sis900" and must be unloaded before
# the latter. Can determine order of dependencies using lsmod
# SUSPEND_MODULES="uhci_hcd mii sis900"
# RESUME_MODULES="sis900 uhci_hcd"
- Do not include mii and sis900 if they are not used on the system!
- Add pm-utils hook scripts
- Good idea to re-apply network settings as part of resume process. This ensures that WOL, speed/duplex, and other configured options are in place (and doesn't hurt even if it's unnecessary). Create/tailor a /etc/pm/hooks/15network script
- Remember to chmod +x /etc/pm/hooks/15network as well
- Some systems have problems lose the ACPI RTC wake alarm setting after the hwclock is synchronized during shutdown/suspend. MSI Wind PC is not affected, but other platforms are. Simple workaround is to reapply the setting after the hwclock sync using /etc/pm/hooks/89wakealarm
- Remember to chmod +x as well, as above
- Good idea to re-apply network settings as part of resume process. This ensures that WOL, speed/duplex, and other configured options are in place (and doesn't hurt even if it's unnecessary). Create/tailor a /etc/pm/hooks/15network script
- Shutdown (or pm-suspend, pm-hibernate, etc.) the system and test whether it responds to WOL packets. There are desktop utilities that can send the necessary packet for most operating systems, and some home routers have this function as part of their web interface
- D201GLY2 works fine with no options supplied to pm-hibernate
- MSI Wind PC needs the --quirk-s3-bios --quirk-vbestate-restore options to correctly suspend/resume
- Wikipedia has a long list of tools to send WOL magic packets: http://en.wikipedia.org/wiki/Wake-on-LAN
Suspend/Hibernate when SqueezeCenter is idle
A separate script can be used to shutdown/suspend/hibernate the system. This will be a key aspect of user interaction, so it is probably worth investing some time to ensure it does not switch off the system when it should not (YMMV).
As a starting point, I use a python script called sc-idle.py (available as sc-idle.tar.gz). Be sure to install the script with /etc and /var/log mounted readwrite
- Download and untar it in /var/lib/squeezecenter, which will create a new directory called sc-idle
- Be sure to add necessary pm-suspend/pm-hibernate "quirks" options for the system to the /var/lib/squeezecenter/sc-idle/sc-idle.init script (the OPTS variable). As distributed this appears to work for MSI Wind PC (D201GLY2 does not need any "quirks" options to hibernate, and suspend is unsupported)
- Fix permissions (may not be necessary)
chown root:squeezecenter /var/lib/squeezecenter/sc-idle && chmod g+w /var/lib/squeezecenter/sc-idle && chmod +x /var/lib/squeezecenter/sc-idle/sc-idle.* - Create logging directory
mkdir /var/log/sc-idle/ - Place init script
ln -s /var/lib/squeezecenter/sc-idle/sc-idle.init sc-idle - Install service to run at startup
chkconfig --add sc-idle && service sc-idle start
- Add an [sc-idle] section to /etc/samba/smb.conf to facilitate hacking
Read-only root filesystem
Good to do this when using Suspend to RAM to limit impact of power failures. Not a lot of documentation exists to support this, but here are some links:
To make the system boot in readonly-root mode:
- Symlink /etc/mtab to /proc/mounts. This is not a best practice, but it does enable the mount command to run once system root is mounted readonly
rm /etc/mtab && ln -s /proc/mounts /etc/mtab - Add readonlyroot kernel option to /etc/grub.conf for default kernel image
- The RHEL/CentOS init scripts check for this option at boot time. It has the same effect as setting the value of READONLY to Y in /etc/sysconfig/readonly-root
- The standard RHEL/CentOS Samba package will not work with readonly-root. Need to make some security files writable (obviously changes to these files will be lost after each reboot). Create /etc/rwtab.d/samba
files /etc/samba/secrets.tdb
files /etc/samba/passdb.tdb
files /var/cache/samba
files /etc/samba/smb.conf - If your /var/lib/squeezecenter and /var/lib/collectd paths are on the root partition then they will need to be moved to another partition before you reboot (both services need to write to these paths to operate). Consider creating a new partition(s) and linking these paths to directories on it
lvcreate --size 2G --name squeezecenter vg0
lvcreate --size 1G --name collectd vg0
mkfs -t ext3 -L squeezecenter /dev/vg0/squeezecenter
mkfs -t ext3 -L collectd /dev/vg0/collectd - Remember to copy the contents of each directory to the new partition if the SqueezeCenter or collectd services have data in their respective directories
- Edit /etc/fstab, add
LABEL=squeezecenter /var/lib/squeezecenter ext3 defaults,noatime,nodirtime 1 4
LABEL=collectd /var/lib/collectd ext3 defaults,noatime,nodirtime 1 5 - Reboot
Temporarily escape readonly-root filesystem
You will need to make the root partition writable to update and maintain the OS, SqueezeCenter, etc. You can remove the readonlyroot option during an interactive boot if you have physical console access. Another option useful if you don't have/want to use the physical console is kexec, which allows you to reload the kernel using parameters specified form the shell
- Reload kernel without the readonlyroot kernel parameter
kexec --load --initrd="/boot/initrd-$(uname -r).img" --command-line="$(cat /proc/cmdline) noreadonlyroot" "/boot/vmlinuz-$(uname -r)" && reboot - Reload kernel with readonlyroot kernel parameter (to return to readonly-root mode once maintenance is complete)
reboot
Maintenance Tasks
Install OS updates & Upgrade SqueezeCenter versions
Use YUM to do this automatically
yum update
Backup/restore audio library
- Change to audio library
cd /mnt/audio - To backup to an host running rsyncd named storage0.local, change to /mnt/audio and
rsync -av --progress . rsync://storage0.local/audio- Also useful for initially populating the audiodir. Consider doing this from a screen session when a lot of data needs to be copied
- When copying data to the system, be sure to remount audio partitions readwrite (and then readonly when done), e.g.
mount -o remount,rw /mnt/audio/00





