Linux – Creating a ram disk on Linux

linuxramdisk

I have a machine with 62GB of RAM, and a trunk that's only 7GB, so I thought I would create a RAM disk and compile there. I am not a Linux expert. I found instructions on the internet to create the RAM disk:

mkfs -q /dev/ram1 8192

but I changed the 8192 to 16777216 in an attempt to allocate 16GB of ram disk.

I got the following error:

mkfs.ext2: Filesystem larger than apparent device size.
Proceed anyway? (y,n) 

At which point I got spooked and bailed.

sudo dmidecode --type 17 | grep Size

shows

8x8192MB + 2048MB = 67584 MB

but du on /dev gives 804K.

Is that the problem? Can I overcome that /dev size?

Best Answer

The best way to create a ram disk on linux is tmpfs. It's a filesystem living in ram, so there is no need for ext2. You can create a tmpfs of 16Gb size with:

mount -o size=16G -t tmpfs none /mnt/tmpfs
Related Question