[NewCommand] set real_root_dev

Rob Landley rob at landley.net
Thu Feb 9 05:32:47 UTC 2006


On Monday 06 February 2006 12:31, drtyc at centrum.cz wrote:
> Hello.
>
> Got idea for another busybox command that will realy be usefull in my
> scenario.
> Something like:
> busybox set_real_root_dev /dev/r5/root

ln -s r5/hda5 /dev/root

(We should document that, and mdev should set it.)

> Where r5 is lvm/device mapper's r5 volume group direcory with underneath
> "root" being block device node created by the lvm/dm but one can't trust
> in it's getting always same minor/major number.

That's what mdev is for. :)

> Now you may understand the situation. The initrd script setups everything
> correctly now but one thing. It does not touch real_root_dev in proc. The
> value has been there since the kernel compiled and there is high
> probability that it breaks when I add or remove logical volumes.

/proc/sys/kernel/real-root-dev is part of the old linuxrc support code.  Since 
linuxrc has to return to the kernel in order to mount the real root device 
and call the real init, if it wants to change the real root device (because 
it just setup a loop device, for example), it writes the dev_t to that file 
to tell the kernel code what device root lives on.  You can do this with 
echo, it's a decimal number.

When booting via initramfs, the kernel never actually reaches the code that 
would use this value.  It's legacy, and when initrd finally gets yanked it'll 
go away.  It has a number of problems, not least of which is that the normal 
non-initrd boot path never sets the value to anything, which isn't busybox's 
fault.

(Other problems include the inability to specify an nfs or samba root device 
as a dev_t.  And of course it's not a proper major:minor pair.  The format of 
dev_t changed between the 2.4 and 2.6 kernel series when major/minor grew 
beyond 8 bits each, although there there's backwards compatability code if 
you feed it a valid old value.)

If you do care about this value, you don't need a busybox command to change 
it.  "stat -t %d /dev/blah > /proc/sys/kernel/real-root-dev" should work just 
fine.  (Assuming stat works, is 11 really the correct value for /dev/hda?  %t 
and %T produce something intelligible...)

> Or is there another way to do the math from the device name grab minor +
> major device number and do the converion into octal format? All just with
> busybox?

Should be.

*blink blink*

Octal?  Really?  (Documentation/filesystems/proc.txt doesn't document this 
entry, of course...).  Grep the kernel source tree...

Anyway, converting to octal's easy enough:

./busybox printf %o 9
11

Rob
-- 
Steve Ballmer: Innovation!  Inigo Montoya: You keep using that word.
I do not think it means what you think it means.



More information about the busybox mailing list