22.5.12

Diskless MythTV frontend

Having a rest day from sports so did something I've wanted to do for a long time, building a diskless mythtv frontend. My hdd died yesterday so I thought it would be a good time to do it.

I had to read the usual amount of guides to do this most of my time spent on troubleshooting and debugging why it isn't working.

A good read: https://help.ubuntu.com/community/DisklessUbuntuHowto

The server

I diverted from the original guide a bit and installed xinetd and tftpd instead of what the guide suggested.
I also didn't install a dhcp server. I used my dd-wrt router for it instead.

1) install the requirements
sudo apt-get install syslinux nfs-kernel-server initramfs-tools xinetd tftpd tftp


2) Configure the dhcp server in my case the dd-wrt router
  • Goto Services 
  • Enable DNSMasq 
  • Enable local DNS 
  • Enter this in Additional DNSMasq options: 
dhcp-boot=pxelinux.0,<serverhostname>,<serverip>
3) Configure the tftp server
sudo mkdir -p /tftpboot/pxelinux.cfg
sudo cp /usr/lib/syslinux/pxelinux.0 /tftpboot
Create default configuration file /tftpboot/pxelinux.cfg/default
This I had to change significantly to get it working from the ubuntu guide and spent a ton of time figuring it out.

Replace <server ip> with your server IP address.
PROMPT 0
DEFAULT linux root=/dev/nfs nfsroot=<server ip>:/nfsroot
APPEND root=/dev/nfs nfsroot=<server ip>:/nfsroot
LABEL linux
KERNEL vmlinuz
APPEND root=/dev/nfs initrd=initrd.img nfsroot=<server ip>:/nfsroot ip=dhcp rw

Create the xinetd tftp configuration file in /etc/xinetd.d/tftp
service tftp {
protocol =udp
port =69
socket_type =dgram
wait =yes
user =nobody
server = /usr/sbin/in.tftpd
server_args =/tftpboot disable =no
}

Set permissions
sudo chmod -R 777 /tftpboot
sudo chown nobody /tftpboot -R
Configure the nfs filesystem first create the folder for the clients OS files
sudo mkdir /nfsroot

Configure your /etc/exports to export your /nfsroot
/nfsroot 10.0.0.*(rw,no_root_squash,async,insecure)


Sync your exports
sudo exportfs -rv

Client setup

I'll assume you have a working installation of which we will now make a diskless client. Connect to the client via ssh.

cp /boot/vmlinuz-`uname -r` ~
Change the BOOT flag to nfs in /etc/initramfs-tools/initramfs.conf
Find BOOT option and change from local to nfs
Find MODULES=most and change it to MODULES=netboot

mkinitramfs -o /home/<USERNAME>/initrd.img


Copy OS files to the server from the client (as root)
mount -t nfs -onolock <server ip>:/nfsroot /mnt 
cp -axvv /. /mnt/.
cp -ax /dev/. /mnt/dev/.
Now that the copying is done we can change the BOOT and MODULES options back on the client just in case you need the disk still at some point and want to upgrade the kernel.


On the server let's configure still the fstab of the client filesystem (/nfsroot/etc/fstab)

# /etc/fstab: static file system information.
# # <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0 /dev/nfs / nfs defaults 1 1
none /tmp tmpfs defaults 0 0
none /var/run tmpfs defaults 0 0
none /var/lock tmpfs defaults 0 0
none /var/tmp tmpfs defaults 0 0

That's it we should be good to go. Reboot the Server first and then the client and see what happens. Remember to set the clients boot order to netboot first in the BIOS. This setup worked for me it may work for someone else also. At the very least it's something I can use to redo this when I do it the next time.

Troubleshooting tips


If you suspect there is something wrong with your tftp try connecting to it. Create a file in your /tftpboot folder like touch /tftpboot/test.txt. Then try on an other computer connecting to it:
tftp <serverip>
get test.txt

If you receive a response like bytes sent... then everything is fine else something is wrong with your tftp configuration.

No comments:

Post a Comment