Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 424591 - (mkinitrd) implement NBD handling
Summary: (mkinitrd) implement NBD handling
Alias: None
Product: Fedora
Classification: Fedora
Component: mkinitrd
Version: rawhide
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Warren Togami
QA Contact: Fedora Extras Quality Assurance
Depends On:
Blocks: K12LTSP F11Target
TreeView+ depends on / blocked
Reported: 2007-12-14 03:42 UTC by Warren Togami
Modified: 2013-01-10 04:31 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2008-10-25 12:58:02 UTC

Attachments (Terms of Use)
NBD patch from earlier (deleted)
2008-02-25 01:18 UTC, Warren Togami
no flags Details | Diff

Description Warren Togami 2007-12-14 03:42:56 UTC
git clone

Please review the changes in this git repository for upstream inclusion:

commit 6562b0fcfc16164438fadbea3263a329f8ceab40
Author: Warren Togami <>
Date:   Fri Dec 7 11:52:20 2007 -0500

    Handle NBD squashfs read-only root (faster alternative to NFS root boot)

commit 59e6c3d2461736e5ff7b2e2b4f6ff94c6ac9ccf7
Author: Warren Togami <>
Date:   Wed Dec 5 21:11:57 2007 -0500

    Enable NFS root boot on arbitrary target machines (from bash-branch)
    - mkinitrd modprobe instead of insmod
    - nash: loadDrivers loads any available driver that matches a PCI device

commit fe4fde5044ae64563c83fc9c2f336f13e6f0b588
Author: Warren Togami <>
Date:   Mon Dec 3 22:25:42 2007 -0500

    Not resuming is not an error.  Return 0 instead of 1.

commit 4b2bdba41417129ff0e80d80fff8971bc5ab4fa1
Author: Warren Togami <>
Date:   Mon Dec 3 22:24:43 2007 -0500

    Correct the replace regex when $MODULE omits the trailing .ko or .o, so
dm-zero does not become dm-ze

Comment 1 Warren Togami 2007-12-14 21:15:39 UTC
This requires a minimum of selinux-policy-3.0.8-66.

* Thu Dec 06 2007 Dan Walsh <> 3.0.8-66
- Allow depmod to read tmp files from rpm

Comment 2 Warren Togami 2008-01-13 16:27:28 UTC
Jeremy said that he would review these changes.

Comment 3 Jeremy Katz 2008-01-16 15:39:49 UTC
A number of them are merged.  The bits that aren't (the nbd stuff), I sent you
mail about trying to figure out why it was as convoluted as it is.  But, you
didn't respond to the questions and there's no way I'm going to be able to look
at anything again until the end of the month.

Comment 4 Warren Togami 2008-01-16 18:23:51 UTC
Ah, I see the point of confusion.

emit "mkrootdev -t $rootfs -o $rootopts $rootdev"

In normal cases $rootfs is the actual filesystem type name like ext3 or nfs. 
But in this case nbd itself is not a filesystem, but instead only the block
device where an any arbitrary filesystem could be accessed.

I reused the $rootfs variable to denote that it is a nbd device, and that is
where it becomes more complicated.  The intent is to be able to support *any*
filesystem mounted over that nbd device, because different types of netboot have
different needs.  For example, thin clients or diskless workstations might be
using squashfs (ro), or ext3 within squashfs with dm-snap, or a future
non-crappy unionfs implementation.

mkrootdev alone is not sufficient for this purpose.  I was very limited in the
complexity of scripting possible in the non-bash-branch of mkinitrd, thus I
initial support was only for the most basic nbdtype (squashfs).

I intended on talking to you after returning from vacation and FUDCon about how
to proceed on the other nbdtypes since this is a VERY similar problem to LiveCD
in non-bash-branch.

Do you have time to talk about how to proceed?  I'm willing to implement it in
any way you suggest.

Comment 5 Warren Togami 2008-02-18 22:33:18 UTC
Status Update
This is currently blocking on mayflower-like functionality to be implemented in
mkinitrd proper.  Full NBD support will require the same type of logic necessary
for LiveCD.

Comment 6 Warren Togami 2008-02-25 01:18:07 UTC
Created attachment 295756 [details]
NBD patch from earlier

Hi Jeremy,

The most common case that I need to support is NBD serving only a squashfs
image, with the client mounting that read-only.  It seems that the equivalent
of this functionality belongs in mkinitrd itself and not mkliveinitrd.	Any
recommendation how better to implement this mounting?

Comment 7 Warren Togami 2008-02-25 04:51:31 UTC
Another question for Jeremy or Peter... I need your opinions.

So the current code seems to handle bootproto "dhcp" where it gets the dhcp's
supplied root-path to get the NFS server's IP address and path.

    option root-path "IPADDR:PATH";
    option root-path "";

I need to extend mkinitrd to support NBD as well.  The goal is for a single
initrd file to choose NFS or NBD at boot-time depending on what the DHCP server
tells it to do.

Should we overload the root-path option or rely on a completely different custom
defined dhcpd.conf option for NBD?

Scenario 1: Overloading root-path
NBD syntax:
    option root-path "NBD:IPADDR:PORT";
    option root-path "NBD:";

Should we overload the meaning of the long established root-path option and
possibly break other software in unpredictable ways?

Scenario 2: New custom defined dhcpd.conf option
    option nbd-root-path "IPADDR:PORT";
    option nbd-root-path "";

Or should we define a custom DHCP option and just support it with our client
(mkinitrd)?  The latter might not be such a problem, as there seems to be many
arbitrary options defined in "man dhcp-options" already.

What are your opinions?  

In any case whatever we do in Fedora might be an easy sell for Debian/Ubuntu to
adopt because this is clearly better than what they rely upon currently.

Comment 8 Warren Togami 2008-02-25 04:57:44 UTC
NOTE: The previous comment assumes root of a simple filesystem like squashfs or
ext3, not more complicated scenarios like squashfs in ext3 with dm-snap.

Comment 9 Peter Jones 2008-02-25 20:26:33 UTC
Kindof meh on the patch.

This chunk:
@@ -1206,6 +1235,11 @@ if [ -n "${loopfs}" ] || [[ "$rootopts" =~ "loop" ]]; then
+if [ "$rootfs" == "nbd" ]; then
+        findmodule nbd
+        findmodule squashfs
 # If we use LVM or dm-based raid, include dm-mod
 # XXX: dm not really supported yet.

seems like it should be part of handlenbd()

And this chunk:

@@ -1654,10 +1688,17 @@ if [ -n "$loopfs" ]; then
     emit "losetup /dev/loop0 /tmpmount/$looppath"
-emit "echo Creating root device."
-# mkrootdev does "echo /dev/root /sysroot ext3 defaults,ro 0 0 >/etc/fstab"
-emit "mkrootdev -t $rootfs -o $rootopts $rootdev"
+if [ "$rootfs" == "nbd" ]; then
+    [ -z "$remoteip" ] && handlenbd $rootdev
+    emit "/sbin/nbd-client $remoteip $nbdport /dev/nbd0"
+    emit "echo Creating root device."
+    emit "echo /dev/nbd0 /sysroot squashfs ro 0 0 > /etc/fstab"
+    emit "echo Creating root device."
+    # mkrootdev does "echo /dev/root /sysroot ext3 defaults,ro 0 0 >/etc/fstab"
+    emit "mkrootdev -t $rootfs -o $rootopts $rootdev"
+    rootdev=/dev/root

Is just weird -- why duplicate the "creating root device" line at all?  Also,
the right thing here is to make mkrootdev do the right thing, not to stub it out.

Comment 10 Warren Togami 2008-03-11 01:52:56 UTC
By Jeremy's suggestion I will be implementing a new fstab syntax:
-o nbd will setup the block device in a similar fashion to loop.

mount -t squashfs -o nbd,ro /path/to/mountpoint

Comment 11 Jesse Keating 2008-04-01 20:15:49 UTC
Warren, Peter, do you guys feel that this will get done for Fedora 9, especially
now that we're past the feature freeze?  Should this move to the Fedora 10
Tracker/Blocker ?

Comment 12 Warren Togami 2008-04-09 22:33:49 UTC
Apparently iscsi already specifies using the root-path option, and other
documentation does not limit it to be NFS-only.  By pjones recommendation,
agreed upon by dcantrell and Debian, we will use root-path for NBD as well.

Comment 13 Taylor Boatright 2008-04-29 09:58:29 UTC
Changing to assigned,

Comment 14 Bug Zapper 2008-05-14 04:12:03 UTC
Changing version to '9' as part of upcoming Fedora 9 GA.
More information and reason for this action is here:

Comment 15 Jesse Keating 2008-10-24 22:23:06 UTC
This obviously isn't going to be done, we're well past the feature freeze.  PUNT!

Comment 16 Warren Togami 2008-10-25 12:58:02 UTC
Actually, it was done a while ago.  Closing now.

Note You need to log in before you can comment on or make changes to this bug.