Skip to contentSkip to conversation

/ on ramfs, possible?

DISCUSSION Anders Eriksson 7 participants 10 messages Oct 30, 2000 – Nov 1, 2000

lore
Share & tools
lore
#0 lore raw

I want my / to be a ramfs filesystem. I intend to populate it from an initrd image, and then remount / as the ramfs filesystem. Is that at all possible? The way I see it the kernel requires / on a device (major,minor) or nfs.

Am I out of luck using ramfs as /? If it's easy to fix, how do I fix it?

/Anders

#1 lore raw
Followup to:  <[email protected]>
By author:    Anders Eriksson <[email protected]>
In newsgroup: linux.dev.kernel
Quoted 8 lines

I want my / to be a ramfs filesystem. I intend to populate it from an initrd image, and then remount / as the ramfs filesystem. Is that at all possible? The way I see it the kernel requires / on a device (major,minor) or nfs.

Am I out of luck using ramfs as /? If it's easy to fix, how do I fix it?

Use pivot_root instead of the initrd stuff in /proc/sys.

-hpa

Signature · 7 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#2 lore raw
Quoted 9 lines · H. Peter Anvin
Quoted 7 lines

I want my / to be a ramfs filesystem. I intend to populate it from an initrd image, and then remount / as the ramfs filesystem. Is that at all possible? The way I see it the kernel requires / on a device (major,minor) or nfs.

Am I out of luck using ramfs as /? If it's easy to fix, how do I fix it?

Use pivot_root instead of the initrd stuff in /proc/sys.

Urgh. Then you're still using an initrd, and you still have to include all the crap necessary to support those horrid block-device thingies.

Why not just use a ramdisk?

Signature · 7 lines
dwmw2


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#3 lore raw
Quoted 11 lines · David Woodhouse
Quoted 8 lines · H. Peter Anvin
Quoted 7 lines

I want my / to be a ramfs filesystem. I intend to populate it from an initrd image, and then remount / as the ramfs filesystem. Is that at all possible? The way I see it the kernel requires / on a device (major,minor) or nfs.

Am I out of luck using ramfs as /? If it's easy to fix, how do I fix it?

Quoted 7 lines
Quoted 1 line

Use pivot_root instead of the initrd stuff in /proc/sys.

Urgh. Then you're still using an initrd, and you still have to include all the crap necessary to support those horrid block-device thingies.

Why not just use a ramdisk?

Pardon?! This doesn't make any sense...

The question was: how do switch from the initrd to using the ramfs as /? Using pivot_root should do it (after the pivot, you can of course nuke the initrd ramdisk.)

-hpa

Signature · 7 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#4 lore raw
Quoted 5 lines · H. Peter Anvin

Pardon?! This doesn't make any sense...

The question was: how do switch from the initrd to using the ramfs as /? Using pivot_root should do it (after the pivot, you can of course nuke the initrd ramdisk.)

My question is: What do you want to do that for? You can nuke the initrd ramdisk, but you can't drop the rd.c code, or ll_rw_blk.c code, etc. So why not just keep your root filesystem in the initrd where it started off?

Signature · 7 lines
dwmw2


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#5 lore raw
Quoted 5 lines · David Woodhouse
Quoted 2 lines · H. Peter Anvin

Pardon?! This doesn't make any sense...

Quoted 8 lines
Quoted 3 lines

The question was: how do switch from the initrd to using the ramfs as /? Using pivot_root should do it (after the pivot, you can of course nuke the initrd ramdisk.)

My question is: What do you want to do that for? You can nuke the initrd ramdisk, but you can't drop the rd.c code, or ll_rw_blk.c code, etc. So why not just keep your root filesystem in the initrd where it started off?

Umm... because the size of a ramdisk is fixed, but the size of a ramfs is flexible?

I can certainly understand this problem... I might in fact do exactly this in the next version of my SuperRescue disk. There, the ramdisk which is the real root is populated from a .tar.gz file; the initrd is just there to unpack the .tar.gz file onto the "real" ramdisk; the initrd is then jettisoned.

Why not just have the real root be the initrd, you ask? It's too large:
since an initrd needs to exist in both compressed form and uncompressed form in memory at the same time; it would mean SuperRescue would no longer work on systems with 64 MB RAM. If I went to ramfs it might actually work on systems with 48 MB RAM, albeit you better not need to much space in / (or conversely, it would suddenly let you put a whole lot more stuff in /tmp if you have 512 MB.)

