On Sun, Nov 28, 2010 at 11:02:52AM -0000, Alkis Georgopoulos wrote: > Public bug reported: > > In /etc/init.d/nbd-client, I don't see any way that would permit me to > use an nbd-mounted root filesystem and have a clean shutdown process. > With the current code, "rmmod nbd" is executed and then the client gets > a bunch of read errors instead of shutting down.
It's not the rmmod that is at fault. When the module is still in use (i.e., the device is still connected), rmmod will fail since the kernel knows that the driver is still needed. However, there is no way for nbd-client to know for sure whether a block device is still in use (as swapspace, with a filesystem, whatever), so it can't check for that very well. As such, the 'nbd-client -d' might succeed, even if the block device is still in use. The initscript has some logic to prevent an 'nbd-client -d' to occur on a device that is still in use; that's what the KILLALL and the OMITKILL variables are for. > Test case: > * In /etc/nbd-server/config on the server, I export a whole partition with > an OS in it: > [generic] > [sda2] > exportname = /dev/sda2 > port = 10809 Note that port 10809 is supposed to be for name-based exports of the NBD device, not for the oldstyle exports. What you're doing will work for now, but will start to fail when you upgrade to an NBD version of 2.9.18 or above. > * In pxelinux.cfg/default on the server, I pass these kernel parameters to > netboot a client: > APPEND ro initrd=nbdclient/initrd.img root=/dev/nbd0 > nbdroot=10.160.31.14,10809 > ip=10.160.31.101:10.160.31.1:10.160.31.1:255.255.255.0:nbd101:eth0:none > > * In the client /etc/network/interfaces (i.e. in /dev/sda2), I put a > "manual eth0" to prevent network manager to break the existing > connection. > > Then I need the following 2 workarounds so cleanly shutdown: > > 1) In the client /etc/fstab, I put the following *commented* entry, > just to prevent /etc/init.d/nbd-client from unmounting the root > filesystem on shutdown. Some documentation for a better way to do > that would be appreciated: Did you find /usr/share/doc/nbd-client/README.Debian ? > #/dev/nbd0 / ext4 _netdev,errors=remount-ro 0 1 This should not be necessary (and the grep line that checks for the device in was changed in a more recent version of the package, so this will break once you upgrade to natty or beyond) > 2) In the client /etc/init.d/nbd-client, I move the marked "if" after the > rmmod command: > if [ "$KILLALL" != "false" ] > then > if [ -d /dev/nbd ] > then > DEVICES=/dev/nbd/* > else > DEVICES=/dev/nb* > fi > - fi > echo "Invoking swapoff on NBD devices..." > swapoff $DEVICES 2>/dev/null > echo "Disconnecting $DESCes..." > for i in $DEVICES > do > $DAEMON -d $i 2>/dev/null >/dev/null > done > rmmod nbd > + fi If you have set KILLALL=false in the configuration file, then the above should not be necessary, due to the fact that nbd-client will then not yank the root device from under your nose anymore. If you have in fact done so and it still does not work, then something fishy is going on. In that case, please send your configuration file to the bugreport, too. Regards, -- The biometric identification system at the gates of the CIA headquarters works because there's a guard with a large gun making sure no one is trying to fool the system. http://www.schneier.com/blog/archives/2009/01/biometrics.html -- Unable to cleanly shutdown with an nbd root filesystem https://bugs.launchpad.net/bugs/682328 You received this bug notification because you are a member of Ubuntu Bugs, which is subscribed to Ubuntu. -- ubuntu-bugs mailing list ubuntu-bugs@lists.ubuntu.com https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs