-----------------------------
How to RAMboot
This details a method of loading your entire OS into an uncompressed ramdisk. The result is lightning fast performance, and elimination of hard drive noise and power consumption (if swap is not used and the hard drive is spun down).
The basic steps are:
1. Install Debian 4.0 on the hard drive
2. Create a modified /etc/fstab which has tmpfs for the root partition
3. Optionally create a startup script to park hard drives
4. Create a script which makes a stripped down OS image
5. Create a custom initrd.img which loads the OS image into a tmpfs ramdisk
6. Modify /boot/grub/menu.lst with an entry for the custom initrd.img
After completing these steps, you will have a dual boot system with the following boot options:
A) Boot normally, where you install new software or change settings
B) Boot into the "ramboot" OS image, for high speed silent computing
-------------------------------------------------
Step 1. Installing Debian 4.0
a) Install Debian 4.0 onto a partition of least 500megs. For purposes of the rest of these instructions, I'll assume you're have installing into the hda1 partition.
b) In the software selection step, deselect the so-called Base software suite. You will manually install only what you need later on.
c) After doing the install, log in as root and edit /etc/apt/sources.list to comment out the CD-ROM entry (use the command "nano /etc/apt/sources.list"). Then run the following commands:
Code: Select all
apt-get update
apt-get install hdparm localepurge debconf-english
apt-get remove --purge aptitude tasksel tasksel-data laptop-detect
apt-get clean
-------------------------------------------------
Step 2. Create a modified /etc/fstab
Create and edit a new fstab using these commands:
Code: Select all
cd /etc/
cp fstab fstab.ramboot
nano fstab.ramboot
Code: Select all
none / tmpfs defaults 0 0
Step 3. Optionally create a startup script to park hard drives
If you want, create a startup script with these commands:
Code: Select all
nano /etc/init.d/ijkijkijk
chmod 755 /etc/init.d/ijkijkijk
update-rc.d ijkijkijk defaults 20
Code: Select all
#! /bin/sh
# /etc/init.d/ijkijkijk
# Some things that run always
touch /var/lock/ijkijkijk
# Carry out specific functions when asked to by the system
case "$1" in
start)
echo "Starting script ijkijkijk"
echo "Isaac Kuo script parking drives"
hdparm -S 6 /dev/hda
hdparm -y /dev/hda
#hdparm -S 6 /dev/hdb
#hdparm -y /dev/hdb
#hdparm -S 6 /dev/hdc
#hdparm -y /dev/hdc
#hdparm -S 6 /dev/hdd
#hdparm -y /dev/hdd
;;
stop)
echo "Stopping script ijkijkijk"
;;
*)
echo "Usage: /etc/init.d/blah {start|stop}"
exit 1
;;
esac
exit 0
Step 4. Create a script which makes a stripped down OS image
Login as root. Then create a basic script like this:
Code: Select all
#!/bin/sh
#
# Takes an OS snapshot, strips it down, and wraps it up into /snapstrip.tar
# Clean up anything previous
touch /snapstrip.tar
touch /snapstrip
rm -fvr /snapstrip.tar
rm -fvr /snapstrip
# Create temporary ramdisk and copy files over
mkdir /snapstrip
mount -t tmpfs -o size=100% none /snapstrip
cp -vax /. /snapstrip/.
cp -vax /dev/. /snapstrip/dev/.
# Move over the modified fstab
cd /snapstrip/etc/
cp -vax fstab.ramboot fstab
# Strip down unnecessary stuff
cd /snapstrip/
rm -fvr /snapstrip/boot/*
rm -fvr /snapstrip/var/lib/apt/lists/*
rm -fvr /snapstrip/usr/share/doc-base/*
rm -fvr /snapstrip/usr/share/doc/*
rm -fvr /snapstrip/usr/share/man/*
rm -fvr /snapstrip/lib/modules/*/kernel/drivers/bluetooth
rm -fvr /snapstrip/lib/modules/*/kernel/drivers/ieee1394
rm -fvr /snapstrip/lib/modules/*/kernel/drivers/parport
rm -fvr /snapstrip/lib/modules/*/kernel/drivers/pcmcia
rm -fvr /snapstrip/lib/modules/*/kernel/drivers/telephony
rm -fvr /snapstrip/lib/modules/*/kernel/drivers/isdn
rm -fvr /snapstrip/lib/modules/*/kernel/drivers/md
rm -fvr /snapstrip/lib/modules/*/kernel/fs/ntfs
rm -fvr /snapstrip/lib/modules/*/kernel/fs/reiserfs
rm -fvr /snapstrip/lib/modules/*/kernel/fs/hfs
rm -fvr /snapstrip/lib/modules/*/kernel/fs/hfsplus
rm -fvr /snapstrip/lib/modules/*/kernel/fs/xfs
rm -fvr /snapstrip/lib/modules/*/kernel/net/appletalk
rm -fvr /snapstrip/lib/modules/*/kernel/net/bluetooth
rm -fvr /snapstrip/lib/modules/*/kernel/net/irda
### ADD IN MORE STUFF TO STRIP HERE ###
# Create the tar archive
cd /snapstrip/
tar cf /snapstrip.tar *
-------------------------------------------------
Step 5. Create a custom initrd.img which loads the OS image into a tmpfs ramdisk
This is step is a hack. It works with Debian 4.0. There's probably a less "hackish" way of doing this.
Use the following commands:
Code: Select all
cd /usr/share/initramfs-tools/scripts/
cp -vax local local.bak
nano local
cp -vax local local.ramboot
Code: Select all
[...]
########### ramboot
# FIXME This has no error checking
# Mount root
### mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
########### mount the filesystem
mkdir /ijkijk
mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} /ijkijk
########### create root ramdisk
mount -t tmpfs -o size=100% none ${rootmnt}
########### copy the files over to the ramdisk
cd ${rootmnt}
tar xf /ijkijk/snapstrip.tar
########### umount the filesystem and set to spin down
umount /ijkijk
hdparm -S 1 /dev/hda
[...]
Code: Select all
mkinitramfs -o /boot/initrd.img.ramboot
Code: Select all
cp -vax local.bak local
-------------------------------------------------
Step 6. Modify /boot/grub/menu.lst with an entry for the custom initrd.img
Modify /boot/grub/menu.lst with a new entry. Copy existing OS's entry. Then modify the initrd to use your new initrd.img. It will look something like this:
Code: Select all
title RAMdisk Debian GNU/Linux
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-6-486 root=/dev/hda1 ro
initrd /boot/initrd.img.ramboot
After following these steps, you'll have a very basic working system. Now you can boot into the "main" OS and install things like X (only install the xserver you need) and other programs like icewm and iceweasel. For example:
apt-get install xserver-xorg-video-vesa xserver-xorg-video-ati xfonts-base alsa-base alsa-utils icewm menu iceweasel xfe aterm
The default icewm theme is rather ugly, so you can copy over a nice theme like /usr/share/icewm/themes/IceCrack2 from another install. Obviously, you don't want to install all of the themes in icewm-themes since they'll be consuming RAM just sitting there.
=====================
=====================
=====================
=====================
=====================
(Original How-to is below)
=====================
=====================
=====================
=====================
=====================
How to RAMboot
This details a method of loading your entire OS into an uncompressed ramdisk. The result is lightning fast performance, and elimination of hard drive noise and power consumption (if swap is not used and the hard drive is spun down).
The basic steps are:
1. Install Debian 4.0 twice on the hard drive
2. Create a modified /etc/fstab which has tmpfs for the root partition
3. Create a script which makes a stripped down OS image
4. Create a custom initrd.img which loads the OS image into a tmpfs ramdisk
5. Modify /boot/grub/menu.lst with an entry for the custom initrd.img
-------------------------------------------------
After completing these steps, you will have a triple boot system with the following boot options:
A) "auxiliary" OS, where you run the OS snapshot/stripping script
B) "main" OS, where you install new software or change settings
C) "ramboot" OS, for high speed silent computing
-------------------------------------------------
Step 1. Installing Debian 4.0 twice
Create three partitions:
hda1 ext3 4 gigs
hda5 ext3 2 gigs (unless you have lots of RAM and plan on making a BIG image)
hda6 swap
First, install onto hda5 do NOT select either Desktop Workstation or Base software suites.
Upgrade the kernel, and install the following:
apt-get install hdparm localepurge debconf-english (will remove debconf-i18n)
Do some stripping down by removing the following:
apt-get remove --purge aptitude tasksel nano
apt-get clean
Second, install onto hda1. This is the auxiliary OS, and you do not need to do anything special to strip it down if you don't want to. Upgrade the kernel to the same version as the other install.
In the auxiliary OS, set it to mount /dev/hda5 to /mnt/hda5.
-------------------------------------------------
Step 2. Create a modified /etc/fstab
Go to create and edit a new fstab using these commands:
cd /mnt/hda5/etc/
cp -vax fstab fstab.ramboot
vi fstab.ramboot
Comment out the swap entry and the /dev/hda5 entry. Create a new / line like this:
none / tmpfs defaults 0 0
-------------------------------------------------
Step 3. Create a script which makes a stripped down OS image
Boot up into the auxiliary hda1 OS, and login as root. Then create a basic script like this:
Code: Select all
#!/bin/sh
#
# Takes an OS snapshot from /mnt/hda5, strips it down, and wraps it up into /snapstrip.tar
# Clean up anything previous
touch /snapstrip
touch /snapstrip.tar
rm -fvr /snapstrip
rm -fvr /snapstrip.tar
# Copy the files over
mkdir /snapstrip
cp -vax /mnt/hda5/* /snapstrip/
# Move over the modified fstab
cd /snapstrip/etc/
cp -vax fstab.ramboot fstab
# Strip down unnecessary stuff
cd /snapstrip/
rm -fvr /snapstrip/boot/*
rm -fvr /snapstrip/var/lib/apt/lists/*
rm -fvr /snapstrip/usr/share/doc-base/*
rm -fvr /snapstrip/usr/share/doc/*
rm -fvr /snapstrip/usr/share/man/*
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/drivers/bluetooth
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/drivers/ieee1394
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/drivers/parport
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/drivers/pcmcia
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/drivers/telephony
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/drivers/isdn
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/drivers/md
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/fs/ntfs
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/fs/reiserfs
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/fs/hfs
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/fs/hfsplus
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/fs/xfs
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/net/appletalk
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/net/bluetooth
rm -fvr /snapstrip/lib/modules/2.6.18-6-486/kernel/net/irda
#############ADD IN MORE STUFF TO DELETE HERE
# Create the tar archive
cd /snapstrip/
tar cf /snapstrip.tar *
-------------------------------------------------
Step 4. Create a custom initrd.img which loads the OS image into a tmpfs ramdisk
This is step is a hack. It works with Debian 4.0, for now at least. There's probably a less "hackish" way of doing this.
On the auxiliary OS, go to /usr/share/initramfs-tools/scripts/
cd /usr/share/initramfs-tools/scripts/
Create a backup of "local" and edit a modified version with:
cp -vax local local.bak
vi local.ramboot
cp -vax local local.ramboot
You'll want to modify the portion where the actual "mount" command is done. Comment it out and insert something like this:
Code: Select all
[...]
########################################ramboot
# FIXME This has no error checking
# Mount root
### mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
################################ mount the filesystem
mkdir /ijkijk
mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} /ijkijk
################################ create ramdisk (note hardcoded size)
mount -t tmpfs -o size=400M none ${rootmnt}
################################ copy the files over to the ramdisk
cd ${rootmnt}
tar xf /ijkijk/snapstrip.tar
################################ umount the filesystem and set to spin down
umount /ijkijk
hdparm -S 6 /dev/hda
########################################ijk
[...]
mkinitramfs -o /boot/initrd.img-2.6.18-6-486.ramboot
After creating this ramdisk make sure to copy back the backup file with:
cp -vax local.bak local
This is important! If you forget to do this, then your system will be screwed up if your kernel is upgraded!
Note that at first, I tried using "cp" to copy over the filesystem, but that failed since the version of cp included in busybox is apparently not up to the job. Tar worked fine.
-------------------------------------------------
Step 5. Modify /boot/grub/menu.lst with an entry for the custom initrd.img
Modify /boot/grub/menu.lst with a new entry. Copy the auxiliary OS's entry where root=/dev/hda1. Then modify the initrd to use your new initrd.img. It will look something like this:
title RAMdisk Debian GNU/Linux, kernel 2.6.18-6-486
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-6-486 root=/dev/hda1 ro
initrd /boot/initrd.img-2.6.18-6-486.ramboot
-------------------------------------------------
After following these steps, you'll have a very basic working system. Now you can boot into the "main" OS and install things like X (only install the xserver you need) and other programs like icewm and iceweasel. For example:
apt-get install xserver-xorg-video-vesa xserver-xorg-video-ati xfonts-base alsa-base alsa-utils icewm menu iceweasel xfe aterm
The default icewm theme is rather ugly, so you can copy over a nice theme like /usr/share/icewm/themes/IceCrack2 from another install. Obviously, you don't want to install all of the themes in icewm-themes since they'll be consuming RAM just sitting there.