Introduce boot parameter root_trim=(yes|no) for SSDs
authorChristian Kruse <cjk@wwwtech.de>
Thu, 5 Jan 2012 16:45:38 +0000 (17:45 +0100)
committerSebastian Pipping <sebastian@pipping.org>
Thu, 5 Jan 2012 16:49:47 +0000 (17:49 +0100)
defaults/initrd.scripts
defaults/linuxrc
doc/genkernel.8.txt

index 89c6d8bf6bc6e00a890161b539179d241e60a7f0..b7b42abbe4bfef3cd43396708fa19efc08496884 100755 (executable)
@@ -732,7 +732,7 @@ openLUKS() {
                        ;;
        esac
 
-       eval local LUKS_DEVICE='"${CRYPT_'${TYPE}'}"' LUKS_NAME="$1" LUKS_KEY='"${CRYPT_'${TYPE}'_KEY}"' LUKS_KEYDEV='"${CRYPT_'${TYPE}'_KEYDEV}"'
+       eval local LUKS_DEVICE='"${CRYPT_'${TYPE}'}"' LUKS_NAME="$1" LUKS_KEY='"${CRYPT_'${TYPE}'_KEY}"' LUKS_KEYDEV='"${CRYPT_'${TYPE}'_KEYDEV}"' LUKS_TRIM='"${CRYPT_'${TYPE}'_TRIM}"'
        local DEV_ERROR=0 KEY_ERROR=0 KEYDEV_ERROR=0
        local mntkey="/mnt/key/" cryptsetup_options=''
 
@@ -793,6 +793,12 @@ openLUKS() {
                                continue
                        else
                                # Handle keys
+                               if [ "x${LUKS_TRIM}" = "xyes" ]
+                               then
+                                       good_msg "Enabling TRIM support for ${LUKS_NAME}." ${CRYPT_SILENT}
+                                       cryptsetup_options="${cryptsetup_options} --allow-discards"
+                               fi
+
                                if [ -n "${LUKS_KEY}" ] 
                                then
                                        if [ ! -e "${mntkey}${LUKS_KEY}" ] 
index 63366bdfbf77f0dfad9fd85f5c109ad1b4e0300b..28d204e38691fe078709410c94ce336b6ba99dad 100755 (executable)
@@ -189,6 +189,10 @@ do
                root_keydev=*)
                        CRYPT_ROOT_KEYDEV=${x#*=}
                ;;
+               root_trim=*)
+                       CRYPT_ROOT_TRIM=${x#*=}
+               ;;
+
                swap_key=*)
                        CRYPT_SWAP_KEY=${x#*=}
                ;;
index 35c7ff3f575b0af92210320a1394e450214ceac3..d436330e64c2120fc8bac46e54c7d53bf0459815 100644 (file)
@@ -387,6 +387,11 @@ which the ramdisk scripts would recognize.
     root_key.   If unset while using root_key, it will automatically
     look for the device in every boot.
 
+*root_trim*=yes|no::
+    Allows you to enable TRIM support on root device. Only useful
+    for SSD setups. Have a look at http://en.wikipedia.org/wiki/TRIM
+    for more information.
+
 *swap_key*=<...>::
     Same as root_key for swap.