特殊:Badtitle/NS100:DisklessSimple

来自Ubuntu中文
Wikibot留言 | 贡献2007年11月30日 (五) 16:47的版本
跳到导航跳到搜索
可打印版本不再受到支持且可能有渲染错误。请更新您的浏览器书签并改用浏览器默认打印功能。

{{#ifexist: :DisklessSimple/zh | | {{#ifexist: DisklessSimple/zh | | {{#ifeq: {{#titleparts:DisklessSimple|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:DisklessSimple|1|-1|}} | zh | | }}

responsible for -> lurer _at_ gmx.net

HOWTO TO NETBOOT UBUNTU / DEBIAN SARGE FROM A NAS BOX WITH NFS (NFSROOT)

BUT WITHOUT DHCPD AND TFTP

Intro

This howto distinguishes from others, as it needs no dhcp and no tftp. Also we are avoiding an initrd, no pivot_root for fs-switching and so on. This is the most simple way to get a small system boot of such a nas box. Need for such an howto: In the last few months dozens of little NAS Boxes appeared on the market (maxtor shared storage etc....) These are little linux boxes, with some ram, a flash, a cpu and a harddrive. When you buy them, most provide smb/cifs only. But Firmware can often be changed for this boxes, so they do export NFS too. Examples for such open firmware projects would be:

  • [1]
  • pls add more ...

This howto focuses on reducing the needed services to boot up a small linux system and on the problems which you get up to, when using a nasbox. I wanted to get rid of tftp and got rid of dhcpd with the same effort. Configuration used:

  • Fritzbox wlan sl 2030 (DSL-NatBox)
  • Maxtor shared storage drive with 200GB and openmss
  • IBM Thinkpad T21 with 512 MB ram, eepro100 NIC
  • a standard PC with dapper drake

Problem you face with this configuration (and with configurations alike):

  1. you can not debootstrap on the nas box. (32 mb ram, busybox...)
  2. you can not debootstrap to the nasbox as nfs mount (because of special files /dev/* etc...)
  3. the DHCP Server in the (small) fritzbox can not be configured to boot diskless clients (you can just turn it on/off)
  4. you may not have/want a tftp server

So we end up with no (real) dhcp, no tftp and an nfs export we can not debootstrap to. This guide should help you.. First let's talk about some scenarios i came accross : Scenarios:

  • client boots with PXE ROM / RARP / [BOOTP / DHCP] to start up and get the initial information. Then he gets his kernel over tftp and starts on the nfs root.
  • boot with floppy (etherboot) and get information over DHCP, get kernel by tftp and boot over/to nsf.
  • boot with floppy (etherboot), get information over DHCP, get kernel via nfs and boot via NFS (so no tftp)
  • (most convenient). boot with static IP Info with etherboot disk to stage 2, get kernel via nfs and boot via nfs. (no dhcp, no tftp) this is the solution we need for a simple client and a nas box.
  • (most ugly). boot with etherboot to a minimal system with a small initrd. then switch with "pivot_root" to a nfs mounted share. (it's like chroot for "/"). there are a lots of usefull scripts with the initrd-netboot package. If you like you can fiddle with them, it didn't work out for me and i won't focus on that. So pivot_root stuff is discussed elsewhere.

For this howto we assume the maxtor shared storage (mss) has the ip 192.168.178.70 and exports "/shares/mss-hdd/Public". This means we mount it on the PC as

# mount -t nfs -o user 192.168.178.70:/shares/mss-hdd/Public /media/mss

It is now mounted as /media/mss. We also assume the debian system to boot lies in:

192.168.178.70:/shares/mss-hdd/Public/sarge

on the mss and there is another folder called "boot" where we put the kernel to boot in.

# kernel here
192.168.178.70:/shares/mss-hdd/Public/boot/

But this is up to you where to put the kernel in, you just have to make it available via nfs to the lan.

The "Server" (or lack thereof later)

Install a standard linux

If you allready have linux running, use it and just install the given packages.... I use dapper drake. But it's up to you what to take.

  • enable universe and multiverse in sources.list
  • Get the following packages:
    • dhcp (just for testing purposes, not needed later on)
    • mknbi
    • debootstrap
    • bzip2
    • build-essentials
    • libncurses5-dev

Get a vanilla kernel

Go to [[2]] and get a recent kernel image. We use 2.6.15 for this howto. put it in /usr/src and unarchive it

# mv /home/user/Desktop/linux-2.6.15.tar.bz2 /usr/src
# cd /usr/src
# tar xvfj linux-2.6.15.tar.bz2
# ln -s linux-2.6.15 linux
# cd linux

now we have installed fresh kernel sources. For most convenience get your running config:

# cp /boot/.config-<running kernel> /usr/src/linux/.config
# cd /usr/src/linux
# make oldconfig
# make menuconfig

Now configure your kernel. I will just focus on some points, if you have questions regarding other topics than diskless nfs booting, pls refer to the many kernel compile howtos.

  • decide if you want apm or acpi. Completely disable the other.
  • Put all needed driver to boot into the kernel (not as module!)
    • your network card drivers
    • IP: kernel level autoconfiguration
    • IP: DHCP support
    • IP: BOOTP support
    • ROM file system support
    • Kernel automounter support
    • NFS file system support
    • Root file system on NFS
  • anything else you want, compile as module. it will be available to the kernel at runtime.

(mostly taken from [[3]]) As we will not use an initial ramdisk, everything we need to boot has to go into the kernel. build kernel and modules.

# make bzImage
# make modules
# make modules_install 

make modules_install only works as root. now the kernel is there: /usr/src/linux/arch/i386/boot/bzImage take it, and copy it somewhere on the nfs share you want to boot of later on.

# //copy to mounted mss share
# cp /usr/src/linux/arch/i386/boot/bzImage /media/mss/boot/vmlinuz-2.6.15

Remember that ../boot/... on the mss is the folder where we put the boot kernel in.

Tag Image

The kernel-image we want to boot, has to be prepared with mkelf-linux (last version of mknbi-linux). With this tool, we create packages which can be loaded from stage 2 on. This can be nbi-images, which means a kernel, or a kernel with an initial ramdisk packed together. Or just plain elf-executables (my way here), which only is a kernel without a ramdisk.

# cd /media/mss/boot
# mkelf-linux  --ip=192.168.178.30:192.168.178.70:192.168.178.1:255.255.255.0:diskless.client:eth0 
--root=/shares/mss-hdd/Public/sarge vmlinuz-2.6.15 > vmlinuz-2.6.15-20-686.nbi
  • ip corresponds to this : client:server:gateway:netmask:hostname[[UbuntuHelp:dev[|proto]]]

look here for command reference of mkelf-linux: [[4]] Now the kernel is ready to boot over network. If you run into any trouble later on, try to modify the settings on mkelf-linux. My kernel reports this after boot:

Kernel command line: rw root=/dev/nfs nfsroot=/shares/mss-hdd/Public/sarge ip=192.168.178.30:192.168.178.70:192.168.178.1:255.255.255.0:gb2:eth0
...
IP-Config: Complete:
[4294673.308000]       device=eth0, addr=192.168.178.30, mask=255.255.255.0, gw=                                                                             192.168.178.1,
[4294673.308000]      host=gb2, domain=, nis-domain=(none),
[4294673.309000]      bootserver=192.168.178.70, rootserver=192.168.178.70, root                                                                           path=
[4294673.309000] RAMDISK: Couldn't find valid RAM disk image starting at 0.
[4294673.309000] Looking up port of RPC 100003/2 on 192.168.178.70
[4294673.311000] Looking up port of RPC 100005/1 on 192.168.178.70
[4294673.363000] VFS: Mounted root (nfs filesystem).

Debootstrap the base system

As the netboot system i used Debian/Sarge, but this can be any other Distro too. I took Sarge because of its smaller base system. A debootstrapped Breezy or dapper is much larger. The system has to be on an nfs share on the nas box. But you can not install it there!! You will run into problems with special files (dev, etc...) so get debootstrap and install it localy on your linux box.

# cd /tmp
# mkdir sarge
# debootstrap  sarge sarge/ http://debian.ethz.ch/debian/

This will install a complete sarge base system into /tmp/sarge. Now copy anything to the nfs share on the mss, except for dev and sys. Copy it with --preserve=all. As said before, the sarge in my lan is in 192.168.178.70:/shares/mss-hdd/Public/sarge

The Client

Let's go to the client. It should have a floppy drive or cdrom or whatever it is capable to boot of and where you can provide etherboot images for. Now this is the interessting part, we have to make a bootdisk capable of booting, assigning IP, mounting the nfs share, get the kernel _and then_ boot that kernel up! No dhcp, no tftp. The kernel itself gets his information from the settings we gave him with mkelf-linux. So if you dont get a kernel, dont fiddle around with mkelf-linux stuff, check your settings from the bootdisk! _IF_ you get to a booting kernel and run into problems then, it's easy because you just have to make new bootable images with mkelf-linux and just change the settings.

Bootdisk

go here: http://www.rom-o-matic.net/5.4.2/

	- choose nic
	- choose floppy image bootable for floppys (zdsk)
	- in config enable/set :
- boot first : nic
- boot first nic found
- USE_STATIC_BOOT_INFO (important)
- STATIC _CLIENT_IP = 192.168.178.30
- STATIC_SUBNET_MASK = 255.255.255.0
- STATIC_SERVER_IP = 192.168.178.70
- STATIC_GATEWAY_IP = 192.168.178.1
- STATIC_BOOTFILE = /shares/mss-hdd/Public/boot/vmlinuz-2.6.15-20-686.nbi
- TAGGED_IMAGE
- ELF_IMAGE
	        - DEFAUL PROTO NFS
		- DOWNLOAD PROTO NFS
- DISABLE PXE_IMAGE!!!
- DISABLE THE TFTP STUFF!!
- DISABLE PXE_EXPORT !!

- save settings and get rom - put it on disk and boot that disk on the client to see if the nic is detected and he tries to get the kernel - if etherboot can not find your nic, continue trying different drivers.

Booting up

Now put the disc in the client and boot the client up. It should now

  • detect the nic
  • assign ip, netmask etc... to the nic device
  • mount the server share on nfs://192.168.178.70:/shares/mss-hdd/Public/boot/
  • get the kernel
  • boot the kernel up
  • the kernel recognizes its appended settings (ip & stuff)
  • mounts nfsroot

we're up!! Now you have to apt-get install udev. Restart udev so he creates all needed device nodes. Copy the modules folder from the pc to the mss share in /lib so the kernel has it's modules. do "depmod -a".

known issues

  • mkelf-linux --ip setting and the kernel append needs a gateway. If this gateway can not be reached, the system will not boot! So take care there is machine with this ip.
  • dev stuff. try to get the system up and do a /etc/init.d/udev restart. this will create all device nodes. i also had to chmod some dev files because users

got no tty's.