[edit: I've created a new and improved how-to. The original version is included below the new version, but there's no reason to prefer the old one.]
-----------------------------
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:

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:

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.

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 scriptB) "main" OS, where you install new software or change settingsC) "ramboot" OS, for high speed silent computing

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.bakvi local.rambootcp -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:

################################ 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:

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:

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

Last edited by IsaacKuo on Mon Aug 11, 2008 6:01 pm, edited 1 time in total.

On my main workstation, I've gone from diskless netbooting to this RAMboot method. It boots off a hard drive, loads the entire OS into RAM, and spins down the hard drive.

Now I can finally enjoy true silent computing!

Previously, I had used either an enclosed 2.5" drive or I use diskless booting over the network. Unfortunately, my motherboards have this "chirping" noise during any sort of disk or network access. Thus, even though the enclosed 2.5" drive or network may theoretically be silent, in practice the motherboard still make noises during I/O access.

But RAM access is dead silent.

Also, the speed is just incredible. Programs start up instantly. The web browser never pauses loading/unloading cache files. It's just plain FAST.

One thing... be sure to be using a processor that supports PAE(most new ones). under most flavors of *IX, you can get 42 bit memory addressing, and can utilize up to 64GB of ram.(of course, slots become the limiting factor as 8 and 16 GB modules aren't out at a reasonable price)

The machine I'm currently typing on is a Socket 754 Sempron 3100+ with 384megs of RAM. It's...a tight fit. I'm going to continue to do more trimming and will be using this on my main workstation--which has 1meg of RAM.

Even if I had tons of RAM, I'd still do the trimming because the size of the image affects how long it takes to boot up. The entire image gets loaded into RAM, of course.

Could this technique be adapted for the Linux machine to ram-boot from an image found on a network server?

In my office, I have my personal workstation, plus several servers that support my business. I was thinking about running the DNS machine from a flash disk, but your ram-boot process might also do what I need.

Some of my machines must have disks running all the time. These could be the source for ram-boot machines.

With Debian 4.0, I notice that the first time it attempts to mount the nfs root, it fails. So it will be necessary to a little more complex hacking of the nfs root mounting script to do the ramdisk creation/copy.

The little hack I suggest to the local mountroot script is simple and straightforward because it simply assumes the mount will work the first time (the original script has no error checking on this step, and simply assumes the mount works).

My original idea for this is simply installing to a flash drive. I can GHOST this drive, or otherwise copy it for safe keeping. My DNS tables are static, so this would be a frugal and silent way to run this machine.

For your purposes I'd go with your original idea of installing to a flash drive. The main problem with netbooting is that the computer is essentially dependent on another particular computer being functional. I think this is acceptable for a workstation or media player "appliance", but I don't like the idea of a server being dependent on another server.

I like to have a simple "two tier" graph of dependency. The upper tier is the "servers", which don't depend on any other computer. The lower tier is the "clients", which depend on zero or more servers (no client depends on another client). This keeps me sane. If nothing else, it makes powering up easy--first power up the servers, in any order, and then power up the clients, in any order.

Thanks for all the hints here. This works great.
But somehow my harddisk is still wakening up after about 5 seconds sleep mode. Does anybody know how to make this complete silent? Why is linux still trying to access the harddrive? Maybe I should mount /var also as a tmpfs filesystem?

By the way, I've been refining this technique, and have figured out an elegant simplification that only involves one OS install on one partition. I'm not sure when I'll have the time to hammer down all the details and redo my how-to.

The basic idea is to just have one OS install, and for the script steps to be:

1) Delete the old image file
2) Create a ramdisk
3) Copy the OS partition to the ramdisk
4) Strip out excess files and modify fstab and such
5) Create the new image file

Compared to the original method, this greatly reduces the overall complexity and hard drive space usage (which may be very helpful for compact flash or USB thumbdrive install). It also greatly improves the performance of the script--copying files between a hard drive and a ramdrive rather than from a hard drive to itself.

The only downside is that it requires more RAM at minimum. There needs to be sufficient RAM for the OS partition even before stripping out unnecessary files. But if you're hurting for RAM, it's probably not a good idea to use this method in the first place.

I've created a new and improved version of this how-to. The new method is far more elegant and has much better performance.

The original version was too complex, using two installs and requiring three reboots whenever making changes to the OS. The new version has only one install and only requires two reboots whenever making changes (one to reboot into the hard drive install, and then one to reboot back into the RAMboot entry).

Performance is better than before when running the snapstrip script. In the old version, the temporary snapshot was put on the hard drive. This meant the old snapshot had to be deleted, which takes a while, before creating a new snapshot. The new version puts the snapshot into a ramdisk. Not only is it no longer necessary to delete the old snapshot, but speed is doubled compared to copying to/from the hard drive.

You're welcome! The speed is really addicting...I can't go back to waiting around for a program to open.

I'm already thinking of another improvement on the scheme. Currently, excess stuff is simply deleted from the image, but there's still a LOT of not entirely essential stuff left in the image.

I'm thinking that instead of outright deleting the excess stuff, it could instead be offloaded to a network share. The excess "junk" files would be moved to the nfs share and softlinked in the root partition.

When booted up in normal hard drive mode, this network share is mounted read/write. When booted up in RAMboot mode, this network share is mounted read-only, joined by UnionFS to a ramdisk.

Compared to the current method of deleting the excess stuff:

1) This leaves apt-get and man fully functional.

2) The excess files no longer take up space in the root partition, so it takes less time to copy over the root partition in the snapstrip script. This also reduces the amount of RAM required by the snapstrip script.

3) It's possible to offload many files which are used infrequently or for which slower loading time is acceptable.

The disadvantages are that you need a file server, and setting everything up is slightly more complicated.

I'm still contemplating the different possible approaches. Using nfs is pretty straightforward for me since I already have an nfs file server, but nbd may offer some compelling advantages.

Network Block Device, unlike nfs, is a block device (like an NAS). As such, file caching works like a local drive. That means that as long as there's plenty of RAM, files only need to be read once and after that read-only access is as fast as from a ramdrive.

The advantage of this approach is, that you don't have to boot from harddrive at all. If you want your changes to be permanent just rsync the root dir to the harddrive, and volia, everything is updated.

In the scripts/local rsync can also be used with the --exclude option, to get rid of unnecessary files and dirs to make the boot faster. It should also be possible to rsync from a remote host (haven't tested it yet).

If someone knows, how i limit the size of the ramdisk (by default it uses half of the available memory) please let me know.

Strangely enough, in my case it would NOT be silent. For whatever reasons, all of my later motherboards make audible electronic chirps whenever accessing most I/O hardware (like ethernet, or USB thumbdrive, or hard drive). Even with a completely silent hard drive, the motherboard hardware makes chirping noises during access.

I want to use something like this, because I have 10 GB of RAM, and no hard disk. I want to boot from USB flash, and then remove the USB stick after booting.

I like your HOWTO, however why do we need to boot to a different boot entry to be able to change the image? I would like to make changes while running the RAMbooted image, and then save the image to a new permanent image on flash (in case power goes down or something) but without any need to reboot. Will that work?

And I don't need, nor want to delete anything from my installed standard Debian system, as I have 10 GB of RAM, more than the flash stick on which I installed Debian (2 GB).

Puppy Linux does just what you describe "out of the box", so if you are not particularily attached to Debian, it might be worth a try.
You might have to modify some scripts to make it save to flash only on shutdown instead of every 10 minutes or so (you wany to remove the USB, right?), but that should not be too difficult.

This is pretty interesting, however I wonder if there are any more wholistic solutions.

For example, Linux has preloading and whatnot, but wouldn't it be nice to be able to specify say a diskcache priority, and have certain apps and libraries loaded at boot based on priority, and release the cache based on that priority. For example, you could specify specify KDE and the KDE apps you want plus say firefox to always remain in cache. If you have a lot of RAM, the speed would be the same as having a ramdisk.

Who is online

Users browsing this forum: No registered users and 3 guests

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum