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

NOTE: I will leave this HowTo here for historic purposes, but the technology has moved on. These days I just use an SSD just like any other drive with the exception of activating TRIM.

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.

http://apcmag.com/how-to-maximise-ssd-p ... -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 2014-07-18 00:01, edited 4 times in total.
User avatar
grege
 
Posts: 193
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.
julian516
 
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
oldboy
 
Posts: 651
Joined: 2007-08-09 12:45

Re: Using an SSD as a boot device in Debian

Postby geebee75 » 2014-05-20 18:43

Great article, but I have a really stupid question.

You say to not install swap on your SSD. I only have SSD's on my system - no spindle drives. During install I was first NOT going to configure a swap partition since I have 8GB RAM (way plenty for this) however it warned me to not do that.

Was there a reason why you don't want swap on an SSD - even if it's rarely (if ever) used?

Thanks!
geebee75
 
Posts: 1
Joined: 2014-05-20 18:38

Re: Using an SSD as a boot device in Debian

Postby TobiSGD » 2014-05-20 19:59

Older SSDs suffered of reduced lifetime due to massive write operations.
On modern SSDs these problems simply don't exist anymore.
You can safely put swap on the SSD.
What would be the use of a fast storage medium if you use slower ones when it comes to operations that seriously slow down the system, like swapping, anyways?
Although with 8GB of RAM you shouldn't have problems with swapping on normal desktop usage.
User avatar
TobiSGD
 
Posts: 826
Joined: 2010-05-08 22:27
Location: Hannover, Germany

Re: Using an SSD as a boot device in Debian

Postby grege » 2014-07-17 23:51

geebee75 wrote:Great article, but I have a really stupid question.

You say to not install swap on your SSD. I only have SSD's on my system - no spindle drives. During install I was first NOT going to configure a swap partition since I have 8GB RAM (way plenty for this) however it warned me to not do that.

Was there a reason why you don't want swap on an SSD - even if it's rarely (if ever) used?

Thanks!


Hi, I have been off line for a while so just saw your question. By now you have no doubt installed your system based on your own decisions.

The answer from TobiSGD is valid. These days I have two modern 256GB SSDs and no longer do anything other than activate trim and symlink a few folders onto the second drive. Without swap you cannot suspend/resume. For a home computer desktop with 8GB of RAM you will never use swap as swap. When I only had 128GB of SSD I was not going to waste more than 10% of it for a swapfile, but times change and technology moves forward. On my newer desktop I do not suspend my system and I do not have a swap partition, but for a notebook a swap file is essential.
User avatar
grege
 
Posts: 193
Joined: 2009-08-13 11:10
Location: Melbourne, Australia

Re: Using an SSD as a boot device in Debian

Postby oldboy » 2014-07-18 00:08

I dual boot with jessie on ssd and wheezy on HDD. The swap file is located in HDD. Is the set up ok to use?
This oldboy has a lot of time in his hands
Linux slows down my Alzheimer and dementia
oldboy
 
Posts: 651
Joined: 2007-08-09 12:45

Re: Using an SSD as a boot device in Debian

Postby grege » 2014-07-28 00:31

oldboy wrote:I dual boot with jessie on ssd and wheezy on HDD. The swap file is located in HDD. Is the set up ok to use?


Interesting setup. I am sure it works, but you would want to be careful if you ever suspend/resume as both installs are probably using the same swap file. If you are using jessie as your main system with Wheezy as a backup and do not use suspend then it should work well enough. My boot times with an i3 and 8 G of ram on a 256 SSD are now below 3 seconds running jessie/sid and systemd.

greg@greg-desktop-1:~$ systemd-analyze
Startup finished in 1.224s (kernel) + 1.375s (userspace) = 2.599s
User avatar
grege
 
Posts: 193
Joined: 2009-08-13 11:10
Location: Melbourne, Australia

Re: Using an SSD as a boot device in Debian

Postby oldboy » 2014-07-28 03:16

3 seconds, cold boot? How is it done? Just my system check takes 10s and the whole thing took 25s.
This oldboy has a lot of time in his hands
Linux slows down my Alzheimer and dementia
oldboy
 
Posts: 651
Joined: 2007-08-09 12:45


Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable