This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours
Bug 424591 - (mkinitrd) implement NBD handling
(mkinitrd) implement NBD handling
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: mkinitrd (Show other bugs)
rawhide
All Linux
high Severity low
: ---
: ---
Assigned To: Warren Togami
Fedora Extras Quality Assurance
:
Depends On:
Blocks: K12LTSP F11Target
  Show dependency treegraph
 
Reported: 2007-12-13 22:42 EST by Warren Togami
Modified: 2013-01-09 23:31 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-10-25 08:58:02 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
NBD patch from earlier (3.43 KB, patch)
2008-02-24 20:18 EST, Warren Togami
no flags Details | Diff

  None (edit)
Description Warren Togami 2007-12-13 22:42:56 EST
git clone http://fedorapeople.org/~wtogami/mkinitrd-upstream-proposed/

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

commit 6562b0fcfc16164438fadbea3263a329f8ceab40
Author: Warren Togami <wtogami@redhat.com>
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 <wtogami@redhat.com>
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 <wtogami@redhat.com>
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 <wtogami@redhat.com>
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 16:15:39 EST
NOTE:
This requires a minimum of selinux-policy-3.0.8-66.

* Thu Dec 06 2007 Dan Walsh <dwalsh@redhat.com> 3.0.8-66
- Allow depmod to read tmp files from rpm
Comment 2 Warren Togami 2008-01-13 11:27:28 EST
Jeremy said that he would review these changes.
Comment 3 Jeremy Katz 2008-01-16 10:39:49 EST
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 13:23:51 EST
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 17:33:18 EST
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-24 20:18:07 EST
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-24 23:51:31 EST
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.

dhcpd.conf:
    option root-path "IPADDR:PATH";
    option root-path "192.168.0.254:/opt/ltsp/i386";

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:192.168.0.254:2000";

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 "192.168.0.254:2000";

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-24 23:57:44 EST
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 15:26:33 EST
Kindof meh on the patch.

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

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"
 fi
 
-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
+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"
+else
+    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
+fi

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-10 21:52:56 EDT
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 192.168.0.254:2000 /path/to/mountpoint
Comment 11 Jesse Keating 2008-04-01 16:15:49 EDT
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 18:33:49 EDT
http://www.ietf.org/mail-archive/web/ips/current/msg02406.html
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 05:58:29 EDT
Changing to assigned,
Comment 14 Bug Zapper 2008-05-14 00:12:03 EDT
Changing version to '9' as part of upcoming Fedora 9 GA.
More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 15 Jesse Keating 2008-10-24 18:23:06 EDT
This obviously isn't going to be done, we're well past the feature freeze.  PUNT!
Comment 16 Warren Togami 2008-10-25 08:58:02 EDT
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.