Differences between revisions 1 and 12 (spanning 11 versions)
Revision 1 as of 2011-11-23 15:03:49
Size: 3322
Editor: OsamuAoki
Comment:
Revision 12 as of 2012-10-01 14:02:16
Size: 4292
Editor: AriPollak
Comment:
Deletions are marked like this. Additions are marked like this.
Line 10: Line 10:
== SSD Optimization on the powerful laptop PC == /!\ An important aspect in optimizing SSD performance is the file system and partition layout. This wiki page does not cover these issues.
Line 12: Line 12:
For a PC with 256GB SSD with system having encrypted root and swap, system is mounted as: == Optimization of solid state drive ==
Line 14: Line 14:
{{{
$ mount
/dev/mapper/crypto-root on / type ext4 (rw,noatime,discard,commit=600,errors=remount-ro,commit=600)
tmpfs on /lib/init/rw type tmpfs (rw,nosuid,size=5242880,mode=755,size=5242880,mode=755)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=755,size=10%,mode=755)
tmpfs on /tmp type tmpfs (rw,noexec,nosuid,nodev,noatime,mode=1777,size=20%,mode=1777,mode=1777)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
udev on /dev type tmpfs (rw,mode=0755)
tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,size=20%,mode=1777,size=20%,mode=1777)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620,gid=5,mode=620)
/dev/sda1 on /boot type ext4 (rw,noatime,discard,commit=600,commit=600)
tmpfs on /var/log type tmpfs (rw,noexec,nosuid,nodev,noatime,mode=1777)
tmpfs on /home/username/.cache type tmpfs (rw,noexec,nosuid,nodev,noatime,uid=1000,gid=1000,mode=700)
rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
}}}
Performance and disk wear of the solid state drive (SSD) can be optimized as follows.
 * Use the latest Linux kernel. (>3.2)
 * Reduce disk writes for read disk accesses.
   * Set "noatime" or "relatime" mount option in /etc/fstab.
 * Enable the TRIM command.
  * Set "discard" mount option in /etc/fstab for the ext4 filesystem, swap partition, Btrfs, etc. See mount(8).
  * Set "discard" option in /etc/lvm/lvm.conf for LVM. See lvm.conf(5).
  * Set "discard" option in /etc/crypttab for dm-crypt. '''Note that this has drawbacks with respect to security/cryptography!''' See crypttab(5). You'll also need to update your initramfs: `update-initramfs -u -k all`
 * Enable the SSD optimized disk space allocation scheme.
  * Set "ssd" mount option in /etc/fstab for the Btrfs.
 * Make system flush data to the disk every 10 minutes for laptop PCs.
  * Set "commit=600" mount option in /etc/fstab. See mount(8).
  * Set pm-utils to use laptop-mode even under AC operation. See [[http://bugs.debian.org/659260|Debian BTS #659260]].
Line 33: Line 28:
This is done with the foloowings. /!\ Changing flushing interval from normal 5 seconds to 10 minutes makes your data vulnerable to the power failure.
Line 35: Line 30:
/etc/fstab:
/!\ I used to use mount /tmp and similar on tmpfs to avoid disk wear. With laptop-mode as above, i do not do this any more since laptop-mode etc. shall reduce disk writes significantly.

== /etc/fstab ==
Line 44: Line 43:
proc /proc proc defaults 0 0
Line 47: Line 45:
/dev/mapper/crypto-root / ext4 discard,noatime,commit=600,errors=remount-ro 0 1 /dev/mapper/goofy-root / ext4 discard,noatime,commit=600,errors=remount-ro 0 1
Line 49: Line 47:
UUID=709abe4b-81c1-96cb-8ac1-dace3159a1b7 /boot ext4 discard,noatime,commit=600,defaults 0 2 UUID=709cbe4a-80c1-46cb-8bb1-dbce3059d1f7 /boot ext4 discard,noatime,commit=600,defaults 0 2
Line 51: Line 49:
/dev/mapper/crypto-swap_1 none swap sw,discard 0 0 /dev/mapper/goofy-swap none swap sw,discard 0 0
/dev/mapper/goofy-chroot /srv/chroot btrfs ssd,discard,noatime 0 2
Line 53: Line 52:
### SSD OPTIMIZATION: /home/osamu/.cache on tmpfs
tmpfs /tmp tmpfs rw,noexec,nodev,nosuid,noatime,mode=1777 0 0
tmpfs /usr/tmp tmpfs rw,noexec,nodev,nosuid,noatime,mode=1777 0 0
tmpfs /var/log tmpfs rw,noexec,nodev,nosuid,noatime,mode=1777 0 0
tmpfs /home/osamu/.cache tmpfs rw,noexec,nodev,nosuid,noatime,uid=1000,gid=1000,mode=700 0 0
Line 60: Line 54:
/etc/pm/config.d/SET_JOURNAL_COMMIT_TIME_AC == /etc/lvm/lvm.conf ==
Line 62: Line 57:
JOURNAL_COMMIT_TIME_AC=600 ...
# This section allows you to configure which block devices should
# be used by the LVM system.
devices {
...
    # Issue discards to a logical volumes's underlying physical volume(s) when
    # the logical volume is no longer using the physical volumes' space (e.g.
    # lvremove, lvreduce, etc). Discards inform the storage that a region is
    # no longer in use. Storage that supports discards advertise the protocol
    # specific way discards should be issued by the kernel (TRIM, UNMAP, or
    # WRITE SAME with UNMAP bit set). Not all storage will support or benefit
    # from discards but SSDs and thinly provisioned LUNs generally do. If set
    # to 1, discards will only be issued if both the storage and kernel provide
    # support.
    # 1 enables; 0 disables.
    #issue_discards = 0
    issue_discards = 1
}
...
}}}

== dm-crypt: /etc/crypttab ==
'''Note that using discard with on-disk-cryptogrpahy (like dm-crypt) has drawbacks with respect to security/cryptography!'''

{{{
#<target name> <source device> <key file> <options>
var UUID=01234567-89ab-cdef-0123-456789abcdef none luks,discard
Line 70: Line 91:
 *

Translation(s): none


This describe SDD optimization with system having encrypted root and swap.

/!\ An important aspect in optimizing SSD performance is the file system and partition layout. This wiki page does not cover these issues.

Optimization of solid state drive

Performance and disk wear of the solid state drive (SSD) can be optimized as follows.

  • Use the latest Linux kernel. (>3.2)

  • Reduce disk writes for read disk accesses.
    • Set "noatime" or "relatime" mount option in /etc/fstab.
  • Enable the TRIM command.
    • Set "discard" mount option in /etc/fstab for the ext4 filesystem, swap partition, Btrfs, etc. See mount(8).
    • Set "discard" option in /etc/lvm/lvm.conf for LVM. See lvm.conf(5).
    • Set "discard" option in /etc/crypttab for dm-crypt. Note that this has drawbacks with respect to security/cryptography! See crypttab(5). You'll also need to update your initramfs: update-initramfs -u -k all

  • Enable the SSD optimized disk space allocation scheme.
    • Set "ssd" mount option in /etc/fstab for the Btrfs.
  • Make system flush data to the disk every 10 minutes for laptop PCs.
    • Set "commit=600" mount option in /etc/fstab. See mount(8).
    • Set pm-utils to use laptop-mode even under AC operation. See Debian BTS #659260.

/!\ Changing flushing interval from normal 5 seconds to 10 minutes makes your data vulnerable to the power failure.

/!\ I used to use mount /tmp and similar on tmpfs to avoid disk wear. With laptop-mode as above, i do not do this any more since laptop-mode etc. shall reduce disk writes significantly.

/etc/fstab

# /etc/fstab: static file system information.
#
# Use 'vol_id --uuid' 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>
### SSD: discard,noatime
### match battery operation default for commit JOURNAL_COMMIT_TIME_AC in Add files in /etc/pm/config.d/*
/dev/mapper/goofy-root /               ext4    discard,noatime,commit=600,errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
UUID=709cbe4a-80c1-46cb-8bb1-dbce3059d1f7 /boot           ext4    discard,noatime,commit=600,defaults        0       2
### SSD: discard
/dev/mapper/goofy-swap none            swap    sw,discard              0       0
/dev/mapper/goofy-chroot /srv/chroot         btrfs    ssd,discard,noatime 0       2
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto     0       0

/etc/lvm/lvm.conf

...
# This section allows you to configure which block devices should
# be used by the LVM system.
devices {
...
    # Issue discards to a logical volumes's underlying physical volume(s) when
    # the logical volume is no longer using the physical volumes' space (e.g.
    # lvremove, lvreduce, etc).  Discards inform the storage that a region is
    # no longer in use.  Storage that supports discards advertise the protocol
    # specific way discards should be issued by the kernel (TRIM, UNMAP, or
    # WRITE SAME with UNMAP bit set).  Not all storage will support or benefit
    # from discards but SSDs and thinly provisioned LUNs generally do.  If set
    # to 1, discards will only be issued if both the storage and kernel provide
    # support.
    # 1 enables; 0 disables.
    #issue_discards = 0
    issue_discards = 1
}
...

dm-crypt: /etc/crypttab

Note that using discard with on-disk-cryptogrpahy (like dm-crypt) has drawbacks with respect to security/cryptography!

#<target name>    <source device>            <key file>  <options>
var  UUID=01234567-89ab-cdef-0123-456789abcdef  none  luks,discard

Smaller system with SSD

See