Ubuntu 10.10 on SSD optimizations

These are the tweaks I applied to my Ubuntu 10.10 installation on SSD (OCZ Vertex2)

1. Auto-trim
2. tmpfs for ‘/tmp’
3. ‘noatime’ mount option

Auto-trim:

Automatic TRIM is supported since kernel 2.6.33 with the EXT4 file system

For automatic TRIM to work, the drive needs to be mounted with the “discard” option in fstab. To add this option run:

sudo cp /etc/fstab ~/fstab-backup
sudo gedit /etc/fstab

add “discard” to options on the entry for the SSD; the line should read similar to this:

UUID=ed586ab8-08c5-4bae-b118-d191b716b4a4 /               ext4    discard,errors=remount-ro 0       1

reboot, automatic TRIM should now be working.

Testing automatic TRIM:

To Test if Trim is working issue the following commands (adapted from here):

cd  / #or whatever part of the file system is on the SSD
sudo dd if=/dev/urandom of=tempfile count=100 bs=512k oflag=direct # you will not need sudo for these to work, if your SSD is in /home for example
sudo hdparm --fibmap tempfile

from the output copy the number under “begin_LBA” and use it in the next command

sudo hdparm --read-sector 2638848 /dev/sda #replace 2638848 with the number obtained before and /sda with your SSD drive

you should receive a a long string of characters for those sectors

sudo rm tempfile
sync
sudo hdparm --read-sector 2638848 /dev/sdd

even after removing the file the sectors are still not empty. Wait a while then run the command again

sudo hdparm --read-sector 2638848 /dev/sdd

if you get only zeros, then automatic TRIM is working.

Create tmpfs for ‘/tmp’

Added this line to ‘/etc/fstab’ (and reboot!). This will make ‘/tmp’ a ramdisk location (i.e. no actual writes to disk)

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

After that, make your applications use this location, if possible. For instance Firefox temp directory:
1. Type ‘about:config’ in the address bar of Firefox.
2. Create a new string entry: ‘browser.cache.disk.parent_directory’ with value: ‘/tmp’
Now Firefox uses ‘/tmp’ for cache, which reduces disk writes.

‘noatime’ for SSD mount location

My ‘/etc/fstab’ is adjusted with ‘noatime’ in the options for the ssd partitions. This disables writing (for me useless) information about access times to the SSD.

UUID=bb1d5dc2-f20a-4360-b0f8-ba05948d8a7e /               ext4    errors=remount-ro,noatime,discard 0       1

Leave a Reply

Your email address will not be published.