What is rootfs# and what can you do with it?

18

4

I have been dropped to a [rootfs /]# prompt many times when booting my distro failed. Usually I found I couldn't fix the problem with the limited commands available, so I would use any spare Live CD I had laying around.

But what is the rootfs prompt? Why does it have limited commands available? And can I use it to boot my system after the problem has been fixed?

Wolfizen

Posted 2013-04-02T06:13:39.250

Reputation: 1 122

Similar on SeverFault: http://serverfault.com/questions/275988/what-is-rootfs

– Ciro Santilli 新疆改造中心法轮功六四事件 – 2015-05-14T20:55:02.163

Answers

10

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.

enter image description here

At kernel initialization time, there is an absolutely minimal filesystem registered, called rootfs. The code that implements this filesystem can be found in fs/ramfs/inode.c, which also happens to contain the code for the ramfs filesystem. rootfs is basically identical to ramfs, except for the specification of the MS_NOUSER flag. This is interpreted by the routine graft_tree in fs/namespace.c, and I think it prevents userland processes doing their own mounts of rootfs.

The routine init_mount_tree (found in fs/namespace.c) is called at system startup time to mount an instance of rootfs, and make it the root namespace of the current process (remember that, under Linux, different processes can have different filesystem namespaces).

It contains all applications, settings, devices, data and more. Without the root file system, your Linux system can not run.

See: https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt

stderr

Posted 2013-04-02T06:13:39.250

Reputation: 9 300

That was a good answer explaining the rootfs file system, and explains the limited commands available, but there is nothing about the prompt itself and what you can do with it. – Wolfizen – 2013-06-05T19:05:30.923

@wolfo9999: I updated my answer to explain better. – stderr – 2013-06-05T20:10:24.857

You sure did :) great answer now that I can visualize it. +50 when I can award it. Says I have to wait 17 hours. Although that's enough time for someone else to make a better answer if they can. – Wolfizen – 2013-06-05T20:26:15.207

@TiagoƇ. Really great answer that helped me a lot too! May I ask where this great graphic explanation is from? A source link would be nice ;) – erch – 2013-12-03T22:13:19.463

@chirp look in https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt =]

– stderr – 2013-12-03T22:36:30.337

@TiagoƇ. I'm aware, thank you. But: Where do you have this IMAGE from? I am looking for something like this quite a while – erch – 2013-12-04T11:54:36.623