linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* how to create /dev/root
@ 2008-07-12  2:52 Marco d'Itri
  2008-07-15 13:50 ` Kay Sievers
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Marco d'Itri @ 2008-07-12  2:52 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 667 bytes --]

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
}

-- 
ciao,
Marco

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: how to create /dev/root
  2008-07-12  2:52 how to create /dev/root Marco d'Itri
@ 2008-07-15 13:50 ` Kay Sievers
  2008-07-16 14:51 ` piterpk
  2008-07-16 15:37 ` Harald Hoyer
  2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2008-07-15 13:50 UTC (permalink / raw)
  To: linux-hotplug

On Sat, Jul 12, 2008 at 04:52, Marco d'Itri <md@linux.it> wrote:
> 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
> }

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: how to create /dev/root
  2008-07-12  2:52 how to create /dev/root Marco d'Itri
  2008-07-15 13:50 ` Kay Sievers
@ 2008-07-16 14:51 ` piterpk
  2008-07-16 15:37 ` Harald Hoyer
  2 siblings, 0 replies; 4+ messages in thread
From: piterpk @ 2008-07-16 14:51 UTC (permalink / raw)
  To: linux-hotplug

> On Sat, Jul 12, 2008 at 04:52, Marco d'Itri <md@linux.it> wrote:
> > 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
> > }

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)

 > 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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: how to create /dev/root
  2008-07-12  2:52 how to create /dev/root Marco d'Itri
  2008-07-15 13:50 ` Kay Sievers
  2008-07-16 14:51 ` piterpk
@ 2008-07-16 15:37 ` Harald Hoyer
  2 siblings, 0 replies; 4+ messages in thread
From: Harald Hoyer @ 2008-07-16 15:37 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 1354 bytes --]

piterpk wrote:
>> On Sat, Jul 12, 2008 at 04:52, Marco d'Itri <md@linux.it> wrote:
>>> 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
>>> }
> 
> 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)

Fedora:

$ which stat
/usr/bin/stat



[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/x-pkcs7-signature, Size: 3636 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-07-16 15:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-12  2:52 how to create /dev/root Marco d'Itri
2008-07-15 13:50 ` Kay Sievers
2008-07-16 14:51 ` piterpk
2008-07-16 15:37 ` Harald Hoyer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).