FreeBSD和Ubuntu系统下启动MLS SSD支持TRIM

目前手边的机器每一台都至少装了一颗 MLC SSD. 不论是当系统碟或当暂存区使用, 都有需要启动 TRIM. 刚好 FreeBSD 8.2 及 Ubuntu 11.10 的 kernel 都有支援 TRIM. 所以就参考文件设定.

[[[ FreeBSD 8.2 ]]]
1. Reboot and login in Single User Mode
2. tunefs -p /dev/adXXsXX
3. tunefs -t enable /dev/adXXsXX
4. Reboot the machine
5. Check the setting

HHHHH(XXXXXX)/root# tunefs -p /dev/adXsXX

tunefs: POSIX.1e ACLs: (-a)                                disabled

tunefs: NFSv4 ACLs: (-N)                                   disabled

tunefs: MAC multilabel: (-l)                               disabled

tunefs: soft updates: (-n)                                 disabled

tunefs: gjournal: (-J)                                     disabled

tunefs: trim: (-t)                                         enabled

tunefs: maximum blocks per file in a cylinder group: (-e)  2048

tunefs: average file size: (-f)                            16384

tunefs: average number of files in a directory: (-s)       64

tunefs: minimum percentage of free space: (-m)             8%

tunefs: optimization preference: (-o)                      time

tunefs: volume label: (-L)

[[[ Ubuntu 11.10 ]]]
1. Edit /etc/fstab and add “discard,noatime,nodiratime,”.

root@HOSTNAME:~# diff /etc/fstab.bak /etc/fstab

10c10

< UUID=dXXXdXXX-5899-XXXX-XXXd-XXXXcXXX8XXX /               ext4    errors=remount-ro 0       1

> UUID=dXXXdXXX-5899-XXXX-XXXd-XXXXcXXX8XXX /               ext4    discard,noatime,nodiratime,errors=remount-ro 0       1

2. Edit /etc/rc.local and add following statements before ‘exit 0’.

### For tweak SSD

echo noop > /sys/block/sda/queue/scheduler

echo 1 > /sys/block/sda/queue/iosched/fifo_batch

3. Reboot the machine

4. 参考这篇做测试. https://sites.google.com/site/lightrush/random-1/checkiftrimonext4isenabledandworking