I have just finished setting up a new XMBC HTPC for my living room; I will walk you through this step-by-step so that you can set one up for yourself. At over 1,700 words, this is a fairly lengthy tutorial; I have separated the steps into the correct order and have made them as easy to follow as possible.
- Setup BIOS
- Setup DHCP Server
- Setup FreeBSD Server
- Install XBMC-Live (Linux)
- Copy XBMC to NFS Server
- Setup XBMC
This will be broken down into a number of smaller steps. First, we will setup the BIOS of the HTPC. Next, we will want to setup your DHCP server for PXE / Network booting and then setup your FreeBSD server. Once your 'backends' are setup, it is time to configure your HTPC (frontend). This will consist of installing XBMC-Live, copying XBMC to your NFS server (FreeBSD), and then configuring a small number of XBMC options. Finally, there are a number of caveats to address.
I decided to go with XBMC instead of MythTV as I 1) do not have cable and thus have no need for live TV recording and 2) have only one frontend, so I do not need the master / slave setup that MthTV has.
After about a week of research, I decided to go with the following hardware:
- ASUS AT3IONT-I This is an amazing little board. I have always had good experiences with Asus. It should be noted that the heatskin gets very hot even when the system is idling. You may opt to place a 40mm fan on the heatsink, as I did.
- Kingston KVR1066D3N7K2/4G I have always had good experiences with Kingston RAM.
- IN WIN IW-BQ656 Black Mini-ITX If you are used to HTPCs the size of a Revo, than this box will seem huge. But for what you're packing, it is nicely sized. It should be noted that this case has an extra inch or so of height for a 2.5" HDD and slim CDROM. Since we'll be using neither, feel free to find a case that better suits your environment, if appropriate.
- Advanced -> CPU Configuration -> Hyper Threading Technology: Disabled I decided to disable Hyper Threading to further reduce the power requirements and heat generation of the box. Watching Avatar in 1080p, without Hyper Threading, my CPU load was at 0.01. You neither need nor will miss this feature.
- Advanced -> Chipset -> MCP7A Configuration -> iGPU Frame Buffer Detect: Disabled
- Advanced -> Chipset -> MCP7A Configuration -> iGPU Frame buffer Size: 512MB
- Advanced -> Onboard Devices Configration -> Front Panel Select: HD Audio While I use HDMI for both audio and video, this feature may be useful to you.
- Advanced -> Onboard Devices Configration ->LAN Option ROM: Enabled
- Advanced -> PCIPnP -> Plug And Play O/S: Yes
- Power -> ACPI 2.0 Support: Enabled
- Power -> ACPI APIC support: Enabled
- Tools -> Express Gate: Disabled
You may notice that, with the above settings and 4GB installed RAM, POST will report "RAM: 3072 OK". This is because the BIOS is allocating ~1GB RAM to the GPU. Linux will also report 3072MB of RAM. This is normal.
You will need to configure your DHCP server for PXE / Network booting. This will allow your front end to obtain an IP address and load the appropriate files to allow the system to boot the operating system over your network. While the instructions below are for PFSense, the setup should be very similar for other systems.
- Services -> DHCP Server
- Click "Advanced - Show Network Booting"
- Check "Enable Network Booting"
- Enter the IP address of your file server into the first box.
- Enter "PXEClient/pxelinux.0" into the second box.
- Click "Save"
I use FreeBSD for my home file / database / web / whatever server. FreeBSD has an amazing technology called ZFS. ZFS is a combined file system and logical volume manager which allows you to dynamically create filing systems, snapshots, rollbacks, and a whole slew of other neat things. If you're generally a GNU/Linux guy and am used to using LVM and / or MDADM, I recommend you try out FreeBSD with ZFS.
ANYWAY, Here we will setup our tftp server (tftpd) and share out some folders with NFS. While you do not need to use a FreeBSD backend, this tutorial assumes that you are, and that you have already created your filing systems.
Setup NFS shares
The home for our XBMC install will be /tank/xbmc. tftpd will serve files from /tftpboot. Our media will be stored in /tank/media.
- echo 'nfs_server_enable="YES"' >> /etc/rc.conf
- echo 'rpcbind_enable="YES"' >> /etc/rc.conf
- echo 'mountd_enable="YES"' >> /etc/rc.conf
- echo 'mountd_flags="-r"' >> /etc/rc.conf
- vi /etc/exports
- /etc/rc.d/mountd start Protip: If you are using FreeBSD 7.3 or 8.1, you may use "service" in place of "/etc/rc.d", so the above command would look like "service nfsd start"
- /etc/rc.d/rpcbind start
- /etc/rc.d/nfsd start
Executing "showmount -e" should now display your NFS-exported folders.
Setup tftp server
If you recall in the previous step of setting up the PXE server, we had to enter a path to "PXEClient/pxelinux.0". This file is served via tftp and is what instructs the PXE-booting (in this case, our HTPC) system to load the appropriate GNU/Linux files and correctly boot.
- Edit vi /etc/inetd.conf and uncomment the following line:
tftp dgram udp wait root /usr/libexec/tftpd tftpd -l -s /tftpboot
- echo 'ftpd_enable="YES"' >> /etc/rc.conf
- Start ftpd /etc/rc.d/ftpd start
You should now be able to test that your tftp server is running by executing "ftp localhost" from the command line.
Configure tftp files
When we are finished, the directory structure of our tftp server will look like this:
- mkdir -p /tftpboot/PXEClient
- cd /tftpboot/PXEClient
- fetch http://archive.ubuntu.com/ubuntu/dists/karmic/main/installer-amd64/current/images/netboot/pxelinux.0
- mkdir pxelinux.cfg
- cd pxelinux.cfg
- vi default
Be sure to replace 192.168.9.10 with the IP address of your FreeBSD Server!
A hard disk is required for this step. After the system is installed, we'll be copying the files off to our NFS server, at which point you can remove the hard disk and disable the controller. If you have ever installed Ubuntu, the XBMC-Live install will seem very familiar. If you haven't, the install will seem very easy!
- Download and burn CD. I am using the xbmc-9.11-live-repack version for this tutorial, which is linked from the "Live" link at http://xbmc.org/download/
- Boot from CD
- From CD menu, choose "Install XBMCLive to Disk" We must first install to the hard disk. Later we will move the system to a NFS share for diskless PXE booting.
- Follow the prompts to progress through setup...
- When you reach the partition disks part of the setup, choose "Guided - use entire disk" The disk layout does not matter as it is only temporary.
- Choose "Yes" to "Write the changes to disks?".
- Create your user account. You'll be using this account if / when you need to SSH into your media center for remote (read: couch) administration.
- Remove CD and reboot
At this point, XBMC should boot and you should have a fully-functional HTPC. The next step is to copy the operating system to a remote server so that we can remove the local hard drive and network boot.
This part of this how-to is based off of the guide at http://hype-o-thetic.com/2009/09/20/diskless-htpc-using-dd-wrt-pxe-xbmc-and-freenas-tftp-nfs/, with some modifications.
Copy the files to the server
Perform this step on the HTPC.
- sudo -s
- apt-get update
- apt-get install nfs-common portmap
- mkdir /mnt/tmp
- mkdir /mnt/nfs
- mount /dev/sda1 /mnt/tmp
- mount 192.168.9.10:/tank/xbmc /mnt/nfs Make sure to change the IP address!
- cp -a /mnt/tmp/* /mnt/nfs/ This will take up to 10 or so minutes, so be patient.
Change root directory
Perform this step on the HTPC.
- chroot /mnt/nfs
- mount -t proc proc proc This command may cause your SSH / terminal session to 'hang'. That is OK - just open a new SSH or terminal connection to the box and proceed.
Edit some files
Perform this step on the HTPC
- chroot /mnt/nfs
- Change BOOT=local to BOOT=nfs vi etc/initramfs-tools/initramfs.conf
- Updated initrd.img update-initramfs -u
- Edit etc/fstab to point to the new NFS root.
- vi /etc/fstab Replace the "/" line with this one:
- /dev/nfs / nfs defaults 0 0
Copy the new kernel image files to the tftp server
Perform this step on the FreeBSD server
- cp /tank/xbmc/vmlinuz /tftpboot/PXEClient/
- cp /tank/xbmc/initram.img /tftpboot/PXEClient/
Now go ahead and turn off your frontend, remove the hard disk, and set your network card to be the first boot device. With any luck, XBMC should boot right up, over the network!
The first thing that I recommend you do is to snapshot your system so that you can easily revert back in the future. I have had bad experiences in upgrading xbmc and the underlying OS and have been fortunate enough to have snapshots to roll back to.
Snapshot your OS
Perform this step on the FreeBSD server
- snapshot -r tank/xbmc@postinstall
Mount NFS Shares
We have already setup our NFS shares on the FreeBSD box - now we will mount them on our frontend so that we can access our media content. This step can be performed either by SSH to the frontend, or by opening a terminal (after XBMC boots up, press CTRL+ALT+F2).
- sudo -s
- mkdir /media/movies
- vi /etc/fstab
- mount -a
While the majority of this setup goes without issue, there are a couple things to address.
While booting, or in dmesg, you will see a message similar to "nForce2_smbus conflicts with ACPI region." The proposed fix for this is to add "acpi_enforce_resources=lax" as a kernel boot parameter. While this will change the error message, it will not fix the problem. I am working on a fix for this.
Even with Hyper Threading disabled, the passively-cooled CPU still runs very hot. You may or may not require a fan. I screwed a 40mm fan to the heat sink, which did the job.
This tutorial was written in the hope that it will help others, as the information for such a setup is spread around many places, and also requires a lot of trial-and-error. If you find that I have overlooked something, or if you have any ideas for improvement, feel free to leave some feedback!