-hpa

Signature · 7 lines
<[email protected]> at work, <[email protected]> in private!
"Unix gives you enough rope to shoot yourself in the foot."
http://www.zytor.com/~hpa/puzzle.txt
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#6 lore raw
In reply to David Woodhouse
Quoted 5 lines · David Woodhouse
Quoted 2 lines · H. Peter Anvin

Pardon?! This doesn't make any sense...

Quoted 7 lines
Quoted 3 lines

The question was: how do switch from the initrd to using the ramfs as /? Using pivot_root should do it (after the pivot, you can of course nuke the initrd ramdisk.)

My question is: What do you want to do that for? You can nuke the initrd ramdisk, but you can't drop the rd.c code, or ll_rw_blk.c code, etc. So why not just keep your root filesystem in the initrd where it started off?

ramfs size is far more dynamic than rd, and it shrinks as well as grows.

Unless you are creating a lot of temporary files and such, though, initrd is indeed a much better solution from many perspectives. (IMHO)

Jeff

Signature · 8 lines
Jeff Garzik             | "Mind if I drive?"  -Sam
Building 1024           | "Not if you don't mind me clawing at the
MandrakeSoft            |  dash and shrieking like a cheerleader."
                        |                     -Max
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/
#7 lore raw
In reply to David Woodhouse
Quoted 13 lines · H. Peter Anvin
Quoted 6 lines

Pardon?! This doesn't make any sense...

The question was: how do switch from the initrd to using the ramfs as /? Using pivot_root should do it (after the pivot, you can of course nuke the initrd ramdisk.)

My question is: What do you want to do that for? You can nuke the initrd ramdisk, but you can't drop the rd.c code, or ll_rw_blk.c code, etc. So why not just keep your root filesystem in the initrd where it started off?

Because the stuff on the initrd is not at all what I want in the resultant filesystem. The machine(s) in question are some disk-based some disk-less. I have a system for remote installation/removal of packages (--> the "partition" _has_ to be able to grove/shrink).

The package builder should not have to worry about these details, so the directory hierarcy cannot contain any traces of _how_ the packges got there in the first place.

/Anders

#8 lore raw
In reply to Anders Eriksson
Quoted 6 lines

I want my / to be a ramfs filesystem. I intend to populate it from an initrd image, and then remount / as the ramfs filesystem. Is that at all possible? The way I see it the kernel requires / on a device (major,minor) or nfs.

Am I out of luck using ramfs as /? If it's easy to fix, how do I fix it?

Firstly make sure you get the patches that make ramfs work if they arent all yet applied, then build your initrd that populates it on boot. Now you can make use of the pivot_root() syscall (you may need to generate your own syscall wrapper for that one as its very new). That lets you flip your root and initrd around

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/

#9 lore raw
In reply to Anders Eriksson

In article <[email protected]>,

Quoted 10 lines · Anders Eriksson

--==_Exmh_17293564P
Content-Type: text/plain; charset=us-ascii

I want my / to be a ramfs filesystem. I intend to populate it from an initrd image, and then remount / as the ramfs filesystem. Is that at all possible? The way I see it the kernel requires / on a device (major,minor) or nfs.

Am I out of luck using ramfs as /? If it's easy to fix, how do I fix it?

Yes it works.

You will need pivot_root.

Something like the following at the end of your initrd /linuxrc script should mount your ramfs, copy the existing root fs files to it, pivot and unmount your old root. YMMV

mkdir -p /ramfs /ram1
mount -t ramfs /ramfs /ramfs
find / | sed '/^\/ramfs/d;/^\/proc\/.*/d' | cpio -pdmV /ramfs cd /ramfs
pivot_root . ram1
exec chroot . sh -c 'umount /ram1; exit' < dev/console >dev/console

BTW has anyone thought of writing a small utility to emulate df for ramfs?

Signature · 8 lines
                                            __O 
Fireplug - a Lineo company                _-\<,_ 
PGP Fingerprint: 28 E2 A0 15 99 62 9A 00 (_)/ (_) 88 EC A3 EE 2D 1C 15 68
Stuart Lynne <[email protected]>       www.fireplug.net        604-461-7532
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
Please read the FAQ at http://www.tux.org/lkml/