Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Questions about /dev/root and rootfs
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
HotBBQ
Apprentice
Apprentice


Joined: 03 Mar 2004
Posts: 275
Location: West Melbourne, FL

PostPosted: Thu Mar 12, 2009 1:39 pm    Post subject: Questions about /dev/root and rootfs Reply with quote

I just did a fresh install of ~amd64 and I have some questions about rootfs and /dev/root. Here is the output of mount and my fstab.

Code:

rootfs on / type rootfs (rw)
/dev/root on / type ext4 (rw,noatime,barrier=1,data=ordered)
proc on /proc type proc (rw,nosuid,nodev,noexec)
rc-svcdir on /lib64/rc/init.d type tmpfs (rw,nosuid,nodev,noexec,size=1024k,mode=755)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec)
debugfs on /sys/kernel/debug type debugfs (rw,nosuid,nodev,noexec)
udev on /dev type tmpfs (rw,nosuid,size=10240k,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,gid=5,mode=620)
shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec)
/dev/sdb3 on /home type ext4 (rw,noatime)
/dev/sda4 on /net type ext4 (rw,noatime)
usbfs on /proc/bus/usb type usbfs (rw,noexec,nosuid,devmode=0664,devgid=85)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
gvfs-fuse-daemon on /home/bowerad1/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=bowerad1)


Code:

/dev/sdb1   /boot   ext2   noauto,noatime   1 2
/dev/sdb2   none   swap   sw               0 0
/dev/sdb3   /home   ext4   noatime         0 2
/dev/sdb5   /       ext4   noatime         0 1
/dev/sda4   /net    ext4   noatime         0 2
shm         /dev/shm   tmpfs   nodev,nosuid,noexec   0 0


I was curious as to why mount doesn't seem to think /dev/sdb5 is mounted on / and instead lists two separate entries mounted on root (rootfs and /dev/root). I suppose it's working fine as is, except I notice that gparted can't find the mount point for /dev/sdb5. I thought it might be an ext4 issue, but my other ext4 partitions can be seen just fine.
_________________
"If tyranny and oppression come to this land, it will be in the guise of fighting a foreign enemy." -- James Madison
Back to top
View user's profile Send private message
HotBBQ
Apprentice
Apprentice


Joined: 03 Mar 2004
Posts: 275
Location: West Melbourne, FL

PostPosted: Fri Mar 13, 2009 5:20 pm    Post subject: Reply with quote

Bump.
_________________
"If tyranny and oppression come to this land, it will be in the guise of fighting a foreign enemy." -- James Madison
Back to top
View user's profile Send private message
hensan
l33t
l33t


Joined: 26 Jun 2003
Posts: 868
Location: Sweden

PostPosted: Mon Mar 30, 2009 5:28 pm    Post subject: Reply with quote

I noticed this too. Anyone know why it looks like that?
Back to top
View user's profile Send private message
BarryK
n00b
n00b


Joined: 14 Jul 2009
Posts: 1

PostPosted: Tue Jul 14, 2009 2:06 am    Post subject: Reply with quote

I had a similar problem and while searching with google I came across this thread.

I'm a developer for Puppy Linux, and I have worked out a solution for our particular problem.

So, as no one else has responded to the query from you guys, here is my blog post with solution. I don't know if you will find it useful for your situation.

My blog post:

http://puppylinux.com/blog/?viewDetailed=00887

Regards,
Barry Kauler
_________________
http://puppylinux.com
Back to top
View user's profile Send private message
legogogo
n00b
n00b


Joined: 08 May 2010
Posts: 2

PostPosted: Sat May 08, 2010 6:36 pm    Post subject: Reply with quote

My /etc/init.d/mtab:

Code:
#!/sbin/runscript
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.

description="Update /etc/mtab to match what the kernel knows about"

depend()
{
   need root
   keyword -prefix
}

start()
{
   # /etc/mtab could be a symlink to /proc/mounts
   if [ ! -w /etc/mtab -a -L /etc/mtab ]; then
      eeinfo "Skipping mtab update (non writeable symlink)"
      return 0
   fi

   ebegin "Updating /etc/mtab"
   if ! echo 2>/dev/null >/etc/mtab; then
      ewend 1 "/etc/mtab is not updateable"
      return 0
   fi

   # With / as tmpfs we cannot umount -at tmpfs in localmount as that
   # makes / readonly and dismounts all tmpfs even if in use which is
   # not good. Luckily, umount uses /etc/mtab instead of /proc/mounts
   # which allows this hack to work.

RETSTUFF="`grep -v "^rootfs" /proc/mounts`"

ROOTPARTITION="`rdev | grep ' /$' | cut -f 1 -d ' ' | grep -E '/dev/sd|/dev/hd|/dev/mmc'`"
nPATTERN="s%^/dev/root %${ROOTPARTITION} %"
[ "$ROOTPARTITION" ] && RETSTUFF="`echo "$RETSTUFF" | sed -e "$nPATTERN"`"

echo "$RETSTUFF" > /etc/mtab

   # Remove stale backups
   rm -f /etc/mtab~ /etc/mtab~~
   eend 0
}
Back to top
View user's profile Send private message
peppev
n00b
n00b


