Ramdisk Size

Tony Travis ajt at rri.sari.ac.uk
Mon Sep 22 13:35:44 EDT 2003


Eric R Johnson wrote:

> I would like to create a large ramdisk to keep a database which will be 
> searched often, but not changed.
> The only thing I currently know how to do to create a ramdisk is:
> mke2fs /dev/ram0
> mount /dev/ram0 /tmp/ramdisk0
> 
> The only problem is that this creates a 4MB ramdisk, and I would like 
> something on the order of 1GB.

Hello, Eric.

Are you *sure* you want to do this?

RAM disks are usually used for loading modules at boot time. That's why 
they are small. Typically, the contents of a RAM disk are used as a root 
filesystem for the kernel to load e.g. SCSI drivers, then discarded when 
the 'real' root filesystem is mounted from SCSI disks. People also use 
them to boot a 'minimal' Linux for diagnostics or for some other reason.

For example, you could create a 10Mb initrd image of a RAM disk using:

	dd if=/dev/zero of=/var/tmp/initrd.img bs=1024 count=10240
	mkfs -t ext3 /tftpboot/initrd.img
	mkdir /mnt/ramdisk
	mount -o loop /tftpboot/initrd.img /mnt/ramdisk
	cp -a /stuff /mnt/ramdisk	# stuff you want on RAM disk
	umount /var/tmp/initrd.img
	zcat /tftpboot/initrd.img > /tftpboot/zinitrd.img

Then, override the 4Mb default at boot time:

	boot: vmlinuz ramdisk_size=10485760 initrd=zinitrd.img

However, I think it would be better to use 'tmpfs' for a 1Gb RAM 
filesystem. The kernel will provide fast access to the most frequently 
accessed areas of your database held in RAM, but it will move the less 
frequently accessed areas onto the swap device freeing up RAM for your 
programs and for other disk caches.

Mounting /tmp as a 'tmpfs' filesystem reserves half of your memory for 
the /tmp filesystem by default. Add an entry like this to /etc/fstab:

	tmpfs	/tmp	tmpfs	defaults	0 0

Beware that openMosix, in particular, does not work well with tmpfs and 
automatically comments out tmpfs entries from your /etc/fstab when you 
install openMosic from the 2.4.21-openmosix1 binary rpm distribution.
	
	Tony.
-- 
Dr. A.J.Travis,                     |  mailto:ajt at rri.sari.ac.uk
Rowett Research Institute,          |    http://www.rri.sari.ac.uk/~ajt
Greenburn Road, Bucksburn,          |   phone:+44 (0)1224 712751
Aberdeen AB21 9SB, Scotland, UK.    |     fax:+44 (0)1224 716687

_______________________________________________
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf



More information about the Beowulf mailing list