# Questions about /dev/root and rootfs

## HotBBQ

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.

```

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)

```

```

/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.

----------

## HotBBQ

Bump.

----------

## hensan

I noticed this too. Anyone know why it looks like that?

----------

## BarryK

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

----------

## legogogo

My /etc/init.d/mtab:

```
#!/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

}
```

----------

## peppev

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:

```

#!/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

}

```

----------

## cach0rr0

from the kernel documentation:

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

```

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.

----------

## peppev

 *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>
> ...

 

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.

----------

## robb11

 *peppev wrote:*   

> 
> 
> I agree. Should be ignored. 
> 
> Then why having "/" listed twice by "mount" and "df", from a not
> ...

 

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

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

with:

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

but I consider it just a personal patch.

Cheers,

Robb.

----------

## anest

https://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?   :Shocked: 

----------

## anton_kg

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
> ...

 

----------

## wcg

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.)

----------

## anest

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!:

```

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 ~ #         
```

```
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!

```
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!   :Crying or Very sad: 

----------

## anest

sorry, i overlooked post with symlink solution  :Embarassed: 

this ln -s /dev/hda3 /dev/root resolved my problem:

```
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.

----------

## Hu

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.

----------

## anest

i was wrong - symlink just works until next reboot   :Evil or Very Mad: 

after reboot again i see this nasty /dev/root and not /dev/hda3 any more   :Evil or Very Mad:   :Evil or Very Mad:   :Evil or Very Mad: 

any solution?

----------

