PDA

View Full Version : How to change the ramdisk size



James Board
18th August 2008, 09:18 PM
Using a ramdisk on FC7 is easy enough: mke2fs /dev/ram0 ; mount /dev/ram0 /mnt/RAMDISK. However, the default ramdisk size is only 16 megabytes, which is too small. How can I create a larger (say, 1 gbyte) RAMdisk?

Jim

PatMcLJr
18th August 2008, 09:37 PM
man mke2fs
man mke2fs.conf

looks like you can change the size on the command line or in the config file

Best of Luck,
Pat Jr.

James Board
18th August 2008, 09:49 PM
>man mke2fs
>man mke2fs.conf

Yes, I read the man pages before I posted. There is no option to change the size of the ramdisk in those man pages.

James Board
18th August 2008, 10:10 PM
Looks like it needs to be configured in the kernel at boot. I added the following option to /etc/grub.conf and rebooted and it worked.

ramdisk_size=32000

The size is in 1-kbyte blocks and it looks like all RAMdisks are forced to be the same size (at least with this method). If anybody knows how to create varying size RAMdisks on the fly (no reboot required), let me know.

Jim

A.Serbinski
19th August 2008, 04:55 AM
mount -t tmpfs -o size=1G tmpfs /mnt

Check "man mount" under "tmpfs"

Mystinar
13th October 2008, 10:08 PM
This is much easier to do in Arch Linux. You just add this to /etc/fstab:


none /path/to/location ramfs 0 0

After that, you create the directory that it gets mounted to (I use /mnt/ramdisk) and then mount the directory. As far as size, the ramdisk does not appear to have an arbitrary size limit, using however much space it needs.

Read more here: http://wiki.archlinux.org/index.php/Ramdisk


EDIT: I just tried this under Fedora, and it works just fine.

A.Serbinski
14th October 2008, 03:59 AM
ramfs is not a "feature of archlinux" -- its common to all distros, BUT, you know what? You don't want to do that and this is why:

1) If you don't know how big your ramdisk needs to be, then you probably will end up running the ram down to nothing. That means that your system will run out of ram and end up completely unresponsive.
2) ramfs will not swap, that means that when you chew up all the ram, everything will immediately grind to a halt.

Thats why I suggested using tmpfs -- because it lets you put a sensible limit on the size of the ramdisk and because when the ram is in high demand, it will safely swap rather than locking everything up.


Either will work, direct or fstab, but ramfs should really only be used under more controlled or academic conditions.

And FYI: tmpfs is much like ramfs, just better. Here's an excerpt from tmpfs.txt in the kernel documentation:

If you compare it to ramfs (which was the template to create tmpfs)
you gain swapping and limit checking. Another similar thing is the RAM
disk (/dev/ram*), which simulates a fixed size hard disk in physical
RAM, where you have to create an ordinary filesystem on top. Ramdisks
cannot swap and you do not have the possibility to resize them.

Mystinar
14th October 2008, 12:19 PM
Thanks for letting me know about that. I've changed the ramfs to tmpfs. I also checked if specifying size works in /etc/fstab (changing "defaults" to "defaults,size=1G") and that works fine.