Bug 204768

Summary: PATCH: fix booting by LABEL from lvm or dmraid
Product: [Fedora] Fedora Reporter: Hans de Goede <hdegoede>
Component: mkinitrdAssignee: Peter Jones <pjones>
Status: CLOSED RAWHIDE QA Contact: David Lawrence <dkl>
Severity: medium Docs Contact:
Priority: medium    
Version: rawhideCC: chabotc
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2006-10-25 08:11:03 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
blkid.tab as it should be
none
blkid.tab after running nash (or /sbin/mkinitrd)
none
Patch fixing the adding of doulble entries to blkid.tab
none
Improved patch as discussed on IRC
none
Patch as applied to CVS
none
/sbin/mkinitrd patch fixing the root argument to mkrootdev in case of lvm by LABEL boot none

Description Hans de Goede 2006-08-31 14:12:43 UTC
Creating a clean /etc/blkid/blkid.tab by removing it and then running blkid as
root gives me the first attached blkid.tab (named blkid.good)

When I run "echo nash-resolveDevice "LABEL=/" | sudo /sbin/nash --forcequiet"
next I get the attached blkid.bad file, notice the last 4 lines which are
doubles of the first 4 devices (same devno, etc) using (obsolete) /dev/dm-x
device paths instead of /dev/mapper/XXXX device paths

This is caused by block_find_fs_by_keyvalue() from nash/block.c, this function
iterates over /sys/block calling
blkid_get_dev(c->cache, dev->dev_path, BLKID_DEV_NORMAL);
For each entry using /dev/dm-x as dev->dev_path for my lvm volumes as these are
called dm-x under /sys/block.

The attached patch fixes this. It fixes this by checking if dev->dev_path is
/dev/dm-# and in that case iterate over /dev/mapper/* and call blkid_get_dev()
for /dev/mapper/* instead of on /dev/dm-#. It only does the iteration if # is 0
since there is no use in doing this more then once.

Comment 1 Hans de Goede 2006-08-31 14:12:43 UTC
Created attachment 135289 [details]
blkid.tab as it should be

Comment 2 Hans de Goede 2006-08-31 14:13:30 UTC
Created attachment 135290 [details]
blkid.tab after running nash (or /sbin/mkinitrd)

Comment 3 Hans de Goede 2006-08-31 14:14:38 UTC
Created attachment 135291 [details]
Patch fixing the adding of doulble entries to blkid.tab

Comment 4 Hans de Goede 2006-08-31 20:59:07 UTC
Created attachment 135333 [details]
Improved patch as discussed on IRC

Comment 5 Hans de Goede 2006-08-31 21:02:08 UTC
Changing summary although the attached patch indeed: "fixes mkinitrd (nash)
adding double/wrong lines to /etc/blkid/blkid.tab"

It also fixes booting by LABEL from lvm or dmraid, which is a quite a bit more
important.


Comment 6 Hans de Goede 2006-08-31 21:05:13 UTC
*** Bug 203241 has been marked as a duplicate of this bug. ***

Comment 7 Peter Jones 2006-09-01 18:10:04 UTC
Created attachment 135400 [details]
Patch as applied to CVS

Patch as applied to CVS

Comment 8 Peter Jones 2006-09-02 21:02:46 UTC
This works for me in 5.1.10-1 .  Can you test and close the bug if it works for you?

Comment 9 Hans de Goede 2006-09-03 05:48:57 UTC
Created attachment 135453 [details]
/sbin/mkinitrd patch fixing the root argument to mkrootdev in case of lvm by LABEL boot

I've tested mkinitrd-5.1-10 with booting a lvm root by LABEL and it works!

However it still specifies the root argument to the mkrootdev command as
/dev/dm-x, thus if the kernel doesn't have a root= argument and mkrootdev falls
back to his own root arg things will fail. This is because for some reason
/sbin/mkinitrd takes the devno from the root device returned by nash and then
searches /sys/block (which nash also does internally, so this is kinda useless)
and then finds /dev/dm-x for a /dev/mapper/XXXX root as the code in
/sbin/mkinitrd doesn't contain an exception for /dev/dm-x as the nash code now
does.

This patch fixes this by simply taking the rootdev value returned by nash, as
that was found by scanning /sys/block already.

---

Another concern I have is that for people who have /dev/dm-x as root in their
fstab grubby will put root=/dev/dm-x as kernel argument in /etc/grub.conf,
leading to the same problem. I'm thinking about writing a patch for this which
calls nashDmGetDevName() in the mkrootdev function when root is /dev/dm-x, the
problem is that we first have to create a devno for this, I think this is best
done by getting the major from /proc/devices (code already in dm.c) and using N
in /dev/dm-N as the minor. Will you take such a patch?

Comment 10 Hans de Goede 2006-10-25 08:11:03 UTC
I finally got confirmation from a friend of mine that this patch really fixes
the mentioned problem, so this bug can be closed now.

I'm opening seperate bugs for the other potential problems which I have noticed
and described in comment #9.

The wrong arch to mkrootdev patch is bug 212124 .

I'll do some further testing to confirm that booting with root=/dev/dm-X is
currently broken and if it is I'll file a seperate bug for that too.



Comment 11 Hans de Goede 2006-10-25 08:28:19 UTC
Booting with root=/dev/dm-X is indeed currently broken, I've filed this as bug
212126