Joined: 10 Aug 2009
Posts: 3
Location: Italy

PostPosted: Sat Mar 12, 2011 10:42 am    Post subject: Reply with quote

Get the same problem after updating my test gentoo box.

Another possible solution, I think, using "readlink" instead
of "rdev", not anymore available in util-linux.

My /etc/init.d/mtab:

Code:

#!/sbin/runscript
# Copyright (c) 2007-2008 Roy Marples <roy@marples.name>
# All rights reserved. Released under the 2-clause BSD license.

description="Update /etc/mtab to match what the kernel knows about"

depend()
{
        need root
        keyword -prefix
}

start()
{
        # look in an easy way to where root is mounted from
        ROOTFS=$(readlink -f /dev/root)

        # /etc/mtab could be a symlink to /proc/mounts
        if [ ! -w /etc/mtab -a -L /etc/mtab ]; then
                eeinfo "Skipping mtab update (non writeable symlink)"
                return 0
        fi

        ebegin "Updating /etc/mtab"
        if ! echo 2>/dev/null >/etc/mtab; then
                ewend 1 "/etc/mtab is not updateable"
                return 0
        fi

        # With / as tmpfs we cannot umount -at tmpfs in localmount as that
        # makes / readonly and dismounts all tmpfs even if in use which is
        # not good. Luckily, umount uses /etc/mtab instead of /proc/mounts
        # which allows this hack to work.
        grep -v "^[^ ]* / tmpfs " /proc/mounts |
          awk '$1 != "rootfs" {print}' | sed 's%/dev/root%'${ROOTFS}'%' > /etc/mtab

        # Remove stale backups
        rm -f /etc/mtab~ /etc/mtab~~
        eend 0
}
Back to top
View user's profile Send private message
cach0rr0
Moderator
Moderator


Joined: 13 Nov 2008
Posts: 4121
Location: Houston, Republic of Texas

PostPosted: Sat Mar 12, 2011 1:17 pm    Post subject: Reply with quote

from the kernel documentation:

/usr/src/linux/Documentation/filesystems/ramfs-rootfs-initramfs.txt
Code:

What is rootfs?
---------------

Rootfs is a special instance of ramfs (or tmpfs, if that's enabled), which is
always present in 2.6 systems.  You can't unmount rootfs for approximately the
same reason you can't kill the init process; rather than having special code
to check for and handle an empty list, it's smaller and simpler for the kernel
to just make sure certain lists can't become empty.

Most systems just mount another filesystem over rootfs and ignore it.  The
amount of space an empty instance of ramfs takes up is tiny.


These entries are, for all intents and purposes, vestigial, leftovers from the boot process, but they aren't going anywhere, and should be ignored.
The entry for 'rootfs on /' is explained above. The entry for /dev/root, I'd just botch the explanation. Have a quick look at 'ls -alh /dev/root' - you will note it's a symlink to /dev/sd<whatever>

Things may have one name during the initial phases of the boot process, before udev has had its time to work for example, than they do at the end. In the bootup process it is easier to just deal with /dev/root and let the symlink get created than it is trying to figure out partition names and THEN mount. If that makes sense.
_________________
Lost configuring your system?
dump lspci -n here | see Pappy's guide | Link Stash
Back to top
View user's profile Send private message
peppev
n00b
n00b


Joined: 10 Aug 2009
Posts: 3
Location: Italy

PostPosted: Sun Mar 13, 2011 10:00 am    Post subject: Reply with quote

cach0rr0 wrote:


These entries are, for all intents and purposes, vestigial, leftovers from the boot process, but they aren't going anywhere, and should be ignored.
The entry for 'rootfs on /' is explained above. The entry for /dev/root, I'd just botch the explanation. Have a quick look at 'ls -alh /dev/root' - you will note it's a symlink to /dev/sd<whatever>

Things may have one name during the initial phases of the boot process, before udev has had its time to work for example, than they do at the end. In the bootup process it is easier to just deal with /dev/root and let the symlink get created than it is trying to figure out partition names and THEN mount. If that makes sense.


I agree. Should be ignored.

Then why having "/" listed twice by "mount" and "df", from a not
filtered "/etc/mtab" is considered a good idea?

I explored a little bit and a BUG was filed and CLOSED about this topic a while ago.

But if I present to my UNIX users, skilled using shell scripts, a system where "df"
list twice "any" filesystem, they are going to kill me. We have ton of scripts using
the output of standard commands to do any sort of work. They have been working
for decades in many variant of UNIX and POSIX systems, from AIX to FreebSD, from
Solaris to Linux, from CYGWIN to Darwin and this would disrupt them.

Just my 2 cents.
Back to top
View user's profile Send private message
robb11
n00b
n00b


Joined: 20 May 2011
Posts: 17
Location: Milan, Italy

PostPosted: Wed May 25, 2011 8:46 am    Post subject: Reply with quote

peppev wrote:


I agree. Should be ignored.

Then why having "/" listed twice by "mount" and "df", from a not
filtered "/etc/mtab" is considered a good idea?

I explored a little bit and a BUG was filed and CLOSED about this topic a while ago.

But if I present to my UNIX users, skilled using shell scripts, a system where "df"
list twice "any" filesystem, they are going to kill me. We have ton of scripts using
the output of standard commands to do any sort of work. They have been working
for decades in many variant of UNIX and POSIX systems, from AIX to FreebSD, from
Solaris to Linux, from CYGWIN to Darwin and this would disrupt them.

Just my 2 cents.


Well... I have to say it, I agree with you. I have solved editing /etc/init.d/mtab, substituting

Code:
grep -v "^[^ ]* / tmpfs " /proc/mounts > /etc/mtab"


with:

Code:
grep -v "^[^ ]* / tmpfs " /proc/mounts | grep -v "rootfs" > /etc/mtab"


but I consider it just a personal patch.

Cheers,

Robb.
_________________
The Bible says: "A day Apocalypse's Knights will shout with superuser powers: <<rm>> "
Back to top
View user's profile Send private message
anest
n00b
n00b


Joined: 12 Mar 2007
Posts: 31

PostPosted: Tue Sep 20, 2011 5:55 pm    Post subject: Reply with quote

http://forums.gentoo.org/viewtopic-p-6609921.html#6609921
thanks peppev for the solution! its really works. and im wonder why this was not added to distro yet??!
this bug (yes, it is!) driving many people crazy! its MUST be added to distro as default script by replacing old one!
doing this manually every time is just a pain in butt, why no one cares? 8O
Back to top
View user's profile Send private message
anton_kg
Tux's lil' helper
Tux's lil' helper


Joined: 10 Feb 2007
Posts: 91
Location: Singapore

PostPosted: Wed Sep 21, 2011 6:51 am    Post subject: Reply with quote

I think you guys can raise your concerns in the following bugs and try to re-open if necessary (I'm no expert):
https://bugs.gentoo.org/show_bug.cgi?id=219038
https://bugs.gentoo.org/show_bug.cgi?id=367637

The current status as bellow:
Quote:
Jeremy Olexa (darkside) 2011-05-18 00:04:26 UTC
This isn't a bug. Furthermore, it is covered in the migration guide.
http://www.gentoo.org/doc/en/openrc-migration.xml

rootfs entry in /etc/mtab

Previously, the initial rootfs entry was removed from /etc/mtab, and only the
real root / entry was present. The duplicate rootfs item was actually added
back during shutdown. In OpenRC, both entries must be present for full support
of initramfs and tmpfs-on-root. This also means that less writing is required
during shutdown.
Back to top
View user's profile Send private message
wcg
Guru
Guru


Joined: 06 Jan 2009
Posts: 588

PostPosted: Wed Sep 21, 2011 4:15 pm    Post subject: Reply with quote

While I see this in the output of mount, too
(does not show the actual physical partition
mounted on root directory, only the ephemeral
rootfs and the /dev/root symbolic link), nothing has
complained, so apparently either nothing running
depends on being able to find the actual device
mounted on / or it finds it through the /dev/root
symbolic link.

The only thing I wanted to mention is that
the actual device to mount on / should be earlier
in the boot order in the OP's posted /etc/fstab.
You cannot mount /boot, /home, etc before the
root partition is mounted. Without a mounted
root partition containing those directories, those
mount points do not exist.

You can enable swap space in /etc/fstab before
the root partition, because swap space does not depend
on a filesystem mount point, but the actual device
to mount on / should be the next entry.

(My systems always mount partitions in the order that
they are specified in /etc/fstab. The mount program may
be able to rearrange things to mount the root partition
first, but why make it take that path through the code
when one can simply tell it to mount the root partition
first directly in /etc/fstab.)
_________________
TIA
Back to top
View user's profile Send private message
anest
n00b
n00b


Joined: 12 Mar 2007
Posts: 31

PostPosted: Sun Oct 30, 2011 6:27 pm    Post subject: Reply with quote

It's very weird case. On all my *old* installations (servers, routers, desktops. its all been updated to up to day offcourse) the script just simple works!:
Code:

mybeast ~ # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/md3             718965936 110868996 571575580  17% /
rc-svcdir                 1024        92       932   9% /lib64/rc/init.d
udev                     10240       184     10056   2% /dev
shm                    4094272         0   4094272   0% /dev/shm
/dev/md1                132134     14739    110573  12% /boot
mybeast ~ #         


Code:
FX6850 ~ # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/sda3            959221208 903923548   6572056 100% /
udev                   4078340         4   4078336   1% /dev
tmpfs                  1635512      1160   1634352   1% /run
none                      5120         4      5116   1% /run/lock
none                   4088776     72052   4016724   2% /run/shm
/dev/sda1               248895     57871    178174  25% /boot
FX6850 ~ #


but on all my *new* installations (even after all system updates) this script not works any more! WTF!
Code:
router ~ # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root            239073888   3030308 223899248   2% /
devtmpfs                256836        12    256824   1% /dev
rc-svcdir                 1024        68       956   7% /lib/rc/init.d
shm                     257000         0    257000   0% /dev/shm
/dev/hda1               254244      6693    234424   3% /boot
router ~ #     


anyone can help to figure out that, please??!
who wants to see this nasty "/dev/root"??? i want my normal /dev/[sh]da3 back! :cry:
Back to top
View user's profile Send private message
anest
n00b
n00b


Joined: 12 Mar 2007
Posts: 31

PostPosted: Sun Oct 30, 2011 7:02 pm    Post subject: Reply with quote

sorry, i overlooked post with symlink solution :oops:
this ln -s /dev/hda3 /dev/root resolved my problem:
Code:
router ~ # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root            239073888   3030484 223899072   2% /
devtmpfs                256836        12    256824   1% /dev
rc-svcdir                 1024        68       956   7% /lib/rc/init.d
shm                     257000         0    257000   0% /dev/shm
/dev/hda1               254244      6693    234424   3% /boot
router ~ #

router ~ # ln -s /dev/hda3 /dev/root
router ~ #


router ~ # grep -v "^rootfs" /proc/mounts
/dev/root / ext4 rw,noatime,user_xattr,acl,barrier=1,data=ordered 0 0
devtmpfs /dev devtmpfs rw,relatime,size=256836k,nr_inodes=64209,mode=755 0 0
proc /proc proc rw,relatime 0 0
rc-svcdir /lib/rc/init.d tmpfs rw,nosuid,nodev,noexec,relatime,size=1024k,mode=755 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620 0 0
shm /dev/shm tmpfs rw,nosuid,nodev,noexec,relatime 0 0
/dev/hda1 /boot ext2 rw,noatime,errors=continue 0 0
usbfs /proc/bus/usb usbfs rw,nosuid,noexec,relatime,devgid=85,devmode=664 0 0
router ~ #


router ~ # /etc/init.d/mtab restart
 * WARNING: you are stopping a boot service
 * Updating /etc/mtab ...                                                                                      [ ok ]
router ~ #


router ~ # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/hda3            239073888   3030484 223899072   2% /
devtmpfs                256836        12    256824   1% /dev
rc-svcdir                 1024        68       956   7% /lib/rc/init.d
shm                     257000         0    257000   0% /dev/shm
/dev/hda1               254244      6693    234424   3% /boot
router ~ #


but i wonder why this symlink not created just automatically by system? i still thinking its a BUG.
Back to top
View user's profile Send private message
Hu
Watchman
Watchman


Joined: 06 Mar 2007
Posts: 8833

PostPosted: Sun Oct 30, 2011 7:26 pm    Post subject: Reply with quote

If your system is fully up to date, you should not have any hdX device nodes left. Updated systems should be using the PATA/SATA layer, which does not use the hdX naming convention.
Back to top
View user's profile Send private message
anest
n00b
n00b


Joined: 12 Mar 2007
Posts: 31

PostPosted: Sun Oct 30, 2011 8:48 pm    Post subject: Reply with quote

i was wrong - symlink just works until next reboot :evil:
after reboot again i see this nasty /dev/root and not /dev/hda3 any more :evil: :evil: :evil:
any solution?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum