Monday, December 13, 2010

Create Ramdisk, Ubuntu Kubuntu Ramdrive, Change default Ramdisk size

The following script will create a usable ram disk in /home/yourhome/autotemp/ directory.  

It is a very basic script and could be improved by taking parameters for the directory (/home/$USER/autotemp) and for the ram disk number (/dev/ram0).  It has drive zero (0) hard coded but could use any of the default Linux ram devices /dev/ram0 - /dev/ram15 (16 disks at once with available RAM).  See instructions in the script for changing the default ram drive size from 64MB to something else.

Thanks to Vane and Khattam for their prior work.

Save content between dashes (----)  to a temp directory as start_ramdisk_0

to copy to system try
sudo cp start_ramdisk_0 /usr/local/.

to make runable try 
chmod +x /usr/local/start_ramdisk_0

-------------------------------------------------------------------------------------------------------
#!/bin/bash 
# Ramdisk maker
# warren jones
# 13 December 2010
#
# based upon scripts from 
#
#
# RAMDISK instructions for UBUNTU, KUBUNTU  
#
# save this file to /usr/local/bin  run as root
# Default drive size for ubuntu/kubuntu is 64MB
# To increase the RAMDISK size
# edit /etc/default/grub and append ramdisk_size=SIZE_IN_BYTES to GRUB_CMDLINE_LINUX_DEFAULT within quotes
# run gksu gedit /etc/default/grub
# For 256Mb RAM Disk, run
# GRUB_CMDLINE_LINUX_DEFAULT="quiet splash ramdisk_size=256000"
# After saving update grub
# sudo update-grub
# restart  computer for drive size changes to take effect


#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
 
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
 
 
USER_NAME=$USER
TMP_PROFILE_DIR=/home/$USER/autotemp/disk0
 
RAM_DEVICE=/dev/ram0
 
umount $RAM_DEVICE
mkdir -p $TMP_PROFILE_DIR
umount $TMP_PROFILE_DIR
mke2fs -m 0 $RAM_DEVICE
mount -t ext2 $RAM_DEVICE $TMP_PROFILE_DIR
chown $USERNAME:root $TMP_PROFILE_DIR
chmod 0770 $TMP_PROFILE_DIR

No comments: