Using an SSD as a boot device in Debian

Share your own howto's etc. Not for support questions!

Using an SSD as a boot device in Debian

Postby grege » 2012-03-07 07:04

Using an SSD as a boot drive in Debian - A Mini HowTo

This is how I set mine up, with the reasoning. This is also aimed at a home system with one user.

SSDs are now becomming cheap enough. $60 will get you a 32gb SSD. I used a 120gb OCZ Agility SSD, with a SATA3 connection. A full Wheezy install with all the usual bits like LibreOffice only needs about 7-8gb - so Debian lends itself to this kind of speed improvement. And for not too many dollars.

Install the SSD and a HDD on SATA1 and SATA2 respectively and then run the Debian installer. I used a snapshopt of Debian Wheezy. When you get to disk partitioning select Custom. We need a root partiton and a /home partition, swap and then a partition to utilise the HDD. We do not want swap on the SSD. You could just mount the HDD as home, but that would waste a big chunk of your shiny new SSD. With a 32gb SSD I would probably use it all for root and have swap and /home on the HDD, but for anything bigger we need to be a bit more creative.

I have a 20gb root and 93gb /home on the SSD, an 8gb swap file on my HDD and the remainder of my HDD is one 740gb partition that is mounted within my home folder as /home/greg/media. The Debian installer used by Squeeze is quite happy to create this layout for you. We also need to enable TRIM support so our new SSD maintains it's performance. I studied many HowTos and blog posts and came across this gem which sumerizes the technical details. Once the system is running create a “media” folder in your home folder and set it's permissions to read/write for your user name. This is needed to give fstab the place to mount the HDD. ... -linux.htm

Be very very careful when hand editing your /etc/fstab as you could end up with a non-booting system. I also changed my kernel scheduling to “deadline” and moved my tmp files into a RAM disk. For easy reference this is the content of my fstab, automatically loading my HDD into a folder within my /home folder. Note the alterations to the lines loading anything to do with the SSD as this is what activates TRIM. TRIM keeps your SSD running at peak performance and is very important.

# /etc/fstab: static file system information.
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# / was on /dev/sda1 during installation
UUID=4aec8584-9725-45bb-a088-82dc63170be8 / ext4 noatime,nodiratime,discard,errors=remount-ro 0 1
# /home was on /dev/sda2 during installation
UUID=fa25b616-d581-4e77-834f-1cc74df7d1f2 /home ext4 noatime,nodiratime,discard,errors=remount-ro 0 2
# /home/greg/media was on /dev/sdb2 during installation
UUID=f1778766-b8b7-4962-bf7d-2bc41f49425a /home/greg/media ext4 defaults 0 2
# swap was on /dev/sdb1 during installation
UUID=8bf799de-5eb5-4fc9-af12-e074880f6325 none swap sw 0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto 0 0

tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0

tmpfs /var/spool tmpfs defaults,noatime,mode=1777 0 0

tmpfs /var/tmp tmpfs defaults,noatime,mode=1777 0 0

tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0

This layout also moves my log files to RAM disk, so they evaporate at each boot. Just remove the last line if you would prefer to keep you log files on disk.

NOTE: Moving tmp files to RAM uses quite a bit of your RAM. My system now idles at about 1.3gb RAM usage. I have 8gb so it is no issue, but if you have 2gb or less this will need to be accounted for in your thinking. Secondly, moving log files can have unforeseen consequences. In my case it killed TOR which could not cope with the move. This change might need some work with environment variables, so for the moment I am leaving it out.

Do a restart and confirm that everything is running as it should and your version of /home/greg/media is functioning. To ensure trim is functioning run this command as su

hdparm -I /dev/sda | awk '/.*TRIM supported.*/{ if ($1 == "*") print "Yes, TRIM is enabled"; else print "No, TRIM is not enabled.";}'

And you should get “Yes, TRIM is enabled”. Adjust sda to sdb or whatever matches your system setup.

We are almost there. Next we need to effectively utilze the HDD. Many files do not benefit from fast access, eg music files. Delete /home/greg/Music and create a folder in /home/greg/media called Music. Then using Nautilus or Midnight Commander create a symlink back to /home/greg/Music. This way all of your mp3s and oggs are physically on the HDD but programs that look in /home/greg/Music can still find and use them. Repeat for other folders you want on the HDD like Documents.

Lastly we have to consider the myriad of hidden folders that populate our /home folders. We actually want our .conf files on the SSD so that we get the fastest program loading possible. But we do want to move our .cache folder. This folder can get thousands of writes hammering our SSD all day long. Go through the same process, copy the .cache folder from home to the HDD in your version of /home/greg/media and then remove the one in your home folder and symlink the new one back to home. Running .cache from the HDD is a good idea.

Any comments or improvements are appreciated. There are many ways you could approach this, this was my way and it seems to work well. I am also not going to give explicit instruction on Symlinks, if you do not know how they function then I suggest some homework is in order before starting.

EDIT 8 Mar 2012: Added note about RAM usage and TOR problems. I forgot to mention that this set up really does speed up a system. LibreOffice Writer loads faster than you can move the mouse back to the center of the screen after you click on the menu item.
EDIT 12 Apr 2012: I use Samba shares, folders on the HDD. Samba loads before the HDD is mounted. To work around this I restart Samba through /etc/rc.local by adding the line /etc/init.d/samba restart - the Samba shares are then correctly loaded.
Last edited by grege on 2012-04-12 12:29, edited 2 times in total.
User avatar
Posts: 191
Joined: 2009-08-13 11:10
Location: Melbourne, Australia

Re: Using an SSD as a boot device in Debian

Postby julian516 » 2012-03-08 12:35

Terrific post and thank you! I have just had to modernize the family Windows machine and so I used an SSD/HD combination such as you describe. The SSD is impressive to say the least and it has caused me to begin thinking seriously about going that route with my preferred Linux machines, both of which run Debian.
Posts: 294
Joined: 2010-03-18 20:10
Location: Loveland, CO

Re: Using an SSD as a boot device in Debian

Postby oldboy » 2012-12-10 18:09

Thanks for the write up. Since I have an older single core with only 1 GB ram, I did not do all of the /tmp stuff you recommended. Anyway, works like a charm.
This oldboy has a lot of time in his hands
Linux slows down my Alzheimer and dementia
Posts: 644
Joined: 2007-08-09 12:45

Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 7 guests