On linux, there is a /dev/root device node. This will be the same block device as another device node, like /dev/sdaX. How can I resolve /dev/root to the 'real' device node in this situation, so that I can show a user a sensible device name?

For example, I might encounter this situation when parsing /proc/mounts.

I'm looking for solutions that would work from a shell/python script but not C.

  • have you checked here ? linux-diag.sourceforge.net/Sysfsutils.html It recommends way to query the kernel about attached devices of all kinds, not sure, if its what you are looking for !
    – user702846
    Jul 28, 2011 at 23:02

6 Answers 6


Parse the root= parameter from /proc/cmdline.

  • 1
    So much safer than dereferencing a symbolic link. +1 :)
    – Tim Post
    Jul 29, 2011 at 2:38
  • 1
    This works on the three distros (fc14, rhel5, ubuntu 11.04) that I've looked at, with the slight caveat that there is an extra step needed to deal with root=UUID= type arguments.
    – kdt
    Jul 29, 2011 at 10:16
  • I'm interested in why this is safer than the readlink solution, could someone elaborate?
    – opello
    Jun 26, 2013 at 13:53
  • readlink does not always work, I'm working on this problem right now and found a user whose system shows no results from: readlink /dev/root - which tripped a glitch in the program I'm working on, which is why I came to this thread. The correct test is to first do: readlink /dev/root, then if null, find it in /proc/cmdline, but parsing /proc/cmdline is not as easy as a better solution, so I'll keep looking.
    – Lizardx
    Mar 18, 2018 at 20:31
  • @kdt how do I deal with root=UUID arguments? Feb 21, 2022 at 21:41

This should probably be updated, because a lot of the information given here is misleading, and may actually never have been comprehensively correct.


For the / mount point, you are just told that it corresponds to /dev/root, which is not the real device you are looking for.

Of course, you can look at the kernel command line and see on which initial root filesystem Linux was instructed to boot (root parameter):

$ cat /proc/cmdline mem=512M console=ttyS2,115200n8 root=/dev/mmcblk0p2 rw rootwait

However, this doesn’t mean that what you see is the current root device. Many Linux systems boot on intermediate root filesystems (like initramdisks and initramfs), which are just used to access the final one.

One thing this points out was that the thing in /proc/cmdline is not necessarily the actual final device root actually live on.

That's from the busybox people, who I assume know what they are talking about when it comes to boot situations.


The second useful resource I found is a very old Slackware thread about the question of /dev/root, from the age of this thread, we can see that all the variants were always present, but I believe 'most' distros were using the symbolic link method, but that was a simple kernel compile switch, it could make one, or not make one if I understood the posters correctly, that is, switch it one way, and readlink /dev/root reports the real device name, switch it the other, and it doesn't.

Since the main topic of that thread was how to get rid of /dev/root, they had to get into what it actually is, what makes it, etc, which means, they had to understand it to get rid of it.

gnashly explained it well:

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

This explains why a symbolic link does not necessarily exist. I'm surprised I never hit this issue before now, given that I maintain some programs that need to know this information, but better late than never.

I believe some of the solutions offered here will 'often' work, and are probably what I will do, but they are not the actual true solution to the problem, which as the busybox author noted, is significantly more complicated to implement in a very robust manner.

[UPDATE:} After getting some user test data, I'm going with the mount method, which seemed to be ok for some cases at least. The /proc/cmdline was not useful because there are too many variants. In the first example, you see the old method. This is less and less common because it's strongly discouraged to use it (the original /dev/sdx[0-9] type syntax) because those paths can change dynamically (swap disk order, insert new disk, etc, and suddenly /dev/sda1 becomes /dev/sdb1).

root=LABEL=random string

VS the very clean and easy to parse:

/dev/sda1 on / type ext4 (rw,noatime,data=ordered)

In the case of cmdline, you'll see, the only variant that is the right 'answer' in theory is the first, deprecated one, since you should not refer root to a moving target like /dev/sdxy

The next two require doing the further action of getting the symbolic link from that string in either /dev/disk/by-uuid or /dev/disk/by-label

The last one requires I believe using parted -l to find what that parted id is pointing to.

That's only the variants I know of and have seen, there could well be others, like GPTID, for example.

So the solution I'm using is this:

first, see if /dev/root is a symbolic link. If it is, verify it's not to /dev/disk/by-uuid or by-label, if it is, you have to do a second step of processing to get the last real path. Depends on the tool you use.

If you got nothing, then go to mount, and see how that is. As a last fallback case, one I'm not using because the arguments given against it not even necessarily being the actual partition or device in question are good enough for me to reject that solution for my program. mount is not a fully robust solution, and I'm sure given enough samples, it would be easy to find cases where it's not right at all, but I believe these two cases cover 'most' users, which is all I needed.

The nicest, cleanest, and most reliable solution would have been for the kernel to just always make the symbolic link, which would not have hurt anything or anyone, and call it good, but that's not how it worked out in the real world. .

I don't consider any of these as 'good or robust' solutions, but the mount option appears to satisfy the 'good enough', and if the truly robust solution is required, use the stuff that busybox recommended.


On the systems I've looked at, /dev/root is a symlink to the real device, so readlink /dev/root (or readlink -f /dev/root if you want the full path), will do it.

  • Or just ls -l /dev/root - shorter to type :) Jul 29, 2011 at 6:32
  • @jankes, but then you have to parse the output of ls (he asked for something to use in a script).
    – cjm
    Jul 29, 2011 at 7:17
  • 2
    Does not work on archlinux.
    – user3356
    Jul 30, 2013 at 18:31
  • 1
    @g33kz0r, my Arch Linux box doesn't have a /dev/root, which makes the question meaningless.
    – cjm
    Jul 30, 2013 at 19:52
  • 4
    Just to clarify, some systems with /dev/root will NOT show output for either ls -l or readlink because it's not a link, not in the normal sense we think of links anyway. I'm hitting this issue right now. So I'd update this answer to be correct for the systems he's looked at, but incorrect for an entire class of systems, like current ubuntu I believe, that he had not seen. I also had not seen this new variant for what it's worth until recently.
    – Lizardx
    Mar 18, 2018 at 20:33

Well /dev/root is just a symbolic link to the real device, so you can use readlink(2) to find out where it points from a program, or readlink(1) to do the same thing from a shell script.

  • No. Does not work on archlinux
    – user3356
    Jul 30, 2013 at 18:31
  • Also not on Debian, openSUSE, CentOS (incomplete list) :(
    – pevik
    Mar 8, 2018 at 15:40
  • Add ubuntu to the list.
    – Lizardx
    Mar 18, 2018 at 20:34

Maybe I'm missing something, but what about:

mount|grep ' / '|cut -d' ' -f 1
  • this gives me /dev/root
    – Rick
    Oct 28, 2022 at 20:09

If what you are looking for is a the device which the / filesystem is mounted on, then the easiest answer is probably to use: findmnt / (or findmnt -n -o SOURCE / for machine-readable output).

findmnt is part of util-linux, which should be present on all mainstream Linux distrubutions.

  • findmnt is useful, but may I ask what this has to do with the question here - which concerns the /dev/root designation in df -h?
    – Seamus
    Apr 21, 2022 at 23:07
  • not available on my busybox
    – Rick
    Oct 28, 2022 at 20:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .