To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here

http://justlinux.com/   Tue, 09-Feb-2010 17:28:10 GMT
         internet.com

Go Back   JustLinux Forums > Community Help: Check the Help Files, then come here to ask! > How I Did It!

How I Did It! Got a How-To/Tutorial/Guide you wrote? Post it here.

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 06-06-2008, 09:59 AM
IsaacKuo's Avatar
IsaacKuo IsaacKuo is offline
Registered User
 
Join Date: Oct 2002
Location: Baton Rouge, Louisiana, USA
Posts: 796
How to RAMboot for blazing speed and silence

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) Boot into the "auxiliary" OS, where you run the OS snapshot/stripping script

B) Boot into the "main" OS, where you install new software or change settings

C) Boot into the "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:
#!/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 *
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 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:
[...]
########################################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
[...]
After making these modifications, create the initrd.img with this command:

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.
__________________
Isaac Kuo, ICQ 29055726 or Yahoo mechdan
Reply With Quote
  #2  
Old 06-06-2008, 10:19 AM
saikee's Avatar
saikee saikee is offline
moderator
 
Join Date: Jun 2004
Location: Newcastle upon Tyne
Posts: 2,485
IsaacKuo,

I haven't looked into the details yet but the idea is brilliant, although many Live CDs work by uploading a full Linux image file into the memory too.

We can do with many nice ideas like this in Justlinux.

Well done!
__________________
Linux user started Jun 2004 - No. 361921
Using a Linux live CD to clone XP
To install Linux and keep Windows MBR untouched
Adding extra Linux & Doing it in a lazy way
A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
Just cloning tips Just booting tips A collection of booting tips

Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"
Reply With Quote
  #3  
Old 06-06-2008, 12:06 PM
IsaacKuo's Avatar
IsaacKuo IsaacKuo is offline
Registered User
 
Join Date: Oct 2002
Location: Baton Rouge, Louisiana, USA
Posts: 796
Thanks!

My first idea was to take what a liveCD does and modify it. However, it looked really complicated and I decided to try and come up with something from scratch. Partly, this was so I could learn about initramfs-tools and the boot process.

After studying initramfs-tools and looking through the scripts for a few days, I figured out a method which I thought would be simple. I was almost right. It came close to working just as I planned, except the version of "cp" available in busybox just wasn't up to the task. I had to use tar instead.

One thing that's a bit different from those Live CDs is that a live CD will load up a compressed image file into memory. This method puts uncompressed files into memory, meaning negligible CPU effort in accessing those files. It is FAST FAST FAST, but it sure hogs RAM.

I'd say you need 512megs of RAM to have a comfortable GUI (something light like IceWM, not KDE or GNOME). Obviously, the more applications you want the more RAM you need, since they're all loaded into RAM regardless of what's running.
__________________
Isaac Kuo, ICQ 29055726 or Yahoo mechdan
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 01:28 PM.

Help File Library
Installation
Hardware
Soundcards
Tools
Security
More



internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers




internet.commerce
Be a Commerce Partner












Linux is a trademark of Linus Torvalds.

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.7.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.