个人工具

UbuntuHelp:DisklessUbuntuHowto

来自Ubuntu中文

Oneleaf讨论 | 贡献2007年5月24日 (四) 09:30的版本 (新页面: {{From|https://help.ubuntu.com/community/DisklessUbuntuHowto}} {{Languages|UbuntuHelp:DisklessUbuntuHowto}} == What is diskless booting? == Diskless booting is using a remote system ...)

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航, 搜索



What is diskless booting?

Diskless booting is using a remote system or systems to store the kernel and the filesystem that will be used on other computer(s).

Why do it?

Imagine my case I admin about 25 public workstations for a local library, if they want something changed across the board I can either go sit at each PC and spend X minutes on it, adding up to who knows how many hours, or I can simply make the change at any one of the 25 systems and have it effect every system equally. The same goes for updates and many other operations. It really eases support issues.

How is this different than ThinClientHowto?

Thin clients use some of the same principals but they also connect to a remote X session, which means everything runs on the remote server, all applications will consume the servers resources, such as RAM and CPU cycles.

Diskless Booting simply uses the remote server for storage and still runs all applications on the local client station. This works better if you have full powered PC's to work with, and are working with a large number of clients that would require too much CPU and RAM to run all their applications on one server.

It is different enough to have multiple machines mounting the same / filesystem as opposed to simply being a remote monitor and keyboard to warrant a separate how-to I think.

Oliver Grawert says :- you could have achieved this easier by following the thin client howto, remove the ltsp-client package from the chroot and install ubuntu-desktop (or whatever desktop you want) there, would save you a lot of configuration work ;)

How does it work?

There are a lot of parallels to ThinClientHowto, diskless booting requires a DHCP server which a bootable PXE network card will query to get its configuration and location of the file to tftp from the server, after booting the PXE image the client will tftp and boot the kernel image(with args specified in the pxe config), those args will tell the kernel how to configure itself, and the path to mount the NFS share where it's / directory is located.

Requirements

  • An Ubuntu system with (preferably) nfs-kernel-server and tftpd server (the server)
  • At least one PXE-bootable system (the client)
  • It helps to have the client set up in its final configuration before you start
  • Enough disk space on the server to hold the client filesystem
  • A fast network connection between the client and the server
  • A DHCP server which is capable of supporting PXE clients, or a separate network segment where you can run a dedicated DHCP server
  • A good understanding of Linux

Getting Started

Set up your server

Install the following packages: dhcp3-server tftpd-hpa syslinux nfs-kernel-server initramfs-tools

sudo mkdir -p /tftpboot/pxelinux.cfg
sudo mkdir /nfsroot
sudo cp /usr/lib/syslinux/pxelinux.0 /tftpboot
  • Configure your DHCP server to offer /tftpboot/pxelinux.0 as a boot file and assign (possibly) assign a static IP to the machine you want to boot with PXE (the client). Your dhcpd.conf might look like this assuming your subnet is 192.168.2.0
allow booting;
allow bootp;

subnet 192.168.2.0 netmask 255.255.255.0 {
range 192.168.2.xxx 192.168.2.xxx;
option broadcast-address 192.168.2.255;
option routers 192.168.2.xxx;
option domain-name-servers 192.168.2.xxx;

filename "/pxelinux.0";
}

# force the client to this ip for pxe.
# This is only necessary assuming you want to send different images to different computers.
host pxe_client {
hardware ethernet xx:xx:xx:xx:xx:xx;
fixed-address 192.168.2.xxx;
}

NOTE: You will need to replace the 'xx:xx:xx:xx:xx:xx' and the '192.168.2.xxx' with your own values

  • create a new config file as /tftpboot/pxelinux.cfg/default

NOTE: There are more options available such as MAC or IP identification for multiple config files see syslinux/pxelinux documentation for help.

LABEL linux
KERNEL vmlinuz-2.6.15-23-686
APPEND root=/dev/nfs initrd=initrd.img-2.6.15-23-686 nfsroot=192.168.2.2:/nfsroot ip=dhcp rw

NOTE: your nfs server IP address, kernel name, and initrd name will likely be different. If you have a preconfigured system the names should be the names of the kernel and initrd (see below) on the client system

  • configure your /etc/exports to export your /nfsroot
/nfsroot             192.168.2.xxx(rw,no_root_squash,async)

The '192.168.2.xxx' should be replaced with either the client IP or hostname for single installations, or wildcards to match the set of servers you are using.

  • sync your exports
exportfs -rv
  • Change the BOOT flag to NFS in /etc/mkinitramfs/initramfs.conf on the client and make a net bootable initrd.img with mkinitramfs. Make sure you remember where you put this, I advise you put it in your home directory. If you do not have a client readily made, just make the ramfs on your host (this is not ideal).

Creating your NFS installation

There are a few ways you can go about this, debchroot, copying the install from your server, or the easiest is having a / fs with all the right configs, was to install [xk]ubuntu on the workstation from CD, after you've got your system installed and working on the network mount the /nfsroot and copy everything from your working system to it. Plus we get to verify the NFS is working

Here's basically how I did it:

mount -tnfs -onolock 192.168.1.2:/nfsroot /mnt
cp -ax /. /mnt/.
cp -ax /dev/. /mnt/dev/.

Note: Here is where you will need to copy your kernel and the initrd.img you made earlier to /tftpboot/ on the server

    • After you copy everything over to the nfs server open an editor on the nfs server and make sure your network settings are correct inside the config files in /nfsroot/etc/.

NOTE: You'll want to check resolv.conf and DO NOT allow the system to bring up eth0, it will already have been configured by the kernel and in use for your NFS filesystem, if you do not comment out 'auto eth0' from /etc/network/interfaces your system will try to reconfigure eth0 and sever your NFS connection and you'll lose your root FS.

    • edit /nfsroot/etc/fstab to look something like this ('note no swap')
# /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
/dev/hdc        /media/cdrom0   udf,iso9660 user,noauto 0       0

note: if you have entries for other tmpfs that's fine to leave them in there

Setup your client

    • Enter your BIOS settings and configure your system to boot from LAN

If you have options for different LAN boot methods choose PXE

Now What?

Reboot your client PC it should get it's net config from the DHCP server, download the pxelinux image, download and boot the kernel, mount your root fs and continue to boot just as if it were using its internal HD, only now you can yank that HD out and use it for something else, that machine doesn't need it any more :)

Gotchas

  • Remember to use -o nolock when first mounting your NFS or have portmapper running or you'll end up with a long (nearly 2 min) hang mounting the remote NFS.
  • If you are going to have multiple systems share this root you need to make sure some directories like /var/run, /var/lock, /tmp and some others are mounted in tmpfs so different systems won't be conflicting into each other.
      • You probably also want to mount /media in tmpfs space if you don't want every workstation having access to every other workstations storage media.
  • Think of things in cron like slocate - do you really want 25 computers trying to updatedb at 4AM all on the same HD?