LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 11-16-2007, 12:46 PM   #1
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 564

Rep: Reputation: Disabled
How to get kernel to recognize "root=LABEL=foo" parameter?


I have several partitions on my HD, including -12.0, -current & a boot partition. I have used the grub package from 'extra' to install grub on my MBR. I want to use the "root=LABEL=..." instead of "root=/dev/hdx" parameter in my menu.lst file, so that moving partitions will be less of a hassle. Turns out my kernel will not accept this parameter (or the "root=UUID=..." parameter). My boot stanza in grub is:
Code:
kernel (hd0,0)/slack/vmlinuz-2.6.23.1-t2f root=/dev/hdb5 ro
If I replace "root=/dev/hdb5" with "root=LABEL=current", the kernel goes through the beginning of it's normal boot process. When it tries to mount the root fs, it displays several screenfuls of information about my drives, then panics, with the error:
Quote:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
At this point, of course, it takes a hard reset or power off/on to get the machine back.
I should mention that using "LABEL=current" instead of "/dev/hdb5" in /etc/fstab works fine, as does the command "mount -L slack /mnt/slack -t ext3", so it appears to fail only at boot time.
Anybody got a clue?
Regards,
Bill
 
Old 11-16-2007, 02:41 PM   #2
rworkman
Slackware Contributor
 
Registered: Oct 2004
Location: Tuscaloosa, Alabama (USA)
Distribution: Slackware
Posts: 2,559

Rep: Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351Reputation: 1351
Code:
root="LABEL=current"
 
Old 11-16-2007, 05:33 PM   #3
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 564

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rworkman View Post
Code:
root="LABEL=current"
I wish it were that easy. But, it didn't work. I also tried:
Code:
root=LABEL="current"
root='LABEL=current'
root=LABEL='current'
They didn't work, too.
Thanks for the try, Robby.
Regards,
Bill
 
Old 11-16-2007, 06:58 PM   #4
regis_n_bits
Member
 
Registered: Mar 2006
Distribution: Slackware64-15.0
Posts: 103

Rep: Reputation: Disabled
I think you need to create an initrd. Your / partition is on /dev/hdb5, but the error message indicates that it tried to find the / partition on (0,0) which corresponds to /dev/hda I believe.

Here is a link that gives an explanation:
http:////mulix.livejournal.com/84768.html

And I think the parameter string you want to pass to the kernel is:
root=LABEL=current
 
