-
New and improved RAMboot method
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:
apt-get update
apt-get install hdparm localepurge debconf-english
apt-get remove --purge aptitude tasksel tasksel-data laptop-detect
apt-get clean
Note that installing debconf-english will remove debconf-i18n. This is normal.
-------------------------------------------------
Step 2. Create a modified /etc/fstab
Create and edit a new fstab using these commands:
Code:
cd /etc/
cp fstab fstab.ramboot
nano fstab.ramboot
Comment out the / entry. Create a new / line like this:
Code:
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:
nano /etc/init.d/ijkijkijk
chmod 755 /etc/init.d/ijkijkijk
update-rc.d ijkijkijk defaults 20
The contents of ijkijkijk should be something like this:
Code:
#! /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:
#!/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 *
Run the script to create the tar archive. You'll run this script after making changes to the main OS to create a new snapshot file.
-------------------------------------------------
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:
cd /usr/share/initramfs-tools/scripts/
cp -vax local local.bak
nano local
cp -vax local local.ramboot
In nano, you'll want to modify the portion where the actual "mount" command is done. Comment it out and insert something like this:
Code:
[...]
########### 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
[...]
After making these modifications, create the initrd.img with this command:
Code:
mkinitramfs -o /boot/initrd.img.ramboot
After creating this ramdisk make sure to copy back the backup file with:
Code:
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!
-------------------------------------------------
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:
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.
Isaac Kuo, ICQ 29055726 or Yahoo mechdan
-
H-m-m..good read and right on....I'll stick with puppylinux for this though...I'm lazy.
-
This is an interesting tutorial.
I have long been intrigued by distros like DSL, Puppy and Slax by their lightening speed in operation. Gradually I realize they do this by putting the entire Linux image in the ram which helped considerably the pioneering the concept of Live CD.
The concept is not new but thanks to IsaacKuo for making a nice detailed write-up on how to do it.
Like JohnT said Puppy is one of this type of Ramboot Linux. When it operates one can see all the full filing tree, just like any Linux with /, /boot, /bin etc, except everything is held in ram and not on the hard disk. However on exit Puppy rolls everything into a file and leaves nothing behind. I have described this like a "hot dog stall" operation. In the day time we see a hot dog stall. In the evening there is nothing to be seen.
Puppy, like many distros, has managed to get the Linux boot up from inside a Fat partition (using a Dos-based syslinux boot loader). I think Puppy calls this type of working as "Frugal install" as oppose to the full installation.
I think the current "Howto" provides the option to put the hard disk in the "sleep" mode too.
If I haven't misread it the Linux has to be booted from a hard disk to start with. Once the OS is loaded into memory the hard disk is dispensed with.
-
Puppy's approach of using a compressed file system is great if you're strapped for RAM. One reason I chose to use an uncompressed file system was because Puppy already had the compressed approach covered.
My approach is for those who have the RAM to spare. At least 256megs for a console system; at least 512megs for X. If you've got the RAM, and you want that extra bit of speed, then uncompressed is for you!
Isaac Kuo, ICQ 29055726 or Yahoo mechdan
-
Originally Posted by saikee
If I haven't misread it the Linux has to be booted from a hard disk to start with. Once the OS is loaded into memory the hard disk is dispensed with.
That is correct. This tutorial will also work equally well with a USB thumbdrive install, for a cheap solid state solution. However, if you're like me you already have some old hard drive lying around so the hard drive solution costs 0$. I'd rather spend my money on more RAM than a thumbdrive.
The way I do things, the rest of the hard drive is actually used. I like having a big data partition mounted to /mnt/hda5, along with the "noatime" option. Leaving this partition mounted still lets the hard drive spin down. I use these big data partitions for periodic backups of my file server data.
Isaac Kuo, ICQ 29055726 or Yahoo mechdan
-
Not bad at all, I'm posting this from a system I just finished, it took about 2 hours. That was starting with a blank HD, I made one small mistake editing the local script, I wasn't sure if the [...] was supposed to be in there or not. after it failed I just edited the local.ramboot script, removed them, created a new image. This is on a pIII 800mhz with 512mb ram, I have to say so far I'm impressed.
Note: There are a couple spots in the howto that the reader will have to jump forword then come back to. But it is still a well written howto two thumbs up Isaac.
-
Incidentally, Knoppix can do this too with the "toram" kernel option. If you can spare the RAM and boot time, it avoids the annoying pauses while it loads from the CD/DVD.
-
The other day I was using Knoppix's toram option. It's actually very sluggish, because it uses a compressed filesystem. I was quite shocked at how long it took to open up Firefox/Iceweasel. Okay, it may have been faster than a traditional hard drive install, but still...very sluggish compared to having the OS on an uncompressed ramdrive.
Isaac Kuo, ICQ 29055726 or Yahoo mechdan
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|