# /dev/root question

## Tony0945

In LTS kernels 4.4 and 4.14 root '/' is mounted on /dev/sda3 and e4defrag works.

On later kernels 4.17 and 4/18  root is mounted on /dev/root and e4dfrag just prints its version number and exit.

Also:

```
MSI tony # df -h

Filesystem      Size  Used Avail Use% Mounted on

/dev/root       228G  155G   61G  72% /

devtmpfs         10M     0   10M   0% /dev

tmpfs           1.6G  1.4M  1.6G   1% /run

cgroup_root      10M     0   10M   0% /sys/fs/cgroup

shm             7.9G     0  7.9G   0% /dev/shm

/dev/sda1      1007M   66M  890M   7% /boot

tmpfs            12G     0   12G   0% /var/tmp/portage

/dev/sdb1       1.9T  1.1T  773G  59% /video

MSI tony # ls -alh /dev/root

ls: cannot access '/dev/root': No such file or directory

```

Can anyone shed light on this and what I can do about it other than sticking to earlier kernels?

----------

## Anon-E-moose

what does "readlink /dev/root" return?

also what does "mount -v" show?

----------

## Ant P.

You probably need to change this:

```

# We can create a /dev/root symbolic link to point to the root device in

# some situations. This is on by default because some software relies on

# it,. However, this software should be fixed to not do this.

# For more information, see

# https://bugs.gentoo.org/show_bug.cgi?id=438380.

# If you are not using any affected software, you do not need this, so

# feel free to turn it off.

#rc_dev_root_symlink="YES"
```

Also, /etc/mtab should be a symlink to /proc/self/mounts if it isn't already.

----------

## Tony0945

```
MSI tony # readlink /dev/root

MSI tony # 
```

```
MSI ~ # mount -v

/dev/sda3 on / type ext4 (rw,relatime)

devtmpfs on /dev type devtmpfs (rw,nosuid,relatime,size=10240k,nr_inodes=2044379,mode=755)

proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)

tmpfs on /run type tmpfs (rw,nodev,relatime,size=1642532k,mode=755)

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)

cgroup_root on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,relatime,size=10240k,mode=755)

fusectl on /sys/fs/fuse/connections type fusectl (rw,nosuid,nodev,noexec,relatime)

mqueue on /dev/mqueue type mqueue (rw,nosuid,nodev,noexec,relatime)

openrc on /sys/fs/cgroup/openrc type cgroup (rw,nosuid,nodev,noexec,relatime,release_agent=/lib64/rc/sh/cgroup-release-agent.sh,name=openrc)

devpts on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000)

shm on /dev/shm type tmpfs (rw,nosuid,nodev,noexec,relatime)

/dev/sda1 on /boot type ext2 (rw,relatime,block_validity,barrier,user_xattr,acl)

tmpfs on /var/tmp/portage type tmpfs (rw,relatime,size=12582912k,nr_inodes=1048576)

binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,nosuid,nodev,noexec,relatime)

devpts on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000)

/dev/sdb1 on /video type jfs (rw,relatime)

gvfsd-fuse on /home/tony/.gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,relatime,user_id=1002,group_id=1002)
```

```
~ # ls -l  /etc/conf.d/udev-trigger

ls: cannot access '/etc/conf.d/udev-trigger': No such file or directory

```

 This is eudev 1.10

```
MSI ~ # ls -l /etc/mtab

lrwxrwxrwx 1 root root 17 Jun 12  2015 /etc/mtab -> /proc/self/mounts
```

I can fix this by adding "ln -s /dev/sda3 /dev/root" to /etc/local.d/000.start and then e4defrag works again. I found this in a nine year old forum post, but it's a bit kludgy. I have to remember to change this if I rearrange the disk or move the installation.  Besides, it works fine in latest 4.4 and 4.14   What changed in later kernels? A bug?  Apparently, according to the old post, the kernel creates /dev/root as a link to the ramdisk while booting and should remove it later. A kernel bug? Or a new setting that I took by default?

----------

## Anon-E-moose

I'm a little confused. You don't have /dev/root but some packages expect it?

Nothing should expect it (not that it hurts to be there), but from the little looking I did every time there was a question with it, it dealt with initrd or similar.

How do you start your system? 

And if you really need it, for whatever reason, I believe that Ant.P pointed out /etc/conf.d/udev* has a setting for it so you don't have to do it manually, just uncomment it.

Note: on older udevs it's under /etc/conf.d/udev not udev-trigger.

----------

## Tony0945

I do have /dev/root, if I boot 4.17.x or 4.18.x  

If I boot 4.4.x or 4.14.x I don't.

Nothing expects it and it interferes with some programs, unless I siymlink it.

I boot without an initramfs using grub legacy.

```
default 0

timeout 10

splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title=Gentoo Stable (4.18.19-gentoo)

root (hd0,0)

kernel /boot/vmlinuz-4.18.19-gentoo  root=/dev/sda3 vga=0x365 net.ifnames=0

title=Gentoo EOL (4.17.19-gentoo)

root (hd0,0)

kernel /boot/vmlinuz-4.17.19-gentoo  root=/dev/sda3 vga=0x365 net.ifnames=0

title=Gentoo LongTerm (4.14.81-gentoo)

root (hd0,0)

kernel /boot/vmlinuz-4.14.81-gentoo  root=/dev/sda3 vga=0x365 net.ifnames=0

title=Gentoo LongTerm (4.4.163-gentoo)

root (hd0,0)

kernel /boot/vmlinuz-4.4.163-gentoo  root=/dev/sda3 vga=0x365 net.ifnames=0

title=memtest86+

root (hd0,0)

kernel /boot/memtest86plus/memtest

```

Last edited by Tony0945 on Wed Nov 28, 2018 2:30 pm; edited 1 time in total

----------

## Ant P.

Try this and see if there's a /dev/root on disk:

```
mkdir -p /mnt/gentoo && mount -o bind / /mnt/gentoo

ls -l /mnt/gentoo/dev/

umount /mnt/gentoo
```

It might be picking it up from the disk filesystem early at boot, before /dev gets mounted over and renders it invisible. Just a guess.

----------

## Tony0945

 *Ant P. wrote:*   

> Try this and see if there's a /dev/root on disk:
> 
> ```
> mkdir -p /mnt/gentoo && mount -o bind / /mnt/gentoo
> 
> ...

 

No /dev/root

pastebinned at http://dpaste.com/2Q70TNQ

----------

## Anon-E-moose

Interesting https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=907634 especially message #10

ETA: is /dev/root listed in /proc/self/mounts

----------

## Ant P.

I have to admit I'm pretty lost here. So to sum up:

There's nothing in the bootloader config to suggest it's feeding weird paths to the kernel (cat /proc/cmdline would verify this, but I don't expect a surprise)

We know the only filesystems involved are the disk and devtmpfs, because there's no initramfs

There's no /dev/root to be found in the filesystem, except when you created it after the fact as a workaround

/etc/mtab is correctly pointing to /proc/self/mounts

/proc/self/mounts (and the `mount` command, which should produce near-identical output anyway) is claiming that / is mounted on a /dev/root which shouldn't exist

Are you running on old openrc/eudev versions, by any chance? That's about the only other thing I can think of at this point.

----------

## Tony0945

 *Ant P. wrote:*   

>  Are you running on old openrc/eudev versions, by any chance? That's about the only other thing I can think of at this point.

 

Yes, eudev-1.10 , but if that was the problem why are the latest 4.4 and 4.14 LTS kernels running correctly?

----------

## Tony0945

 *Anon-E-moose wrote:*   

> Interesting https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=907634 especially message #10

 

That explains why e4defrag prints the version and exits.

Still wondering where the /dev/root is coming from. 

Did a meld on kernel .configs but noting there to remotely account for it.

I've put the link in local startup but I should really check for kernel version before doing so.

Going to build 4.19 and see what it does.

----------

## Anon-E-moose

On one of the systems where /dev/root is there, post the result of "cat /etc/mtab"

*hmm* https://archives.gentoo.org/gentoo-commits/message/0febf7851333595045e20fc4186a7f79 (look for /dev/root)

The other thing I noticed when googling various combination to see what was going on, is that sometime after 4.14, the kernel quit using sys_open in favor of ksys_open, but I don't know if that has anything to do with it.

----------

## Tony0945

 *Anon-E-moose wrote:*   

> On one of the systems where /dev/root is there, post the result of "cat /etc/mtab"
> 
> *hmm* https://archives.gentoo.org/gentoo-commits/message/0febf7851333595045e20fc4186a7f79 (look for /dev/root)
> 
> The other thing I noticed when googling various combination to see what was going on, is that sometime after 4.14, the kernel quit using sys_open in favor of ksys_open, but I don't know if that has anything to do with it.

 cat /etc/mtab This from 4.19.2

----------

## Tony0945

 *Anon-E-moose wrote:*   

> On one of the systems where /dev/root is there, post the result of "cat /etc/mtab"
> 
> *hmm* https://archives.gentoo.org/gentoo-commits/message/0febf7851333595045e20fc4186a7f79 (look for /dev/root)
> 
> The other thing I noticed when googling various combination to see what was going on, is that sometime after 4.14, the kernel quit using sys_open in favor of ksys_open, but I don't know if that has anything to do with it.

 

Oh God! He is messing with the kernel now. I'll try vanilla-4.19.2 and see what happens.

----------

## Anon-E-moose

 *Tony0945 wrote:*   

>  *Anon-E-moose wrote:*   On one of the systems where /dev/root is there, post the result of "cat /etc/mtab"
> 
> *hmm* https://archives.gentoo.org/gentoo-commits/message/0febf7851333595045e20fc4186a7f79 (look for /dev/root)
> 
> The other thing I noticed when googling various combination to see what was going on, is that sometime after 4.14, the kernel quit using sys_open in favor of ksys_open, but I don't know if that has anything to do with it. 
> ...

 

Interestingly enough that post goes back to 2013 and the last comment was from 2016, where there were still periodic problems.

One of the devs, made a comment that it seemed to be a bug from the kernel itself, causing it.

If so, it's probably one of those race conditions that only get triggered when the conditions are right.

I tend to think he might be right and it's a kernel bug, /dev/root shouldn't exist especially when the kernel is started with a proper root= parm.

----------

## Tony0945

vanilla-19.2 still has dev/root     When I edited ksys_open to sys_open, it made no difference.

----------

## Anon-E-moose

 *Quote:*   

> /dev/root is a generic device which can be used in the fstab. One can also use 'rootfs'. Doing this offers some advantage in that it allows yout to be less specific. What I mean is, if the root partition is on an external drive, it may not always show up as the same device and successfully mounting it as / would require changing the fstab to match the correct device. By using /dev/root it will always match whatever device is specified in the kernel boot paramters from lilo or grub.
> 
>     /dev/root has always been present as a virtual mount point, even if you never saw it. So has rootfs (compare this to the special virtual devices like proc and tmpfs which have no preceeding /dev)
> 
>     /dev/root is a virtual device like 'proc' or /dev/tcp'. There is no device node in /dev for these things -it's already in the kernel as a virtual device.

 

From a discussion https://unix.stackexchange.com/questions/17563/find-out-what-device-dev-root-represents-in-linux/17566

Now, WHY it's showing up is the mystery.

ETA: I'm still running 4.14 though I intend to move up to 4.19 soon, I just hadn't wanted to mess with it today. I'll keep an eye after I update to see what shows.

----------

## Tony0945

Temporarily adding the following to /etc/local.d/000.start

```
#fix root mount

KSERIES=" `uname -r | cut -f 3|cut -d . -f2`"

if [ $KSERIES > 14 ]; then

        ln -s /dev/sda3 /dev/root

fi

```

----------

## Tony0945

Problem just appeared in 4.14.90-gentoo, wasn't there in 4.14.88-gentoo

----------