Old 11-16-2007, 07:09 PM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
You can't - without putting some code into an initrd to handle it.
Neither grub nor the kernel handle this as part of "early code" (that I'm aware of).

Distros that support this (Fedora for LABEL, Ubuntu for UUID e.g.) must have code in the initrd to determine which is the (real) root by label/UUID/whatever, then pivot_root to that real root for you.
 
Old 11-17-2007, 10:14 AM   #6
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 564

Original Poster
Rep: Reputation: Disabled
Thanks, folks. I use slightly modified generic kernels in both -12.0 & -current, with ext[23] fs support build in, so that I _don't_ have to use an initrd. I will continue using "/dev/hdX" in grub, so that I _don't_ have to use an initrd!
Regards,
Bill
 
Old 11-17-2007, 10:26 AM   #7
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
syg00 has hit the nail on the head.
I was recently having a look at the OLPC distro which is based on fedora. The initrd contained a pretty complete minisystem including devmapper and other progs associated with it.
 
Old 11-20-2008, 02:58 PM   #8
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 564

Original Poster
Rep: Reputation: Disabled
It's been a year now, & I finally got it to work...

Recently I found this thread, which led me to uppman's wiki.
His method allows booting from a USB device to a file system on the same USB
device. However, the "root=LABEL=*" is hard coded into the initrd, which may
make sense for booting from a USB device, but I wanted to boot from either an
IDE or SATA HD, without having to modify /etc/fstab, so I modified uppman's init
script.
Now, I use the following to modify my basic initrd (all of this based
on uppman's wiki):
1) Start by making a clean initrd. I use:
Code:
mkinitrd -c -k 2.6.24.5-smp -m ext3:reiserfs -f ext3 -r /dev/hda3
The options are:
-c - Clear the /boot/initrd-tree subdirectory & create a new one
-k - The default kernel to be used if no kernel is specified in menu.lst/lilo.conf
-m - Colon delimited list of modules to be loaded
-f - File system used in root file system (the -r option must be used also)
-r - Device for root file system (must be used with -r)
Note: The script dynamically determines root filesystem type when "root=/dev/*", "root/LABEL/*" or "root/UUID/*" is used in the menu.lst/lilo.conf. Be sure that you add the modules for the required filesyetems, either here or in Step 5. (It's easier here.)
2) Patch the original "/boot/initrd-tree/init" file:
Copy this code to a file named "init.patch".
Code:
74a75,82
> # Added, 20081119, by Bill Kirkpatrick <bkirkp@gmail.com>, to allow dynamic
> #	determination of root filesystem type.
> 	  ROOTFS=""
> 	  BLKID=`blkid $ROOTDEV`
> 	  ROOTFS=`echo $BLKID_ROOT | awk 'BEGIN{FS="="}{l=length($5);print substr($5, 2, l-2)}'`
> 	  if [ "$ROOTFS" = "" ]; then ROOTFS=`echo $BLKID_ROOT | awk 'BEGIN{FS="="}{l=length($4);print substr($4, 2, l-2)}'`; fi
> 	  echo "ROOTFS:" $ROOTFS " ROOTDEV:" $ROOTDEV
> # End dynamic determination
75a84,133
> # Added for dynamic booting when the disk LABEL is known but not the device.
> # Author: Magnus Uppman, magnus_uppman@hotmail.com
> # Modified, 20081119, by Bill Kirkpatrick <bkirkp@gmail.com>, to allow use
> #	of "root=LABEL=*" & "root=UUID=*" in menu.lst or lilo.conf & dynamic
> #	determination of root filesystem type.
> 	root=LABEL=*)
> 	  ROOTDEV=""
> 	  ROOTFS=""
> 	  ROOTLABEL=`echo $ARG | cut -f3 -d=`
> 	  while [ "$ROOTDEV" = "" ]; do
> 		echo "Trying to find:" $ROOTLABEL
> 		#Display some info
> 		PARTITIONS=`cat /proc/partitions`
> 		BLKID=`blkid -c /dev/null`
> 		echo $BLKID
> 		echo
> 		echo $PARTITIONS
> 		echo
> 		BLKID_ROOT=`blkid -t LABEL=$ROOTLABEL -c /dev/null`
> 		echo "Found:" $BLKID_ROOT
> 		ROOTDEV=`echo $BLKID_ROOT | awk 'BEGIN{FS=":"}{print $1}'`
> 		ROOTFS=`echo $BLKID_ROOT | awk 'BEGIN{FS="="}{l=length($5);print substr($5, 2, l-2)}'`
> 		if [ "$ROOTFS" = "" ]; then ROOTFS=`echo $BLKID_ROOT | awk 'BEGIN{FS="="}{l=length($4);print substr($4, 2, l-2)}'`; fi
> 		if [ "$ROOTDEV" = "" ]; then sleep 2; fi
> 	  done
> 	  echo "ROOTFS:" $ROOTFS " ROOTDEV:" $ROOTDEV
>     ;;
> 	root=UUID=*)
> 		  ROOTDEV=""
> 	  ROOTFS=""
> 	  ROOTUUID=`echo $ARG | cut -f3 -d=`
> 	  while [ "$ROOTDEV" = "" ]; do
> 		echo "Trying to find:" $ROOTUUID
> 		#Display some info
> 		PARTITIONS=`cat /proc/partitions`
> 		BLKID=`blkid -c /dev/null`
> 		echo $BLKID
> 		echo
> 		echo $PARTITIONS
> 		echo
> 		BLKID_ROOT=`blkid -t UUID=$ROOTUUID -c /dev/null`
> 		echo "Found:" $BLKID_ROOT
> 		ROOTDEV=`echo $BLKID_ROOT | awk 'BEGIN{FS=":"}{print $1}'`
> 		ROOTFS=`echo $BLKID_ROOT | awk 'BEGIN{FS="="}{l=length($5);print substr($5, 2, l-2)}'`
> 		if [ "$ROOTFS" = "" ]; then ROOTFS=`echo $BLKID_ROOT | awk 'BEGIN{FS="="}{l=length($4);print substr($4, 2, l-2)}'`; fi
> 		if [ "$ROOTDEV" = "" ]; then sleep 2; fi
> 	  done
> 	  echo "ROOTFS:" $ROOTFS " ROOTDEV:" $ROOTDEV
>     ;;
> # End dynamic booting
Issue this command:
Code:
patch /boot/initrd-tree/init "/path/to/init.patch"
There may be a better way of doing this, I know little about diff/patch.
3) Copy blkid to initrd-tree/sbin:
Code:
cp /sbin/blkid /boot/initrd-tree/sbin
Note: uppman used a separate directory & also copied in /usr/bin/awk, but the busybox implementation of awk works for me & other programs(for RAID & LVM, for example) are placed in /boot/initrd-tree/sbin by the /sbin/mkinitrd script, so I used that location instead of the separate directory.
4) Copy libraries (ld-linux.so.2 libblkid.so.1 libc.so.6 libdl.so.2 libm.so.6 libuuid.so.1) to lib:
Code:
cp /lib/{ld-linux.so.2,libblkid.so.1,libc.so.6,libdl.so.2,libm.so.6,libuuid.so.1} /boot/initrd-tree/lib
5) If you need any other modules in the initrd, copy them into '/boot/initrd-tree/lib/modules/'uname -r/'.
This step is optional. I do not perform it. If you do, you should also delete (or remove the executable bit from) the file /boot/initrd-tree/load_kernel_modules, so that all modules will be loaded, instead of just the ones that were loaded when the initrd was created.
6) Create a new initrd which contains the modifications:
Code:
cd /boot
mkinitrd [ -o initrd-mod.gz ]
The -o option may be used to rename the output initrd, so as to not clobber the original default "initrd.gz". I used this until it worked, now I don't.
7) Label the partitions. You may have to unmount some filesystems to label them. e2label works on a mounted ext3 fs, however.
8) Modify lilo.conf or menu.lst to use the correct "/dev/*", "root=LABEL=*" or "root=UUID=*" & new initrd name. Note that if you use a "/dev/*", "root=LABEL=*" or "root=UUID=*" that does not exist, you will get an error & have to reboot. With "root=LABEL=*" & "root=UUID=*", the process will sleep 2 seconds between each of five retries. If the label/uuid existed, my system has never needed but one attempt at finding it.
9) You're done. Test it out.

Last edited by TSquaredF; 11-27-2008 at 09:32 AM. Reason: update patch, add additional instructions
 
Old 11-06-2009, 11:26 AM   #9
hiptobecubic
LQ Newbie
 
Registered: Oct 2009
Distribution: Slackware
Posts: 23

Rep: Reputation: 2
Lightbulb Patch not needed.

I spent a LONG time trying to get this work and discovered that the that I wasn't waiting long enough for the usb to initialize. You can get around this by specifying some extra goodies when you make your initrd :-)


Code:
mkinitrd -c -k <KERNELVERSION> -w <WAIT_TIME> -r <ROOT_DEV> -f <ROOT_FS>
My finished initrd was made using:

Code:
mkinitrd -c -k 2.6.29.6-smp -w 8 -r LABEL=usbslack -f ext2
The init script is ALREADY cleverly written to translate LABEL=* and UUID=*. In other words, the (very nice) patch is redundant.

I didn't have to add anything, no libs, no modules etc. Just make sure that your new initrd.gz is in your lilo.conf or whatever bootloader you are using and go.
 
Old 11-06-2009, 12:16 PM   #10
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
Quote:
Originally Posted by hiptobecubic View Post
The init script is ALREADY cleverly written to translate LABEL=* and UUID=*. In other words, the (very nice) patch is redundant.
I think I added that LABEL/UUID support to "init" somewhere early in slackware64 development, at least more than a year ago.

I never tried using "root=LABEL=" or "root=UUID" directly on the commandline - to get this functionality in Slackware, it needs an initrd.

Eric
 
Old 11-06-2009, 01:17 PM   #11
uppman
Member
 
Registered: Jul 2008
Location: Stockholm, Sweden
Distribution: Slackware 13.1 32-bit
Posts: 145

Rep: Reputation: 24
I have made a new version for 13.0.

This one also supports UUID.

http://linuxconfig.dyndns.org/lazy/L...L/UUID_support

/Magnus
 
Old 11-06-2009, 03:49 PM   #12
TSquaredF
Member
 
Registered: Dec 2005
Location: "The South Coast of Texas"
Distribution: Slackware64-current
Posts: 564

Original Poster
Rep: Reputation: Disabled
hiptobecubic wrote:
Quote:
The init script is ALREADY cleverly written to translate LABEL=* and UUID=*. In other words, the (very nice) patch is redundant.
Indeed. I found this change quite a while ago (Thanks, Eric). I also found it easier to use an initrd than to be updating kernels at every revision. So I have been very happily using the stock initrd for my installations (I have bought a new laptop & desktop in the past year or so, but neither of them will boot from USB, so I don't use uppmans modifications).
Regards,
Bill
 
Old 11-07-2009, 06:54 AM   #13
uppman
Member
 
Registered: Jul 2008
Location: Stockholm, Sweden
Distribution: Slackware 13.1 32-bit
Posts: 145

Rep: Reputation: 24
Quote:
Originally Posted by TSquaredF View Post
hiptobecubic wrote:

Indeed. I found this change quite a while ago (Thanks, Eric). I also found it easier to use an initrd than to be updating kernels at every revision. So I have been very happily using the stock initrd for my installations (I have bought a new laptop & desktop in the past year or so, but neither of them will boot from USB, so I don't use uppmans modifications).
Regards,
Bill
The stock (32-bit) initrd doesn't support UUIDs to my knowledge.. Does it in 64-bit?

My patch is also (IMHO) more foolproof and allows plugging/unplugging any hot-swapable disks until the root partition is found.

By the way (since some prominent Slackware contributors seem to read this thread ) the file /etc/keymaps.tar.gz is missing in the stock initrd.

/Magnus
 
Old 11-07-2009, 08:33 AM   #14
hiptobecubic
LQ Newbie
 
Registered: Oct 2009
Distribution: Slackware
Posts: 23

Rep: Reputation: 2
Quote:
Originally Posted by uppman View Post
The stock (32-bit) initrd doesn't support UUIDs to my knowledge.. Does it in 64-bit?
No you're right, I was only using the LABEL functionality so I didn't notice that UUID wasn't there. It's pretty trivial to change it though, as `findfs` can use UUID= or LABEL= transparently.

Quote:
My patch is also (IMHO) more foolproof and allows plugging/unplugging any hot-swapable disks until the root partition is found.
Yeah I see that you wrapped it in a loop, not a bad idea. I think the call to /bin/sh is unnecessary though, since the boot process already drops to shell if a suitable root hasn't been mounted.

Also.. and this is probably just personal preference, but it seems like it would be better served to make 'yes' the default and force typing 'no' to continue. How often do you want to continue booting after you've failed to find your rootfs?
 
Old 11-07-2009, 08:47 AM   #15
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 8,559

Rep: Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106Reputation: 8106
Quote:
Originally Posted by uppman View Post
... the file /etc/keymaps.tar.gz is missing in the stock initrd.
Th keymaps.tar.gz file will be copied to the initrd.gz if you explicitly specify a non-US keyboard using the "-l" parameter to mkinitrd.

Eric
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH get marked RegEx result: "foo s bar" | /foo(.*)bar/ 1 -> " s " hansschmucker Programming 6 10-23-2007 10:34 PM
VFS: cannot open root device "LABEL=\" or 00:00 venkatesh111 Linux - Kernel 3 05-04-2006 09:47 AM
FC2; VFS: Cannot open root device "LABEL=/" or unknown-block(0,0) Starchild Fedora 11 01-18-2006 03:39 AM
VFS: Cannot Open Root Device "Label=/" abefroman Red Hat 4 05-03-2005 09:03 AM
"make-kpkg --revision=foo.1.0 kernel_image" gives some errors (kernel 2.6.3) Duukkis Debian 14 05-23-2004 03:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:22 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration