Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I do

yum install MAKEDEV
fdisk -l /dev/ram

I get the that it is 16MB.

I am using MAKEDEV to get a block-device instead of tmpfs.


Is it possible to set it to e.g. 1GB?

share|improve this question
FYI, MAKEDEV is obsolete. These days udev automatically creates the dev node when the driver is loaded. – psusi Dec 31 '12 at 15:30
@psusi Very interesting. How is that done with udev? When I boot I don't have /dev/ram* so doing fdisk -l /dev/ram1 fails. – Sandra Dec 31 '12 at 17:12
The kernel notifies udev when new devices are detected, and it creates the dev node. Actually these days most distributions mount /dev as a devtmpfs, where the kernel internally automatically creates the node, and notifies udev for any additional processing. – psusi Dec 31 '12 at 21:22
@psusi I am not sure I understand. What would you type to get the ramdisk? – Sandra Dec 31 '12 at 22:25
You don't have to type anything; as long as the ramdisk driver is loaded, the dev nodes exist. If you had to create them with MAKEDEV then your udev/devtmpfs are not working correctly. – psusi Jan 1 '13 at 2:33
up vote 4 down vote accepted

The block device driver for ramdisks has the size set at the time the driver loads, using the ramdisk_size= parameter to specify the number of blocks (default blocksize = 1024 bytes, see ramdisk_blocksize= as well) to allocate to each ramdisk. If you're loading it as a module, you can use that parameter when loading the module, otherwise if it's built into the kernel you'll have to boot that system as a kernel option.

It appears that at some point in 2.6 the ramdisk driver was changed so that the first time you accessed it, the size of the ramdisk was set permanently (rather than using the kernel option).

Regarding setting it to 1GB, I think it would be possible but once the ramdisk has been accessed it will occupy all 1GB in RAM and cannot be swapped out (unlike tmpfs which can swap if necessary). There is also no way to unload the ramdisk and free the memory without a reboot.

share|improve this answer
When I do that, I can see in dmesg that the ramdisk_size= have been passed, but /dev/ram* all remains 16MB. I have tried to set it to 99MB on my 8GB ram server, and it is still 16MB. – Sandra Dec 31 '12 at 17:14
@Sandra It may be that you'll need to use something like dd if=/dev/zero of=/dev/ram1 bs=1024 count=1000000 to allocate the full GB before you do anything else with the device. Also, I'm not sure that I'd trust fdisk with the ramdisk since they're not partitionable normally. – DerfK Dec 31 '12 at 17:24
Interesting idea. Didn't work however. 16777216 bytes (17 MB) copied, 0.051657 s, 325 MB/s – Sandra Dec 31 '12 at 17:53
The size is dynamically grown to fit as much as you write to it, like a file. The ramdisk_size argument has been obsolete for years. You also most certainly can unload the ramdisk module, or free a particular ramdisk memory with blockdev --flushbufs /dev/ramX – psusi Jan 1 '13 at 2:52

mkfs -q /dev/ram1 X where X is the size in KB. You'd want 1048576 for 1GB.

share|improve this answer
If I do that then I get mkfs.ext2: Filesystem larger than apparent device size. and it fails. – Sandra Dec 31 '12 at 15:06
What about using ext4? – mdpc Dec 31 '12 at 17:58
That is a warning, which prompts to whether to continue or not. Say yes. – psusi Jan 1 '13 at 2:54

It looks like you're more looking for something like mount -t tmpfs -o size=1024m tmpfs mount_directory

share|improve this answer
Updated OP. Using MAKEDEV because I want a block-device. – Sandra Dec 31 '12 at 15:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.