Difference between revisions of "Diskless network boot NBD root"

From ArchWiki
Jump to: navigation, search
m (Fixed double redirect)
(34 intermediate revisions by 9 users not shown)
Line 1: Line 1:
[[Category:Boot process (English)]]
#REDIRECT [[Diskless System]]
[[Category:Networking (English)]]
{{Note|This article is not completed yet!}}
==Boot from a NBD root device==
This article will explain how to boot an ArchLinux Installation from a Network Block Device (NBD).
Much of the work to be done is based on the article [[Diskless network boot NFS root]], so this will be referenced several times within the article.
==Advantages over NFS==
The main advantages are that NBD is faster and that you can boot from an [[encrypted|LUKS]] or [[LVM]]-based NBD root device. One disadvantage is that you cannot easily update your kernel from within the running diskless client, although there are [[Diskless network boot NBD root#Updating the Kernel from the Client System|workarounds]] for this.
==Server-Side Setup==
===Create the NBD File and Boot Directory===
Create a directory that will hold the boot directory and the NBD file.
mkdir -p /nbd/boot/
Next, create the actual file that will be shared via NBD. Of course you can also use an actual block device (a hard drive) instead of creating a file on your filesystem. Just replace /nbd/root with the block device.
In this example we are going to create a file with a size of 5GB.
dd if=/dev/zero of=/nbd/root bs=1M count=5000
Now you can create a filesystem on the file.
mkfs.ext4 /nbd/root
mkfs will show you warning about the fact that the file is no actual block device. You can ignore this and simply press y to continue.
Alternatively, if you want to create an encrypted NBD device:
cryptsetup luksFormat -s 256 /nbd/root
cryptsetup luksOpen /nbd/root nbdcrypt
mkfs.ext4 /dev/mapper/nbdcrypt
{{note|Be aware that the rest of the article will use /nbd/root. If your NBD file is encrypted, replace it with /dev/mapper/nbdcrypt, if you use an actual block device, with /dev/sdX.}}
===Install ArchLinux on the NBD filesystem===
Mount the filesystem:
mount /nbd/root /mnt
Now follow the instructions [[Diskless network boot NFS root#Create Client Root Directory|here]], but be aware of three things:
# make sure you use /mnt instead of /disklessroot
# you are going to have to install the mkinitcpio-nbd package from AUR before recreating the kernel image
# the editing of /mnt/etc/mkinitcpio.conf is different for NBD
====Installing mkinitcpio-nbd====
====Editing mkinitcpio.conf====
Set the following hook list in /mnt/etc/mkinitcpio.conf:
HOOKS="base udev net nbd filesystems"
If you use an encrypted NBD device, use this:
HOOKS="base udev net nbd usbinput keymap encrypt filesystems"
Then continue with the instructions about recreating the kernel image in the NFS article.
After leaving the chroot, the kernel image will be in /mnt/boot/. We are going to need it in /nbd/boot:
cp /mnt/boot/vmlinuz26 /nbd/boot/
cp /mnt/boot/kernel26.img /nbd/boot/
====Editing rc.conf====
Make sure you set NETWORK_PERSIST="yes" and your own settings in /mnt/etc/rc.conf. Also edit /mnt/etc/locale.gen and make sure your locales are enabled.
{{note|Shutdown does currently not work, even if NETWORK_PERSIST is set to yes, see [[Diskless network boot NBD root#Known Problems|Known Problems/Shutdown Hang]]}}
===PXE/TFTP Setup===
Follow the instructions [[Diskless network boot NFS root#PXE/TFTP Setup|here]]. Just make sure you use /nbd/boot/ instead of /disklessroot/boot/ for the TFTP-Root.
==Boot configuration==
Copy the pxelinux.0 boot file from syslinux to /nbd/boot and create the pxelinux.cfg directory:
cp /usr/lib/syslinux/pxelinux.0 /nbd/boot/
mkdir /nbd/boot/pxelinux.cfg/
Now create and edit /nbd/boot/pxelinux.cfg/default, which contains the boot configuration for the client. Replace the value for nbd_server with the IP and Port your NBD server will be running on.
default linux
label linux
kernel vmlinuz26
append initrd=kernel26.img ip=::::::dhcp nbd_server= root=/dev/nbd0
See [[Mkinitcpio#Using net|here]] for details about the ip option.
If your NBD device is encrypted, use the following append line instead:
append initrd=kernel26.img ip=::::::dhcp nbd_server= cryptdevice=/dev/nbd0:nbdcrypt root=/dev/mapper/nbdcrypt
==Configuring the NBD server==
==Using a swap partition==
Although this has not been tested yet, you should be able to do this by creating a [[LVM]] volume group on /dev/nbd0 that contains the root and swap partition and adding lvm2 before the filesystems hook in /mnt/etc/mkinitcpio.conf.
==Updating the Kernel from the Client System==
==Known Problems==
===Shutdown Hang===
Shutdown will hang at "Sending SIGTERM to processes". This probably happens because this also kills the nbd-client process and the connection to the root device is therefore lost. Unfortunately, there is currently no known workaround for this.

Revision as of 02:27, 12 February 2013

Redirect to: