how to create /dev/root
I added this to the Debian udev init script, run between mounting /dev and starting udevtrigger.
mountpoint at least on Debian systems is part of sysvinit and happens to be in /bin, but if /usr is available then you can as well use stat(1).
create_devroot_rule() {
local udevroot="$1"
local rootnumbers=$(mountpoint -q -d / || true)
local rootmajor=${rootnumbers%:*}
local rootminor=${rootnumbers#*:}
[ "$rootmajor" -a "$rootminor" ] || return 0
echo 'ACTION=="add", SUBSYSTEM=="block", ENV{MAJOR}=="'$rootmajor'", ENV{MINOR}=="'$rootminor'", SYMLINK+="root"' > /dev/.udev/rules.d/rules.d/61-dev-root-link.rules
}
Signature · 2 lines
ciao, Marco
Quoted 13 lines · Marco d'Itri
I added this to the Debian udev init script, run between mounting /dev and starting udevtrigger.
mountpoint at least on Debian systems is part of sysvinit and happens to be in /bin, but if /usr is available then you can as well use stat(1).
create_devroot_rule(){
local udevroot="$1"
local rootnumbers=$(mountpoint -q -d / || true)
local rootmajor=${rootnumbers%:*}
local rootminor=${rootnumbers#*:}
[ "$rootmajor" -a "$rootminor" ] || return 0
Quoted 2 lines
echo 'ACTION="add", SUBSYSTEM="block", ENV{MAJOR}="'$rootmajor'", ENV{MINOR}="'$rootminor'", SYMLINK+="root"' >
/dev/.udev/rules.d/rules.d/61-dev-root-link.rules
}
Looks fine, didn't know about "mountpoint, and not sure if all distros have it. We use:
udevadm info --device-id-of-file=/
since a while. I've added --export to it now, so:
eval $(/sbin/udevadm info --export --export-prefix=ROOT_
--device-id-of-file=/)
should make $ROOT_MAJOR, $ROOT_MINOR available without any further shell mangling.
Kay
Quoted 7 lines · Marco d'Itri
Quoted 6 lines
I added this to the Debian udev init script, run between mounting /dev and starting udevtrigger.
mountpoint at least on Debian systems is part of sysvinit and happens to be in /bin, but if /usr is available then you can as well use stat(1).
Quoted 8 lines
Quoted 8 lines
create_devroot_rule(){
local udevroot="$1"
local rootnumbers=$(mountpoint -q -d / || true)
local rootmajor=${rootnumbers%:*}
local rootminor=${rootnumbers#*:}
[ "$rootmajor" -a "$rootminor" ] || return 0echo 'ACTION="add", SUBSYSTEM="block", ENV{MAJOR}="'$rootmajor'", ENV{MINOR}="'$rootminor'",
SYMLINK+="root"' > /dev/.udev/rules.d/rules.d/61-dev-root-link.rules
Quoted 1 line
Quoted 1 line
}
Based in original Marco´s code, we are using this one:
# Create rootdev rules
DEVICENUMBER=$( /bin/stat -c %d / )
MAJORNUMBER=$(($DEVICENUMBER / 256))
MINORNUMBER=$(($DEVICENUMBER % 256))
echo 'ACTION="add", SUBSYSTEM="block", ENV{MAJOR}="'$MAJORNUMBER'", ENV{MINOR}="'$MINORNUMBER'",SYMLINK+="root"' > /dev/.udev/rules.d/61-dev-root-link.rules
But our uses stat instead mountpoint (mountpoint is in /usr/bin and stat is in /bin)
Quoted 8 lines
Looks fine, didn't know about "mountpoint, and not sure if all distros have it. We use:
udevadm info --device-id-of-file=/
since a while. I've added --export to it now, so:
eval $(/sbin/udevadm info --export --export-prefix=ROOT_
--device-id-of-file=/)
should make $ROOT_MAJOR, $ROOT_MINOR available without any further shell mangling.
Hmmm... seems to be a good idea to use udev internal tools to do that.
Piter Punk
Quoted 26 lines · piterpk
Quoted 7 lines · Marco d'Itri
Quoted 6 lines
I added this to the Debian udev init script, run between mounting /dev and starting udevtrigger.
mountpoint at least on Debian systems is part of sysvinit and happens to be in /bin, but if /usr is available then you can as well use stat(1).
Quoted 8 lines
Quoted 8 lines
create_devroot_rule(){
local udevroot="$1"
local rootnumbers=$(mountpoint -q -d / || true)
local rootmajor=${rootnumbers%:*}
local rootminor=${rootnumbers#*:}
[ "$rootmajor" -a "$rootminor" ] || return 0echo 'ACTION=="add", SUBSYSTEM=="block", ENV{MAJOR}=="'$rootmajor'", ENV{MINOR}=="'$rootminor'",
SYMLINK+="root"' >
/dev/.udev/rules.d/rules.d/61-dev-root-link.rulesQuoted 1 line
Quoted 1 line
}
Based in original Marco´s code, we are using this one:
# Create rootdev rules DEVICENUMBER=$( /bin/stat -c %d / ) MAJORNUMBER=$(($DEVICENUMBER / 256)) MINORNUMBER=$(($DEVICENUMBER % 256)) echo 'ACTION=="add", SUBSYSTEM=="block", ENV{MAJOR}=="'$MAJORNUMBER'", ENV{MINOR}=="'$MINORNUMBER'",
Quoted 3 lines
SYMLINK+="root"' >
/dev/.udev/rules.d/61-dev-root-link.rulesBut our uses stat instead mountpoint (mountpoint is in
/usr/binand stat is in /bin)
Fedora:
$ which stat /usr/bin/stat