Hello to everyone in this article I’m going to show you how to load all your linux system os to the ram
in order to get an outperforming pc with incredible speed.
Warning :
I recommend you make a back up of your system before following this guide.
I do not assume any responsibility for the loss of your data.
Requirement :
–At least 8 Gb of ram
–An operative system debian based, I tried on debian 7.02 and debian 6.06
probably it will work also on Ubuntu and others distro derived from debian.
–Medium knowledge of the linux terminal
Advantages:
At the end of this guide, you will have the faster system you have ever seen!!
Faster than any system installed on ssd!
In addition, we will create 2 grub entries that will allow you to choose
to run the system on the hard disk or on the ram.
When you choose to start on ram all changes made to the system in this mode will be
forgotten once restarted.
This means that you can install programs, test terminal commands
and other such things without fear of corrupting your system!
Disadvantages:
The startup may take up to 10 minutes depending on which hard drive you have and how much space occupies your Linux system.
During startup you will see a black screen with a blinking white cursor.
When you reboot you lose all data and changes that you have saved on the hard disk
you can avoid this problem in various ways which I will explain later.
Why on earth did I think to run the entire system on ram?
Because after I bought and assembled the pieces of my pc it was not
as fast as I wanted.
My pc was as follows:
Amd Phenom 2 X6 Black Edition
Motherboard ASRock 890GX Extreme3
16 GB G.SKILL DDR3 1600
I recently added an Ati 7970xfx Ghost Edition
After installing Mint Debian Edition I had an average fast system but I didn’t build
my pc to have a “just” average fast system.
So I decided to investigate and discover what did slow down my pc.
I found out that the problem are my hard disks.
I found an interesting post where they teach me how to remedy.
http://reboot.pro/topic/14547-linux-load-your-root-partition-to-ram-and-boot-it/
I decided to try the post’s guide.
The first time I thought the pc was not going to boot so I restarted it.
After that I understood that the pc needs more time to copy all the data from the hard disk to the ram.
I waited with the black screen and after about 12 minutes the pc showed me the login screen.
I tried the system and I was impressed by the responsiveness of the pc!
It was instantaneous!
You click to run a program and after you released the finger on the mouse the program is already there! Wonderful!
So I decided to write this guide.
Why loading on your ram all your system the pc become so faster?
Because the slower part fo the pc is the only mechanical part! the pc hard disk!!!
Every time you run a program it is read from the hard disk.
Also, the faster hard disk is a bottleneck for the nowadays PCs (warning this article is old, so now there are some pretty fast SSD )
Removing all the hard disk reading and writing process you remove a long waiting time!
The Ram is a lot faster than any hard disks.
DDR3 ram is rated from 6400 MB/s to 12800 MB/s varying from the model.
A solid-state disk is rated from 250MB/s to 600 MB/s varying from the model.
A rotary hard disk is rated from 50 to 150MB/s varying from the model.
Now you can see that the speed of the slower DDR3 ram is about 42 times faster
than the fastest rotary hard disk!
Your pc will not run 42 times faster but you will notice a great difference
and it is worth the work to gain that.
Let’s start with the guide:
I started with a version of Debian 7.2 installed from net cd so I installed
the bare minimum programs and Mate graphical interface.
Open a terminal
Write the following in order to make a back up of the fstab file:
sudo cp /etc/fstab /etc/fstab.bak
Now open with your favorite text editor as an administrator the file:
sudo pluma /etc/fstab or sudo gedit /etc/fstab or sudo nano /etc/fstab
Look for the line where there is the root partition /
Mine was written like this:
UUID=b4a375f0-3cae-41ec-a130-fd9fa5207b07 / ext4 noatime,errors=remount-ro 0 0
Make sure that on your old line of the root fsck is disabled so there should be 2 zeros as the end of the line, like in my example.
If there are not 2 zeros replace the numbers with two zeros
after that restart your PC.
Reopen the file and proceed as before.
At this point, replace the line of the root with:
none / tmpfs defaults,noatime,nodiratime,discard 0 0
Save and close the file.
Move yourself typing in the terminal:
cd /usr/share/initramfs-tools/scripts/
Make a copy of the file local with:
sudo cp local local.bak
Open with your favorite text editor as an administrator the file:
sudo pluma local or sudo gedit local or sudo nano local
Search a part like this:
# FIXME This has no error checking
# Mount root
if [ "${FSTYPE}" != "unknown" ]; then
mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
else
mount ${roflag} ${ROOTFLAGS} ${ROOT} ${rootmnt}
fi[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom"
run_scripts /scripts/local-bottom
[ "$quiet" != "y" ] && log_end_msg}
In particular, you should find the line # Mount root that tells you that you are in the right place.
Replace the lines with following ones :
# FIXME This has no error checking
# Mount root
mkdir /ramboottmp
mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} /ramboottmp
mount -t tmpfs -o size=100% none ${rootmnt}
cd ${rootmnt}
cp -rfa /ramboottmp/* ${rootmnt}
umount /ramboottmp
[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom"
run_scripts /scripts/local-bottom
[ "$quiet" != "y" ] && log_end_msg
}
Depending on the version of Linux you have ,you could have to change the lines
but should not differ by much.
Save and close the text editor.
Now run from terminal:
sudo mkinitramfs -o /boot/initrd.img-ramboot
May print 2 warning but is usual.
Restore now the old local with:
sudo cp -f local.bak local
Open the file /boot/grub/grub.cfg with your favorite text editor as an administrator :
sudo pluma /boot/grub/grub.cfg oppure sudo gedit /boot/grub/grub.cfg
Find the first part that look like this:
menuentry 'Debian GNU/Linux, con Linux 3.2.0-4-amd64' --class debian --class gnu-linux --class gnu --class os {
load_video
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd2,msdos1)'
search --no-floppy --fs-uuid --set=root b4a375f0-3cae-41ec-a130-fd9fa5207b07
echo 'Caricamento Linux 3.2.0-4-amd64...'
linux /boot/vmlinuz-3.2.0-4-amd64 root=UUID=b4a375f0-3cae-41ec-a130-fd9fa5207b07 ro quiet
echo 'Caricamento ramdisk iniziale...'
initrd /boot/initrd.img-3.2.0-4-amd64
}
Copy and paste it just above modifying it as following
In menuentry add a label that let you know that is the entry to run the system on ram :
I added RAM!!! (make sure to not made it too long or maybe will not work)
Now where is written :
initrd /boot/something
replace something with:
initrd.img-ramboot
My menuentry is like this:
menuentry 'Debian GNU/Linux,Linux3.2.0-4-amd64 RAM!!!' --class debian --class gnu-linux --class gnu --class os {
load_video
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd2,msdos1)'
search --no-floppy --fs-uuid --set=root b4a375f0-3cae-41ec-a130-fd9fa5207b07
echo 'Caricamento Linux 3.2.0-4-amd64...'
linux /boot/vmlinuz-3.2.0-4-amd64 root=UUID=b4a375f0-3cae-41ec-a130-fd9fa5207b07 ro quiet
echo 'Caricamento ramdisk iniziale...'
initrd /boot/initrd.img-ramboot
}
We created another grub entry equal to the original but that start with:
initrd /boot/initrd.img-ramboot
instead to start with
initrd /boot/initrd.img-3.2.0-4-amd64
So it load the system on Ram
At this point save and close the file.
Reboot and now you should have a new entry in the grub
Choose it and after 10 -15 minutes your pc will show you your linux system.
Now you have an extremely fast system
Rebooting and choosing the old grub entry you can run the old system .
Changing this system you will change also the on ram system.
I have the home folder almost empty and my system occupies 3.7 Gb then for me
6 Gb of ram would be enough to run the whole system in ram.
Because my system would use 4 Gb of ram to store the os files and the others 2 Gb as usual ram.
With 8 Gb you could probably run almost any os linux system in ram.
I recommend you to store all the files in a different partition.
So store only the programs configurations in your home folder.
In order to have a faster boot (from 15 minutes to 1 minute) i use a ssd .
Doing so the copying time from the ssd to ram is reduced a lot
I discovered recently that the suspend to ram feature works good on my linux pc .
So in 20 seconds my pc is ready after been suspended to ram!
If you have some questions ,suggestion ,corrections or you just like my articles please leave a comment.
Share this article to improve the computers speed and to spread the linux use.
Thanks to Tibor Áser Veres here the guide to run Ubuntu 16.04 LTS on ram:
Here is an Ubuntu version I made:
Step 1:
Make a copy of your initrd.img just in case…
you use a live session to restore it if it won’t boot
sudo cp /boot/initrd.img-x.x.x-xx-generic /boot/initrd.img-x.x.x-xx-generic.old replace the “x” characters with your system specific numbers…
Step 2:
Edit: /etc/default/grub in order to see the prompt form normal/ramboot mode…
Change: GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash” >> GRUB_CMDLINE_LINUX_DEFAULT=””
Edit it with nano: sudo nano /etc/default/grub
Step 3:
Run update-grub after changes to take place… sudo update-grub
Step 4:
Edit: /usr/share/initramfs-tools/scripts/local You may want to use gedit,
so that you can search with ctrl+F in the file
Find this 2 lines in the script(search for: “# Mount root” FIXME line appears at more places, and it may be temporary until it’s fixed…):
# FIXME This has no error checking # Mount root Paste this under “# Mount root” line: ### Custom modification starts ### read -t 10 -p ‘Do you want to boot normally? (enter Y if so…)’ Yy case $Yy in [Yy]* ) clear echo ‘Booting normally’ mount ${roflag} ${FSTYPE:+-t ${FSTYPE} }${ROOTFLAGS} ${ROOT} ${rootmnt} ;; *) clear echo ‘Booting in RAM’ mount -t tmpfs -o rw,noatime,nodiratime,size=100% tmpfs ${rootmnt} mkdir /ramboottmp mount ${roflag} ${FSTYPE:+-t ${FSTYPE} }${ROOTFLAGS} ${ROOT} /ramboottmp cp -rfa /ramboottmp/* ${rootmnt} umount /ramboottmp rm /ramboottmp ;; esac ### End of custom modifications ###
Remove or uncomment these lines: mount ${roflag} ${FSTYPE:+-t ${FSTYPE} }${ROOTFLAGS} ${ROOT} ${rootmnt}
Step 5:
sudo mkinitramfs -o /boot/initrd.img-x.x.x-xx-generic replace the “x” characters with your system specific numbers…
Final step: sudo reboot