Thank you! It has been very detail.
> Date: Thu, 4 Jun 2015 17:40:21 +0200 > From: w@...112... > To: wmike@...1237... > CC: nbd-general@lists.sourceforge.net > Subject: Re: [Nbd] diskless linux: put root on NBD device > > On Thu, Jun 04, 2015 at 01:38:12AM +0000, WangMike wrote: > > Dear all, > > > > Is there any guide about how to run diskless linux machine, and put root on nbd > > device. > > There are two initramfs implementations that support root on NBD: dracut > supports it, and Debian's initramfs-utils (with the extra scripts in the > nbd-client package) supports it as well. If you want to try this, I > suggest you try one of those. > > If you can't use either of those for whatever reason, you'll have to do > it yourself. In theory, it's not too hard; you'd have to parse > /proc/cmdline and figure out where your nbd device is, configure the > network, and then call nbd-client, preferably with the -swap and (if > using systemd) -systemd-mark options. > > There's also some debian-installer support; to use that, boot > debian-installer with the extra kernel command line option > "modules=partman-nbd", and then it should work, for the most part. > > > My concern is about the process of "switch root" from initrd to normal file > > system, > > There isn't any useful distinction between pivot_root from initramfs to > hard disk or pivot_root from initramfs to nbd; they're both just > filesystems, as far as the kernel is concerned. All that's needed is > that something sets up your network and nbd device, then mounts that as > a normal > > > configure network (which will cause network broken for short time), > > If that happens, you lose your root device and you're dead. If you want > to do root-on-NBD, you *cannot* have a network configuration tool which > brings down the network as configured by the initramfs or the kernel; > you'll have to use something else. > > When I last tried this, I found that this excluded network-manager. > However, it's been a while since I did, so things might have changed > since then. > > Just using a simple shell script that calls "dhclient", or something > like Debian's ifupdown should work though. > > > and shutdown system. > > That works quite well, provided you tell your init system you don't want > it to kill nbd-client; if it does that, you lose your root device and > you're dead. > > For systemd, nbd-client >= 3.8 has a -systemd-mark option > which does what's needed for systemd to not kill nbd-client > > For SysVinit, it isn't init itself but rather the killall5 binary which > would kill nbd-client; it has a "-o" parameter with which you can tell > it to skip one or more processes. You'd have to make sure that the > shutdown procedure somehow passes on the correct PID to a -o parameter > of killall5; the details will depend on your distribution and its > shutdown procedure. > > For SysV-based Debian, the nbd-client init script takes care to write > the PID of the nbd-client process supporting the root filesystem to a > particular directory which gets read by the script that runs killall5, > so that this happens automagically. For other distributions, I suppose > you'll have to figure out the details yourself. > > If you have any more detailed questions, I'd be happy to answer them. > > -- > It is easy to love a country that is famous for chocolate and beer > > -- Barack Obama, speaking in Brussels, Belgium, 2014-03-26 |