All Forums
 Embedded Linux
 Linux FAQ
 How do I change the size of a ramdisk?
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

jlackey

213 Posts

Posted - 08 May 2002 :  16:05:28  Show Profile  Email Poster
How do I change the size of a ramdisk?

If you want to make a ramdisk bigger, look at How big can a ramdisk be? first.

Create places to mount the old (current) and new (resized) ramdisks:
mkdir /mnt/old-ramdisk
mkdir /mnt/new-ramdisk

Create an empty ramdisk that is the size you want:
dd if=/dev/zero of=my-new-ramdisk bs=size-of-my-new-ramdisk count=1
mkfs.ext2 my-new-ramdisk

Unzip the old ramdisk and mount both ramdisks:
gunzip my-old-ramdisk.gz
mount -o loop old-ramdisk /mnt/old-ramdisk
mount -o loop new-ramdisk /mnt/new-ramdisk

Copy the contents of the old ramdisk to the new one:
cd /mnt/new-ramdisk
tar cf - -C /mnt/old-ramdisk . | tar xf -

Unmount the ramdisks and zip the new one:
umount /mnt/old-ramdisk
umount /mnt/new-ramdisk
gzip new-ramdisk

Note: If you just want a little more free space and you've been making lots of changes to your ramdisk, try making your new ramdisk the same size as your old ramdisk. You may find you have enough free space when the files are rearranged.

(Thanks to Vijay Kishan for the script)


30-Dec-2003: jlackey
24-May-2002: jlackey
  Topic  
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.02 seconds. Snitz Forums 2000