终于将UbuntuKylin 13.04安装到了SSD上,过程很艰苦啊! 建议通过USB Live的方式进行安装,速度很快,实测128G SSD + 8G 内存,在联网下载的情况下,大约8分钟安装完毕。 第一步:关闭ext4的日志功能 注意:系统挂载时无法停用日志功能,所以需要使用安装用的U盘系统,利用root权限执行: # sudo tune2fs -O ^has_journal /dev/sda1 执行操作检测: # sudo e2fsck -f /dev/sda1 特别提示:如果SSD的硬盘被分了不止一个区,需要将每一个区的日志功能都设置好。 重启,进入SSD中的系统,检查是否设置成功: # dmesg | grep EXT4 如果出现类似如下的结果表明设置成功: [ 7.003337] EXT4-fs (sda3): mounted filesystem without journal. Opts: (null) [ 7.983753] EXT4-fs (sda3): re-mounted. Opts: discard,errors=remount-ro [ 8.025093] EXT4-fs (sda1): mounted filesystem without journal. Opts: discard [ 8.033006] EXT4-fs (sda4): mounted filesystem without journal. Opts: discard [ 8.199882] EXT4-fs (sdb1): mounted filesystem with ordered data mode. Opts: (null) 第二步:启用TRIM,并设置读写选项 TRIM是一种操作系统调度SSD块写入的方式。主要是因为同一个SSD的闪存单元频繁操作会磨损,影响使用寿命,区别于传统的机械硬盘处理删除数据。Linux内核自2.6.33开始支持TRIM。 首先,检查内核版本及SSD硬盘是否支持TRIM: # sudo uname -a # sudo hdparm -I /dev/sda | grep TRIM 如果硬件支持,会提示类似如下的信息: * Data Set Management TRIM supported (limit 8 blocks) * Deterministic read ZEROs after TRIM 启用TRIM功能,需要修改/etc/fstab文件,在选项中加入discard。 也可以通过noatime,nodiratime选项,强制Linux不对访问文件的时间做记录,以减少对SSD的写操作。 文件修改例: UUID=9064cc67-5f20-4cf6-b71c-f18d78bfb60b / ext4 noatime,nodiratime,discard,errors=remount-ro 0 1 UUID=869f54b7-b9f2-414f-9436-565412827c39 /boot ext4 noatime,nodiratime,discard,defaults 0 2 UUID=cec0f78a-581f-4748-a686-acbbdea23270 /home ext4 noatime,nodiratime,discard,defaults 0 2 重新启动后,用mount命令查看是否成功。 第三步:交换空间 对于大内存来说swap基本上都是空闲的,除非电脑进入休眠状态,系统会将内存内容转到swap中。有了SSD后swap基本没用,可以不分配。(但安装不通过,强制要有swap分区)。 但在安装时,如果没有swap分不通过,我的作法是尽量分配得小(1G),并且通过设置来减少swap换出量。 可先查看当前的/proc/sys/vm/swappiness值(我的默认为60)。 设置/etc/sysctl.conf,如下: vm.swappiness=1 vm.vfs_cache_pressure=50 第四步:运行时的I/O调度 Linux有4种I/O调度策略,其中有些适合于普通机械硬盘,有些适合虚拟机或者数据库,具体可参考Linux IO Scheduler。 对于SSD来说noop和deadline调度器都是不错的选择。前者优势是简单,后者主要用于数据库等有高性能磁盘的场景,对于读更有优化。 设置的方法是建立规则文件: # sudo gedit /etc/udev/rules.d/60-schedulers.rules 内容如下: # Handle the scheduler choice according to the type of disk detected # system default : set cfq scheduler for rotating disks ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="1", ATTR{queue/scheduler}="cfq" # SSD specific : set deadline scheduler for non-rotating disks ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline" 通过如下命令性能实测: # sudo hdparm -Tt /dev/sda NOOP模式: /dev/sda: Timing cached reads: 12434 MB in 2.00 seconds = 6220.51 MB/sec Timing buffered disk reads: 1472 MB in 3.00 seconds = 490.11 MB/sec deadline模式: /dev/sda: Timing cached reads: 11510 MB in 2.00 seconds = 5757.64 MB/sec Timing buffered disk reads: 1544 MB in 3.00 seconds = 514.00 MB/sec 第五步:内存分区加速 如果内存够大,可以用ramdisk的方式,将一些经常变化的位置如/tmp放入内存,加快速度,减少对SSD的访问。 在/etc/fstab中加入: # SSD tweak : temporary directories as tmpfs tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0 tmpfs /var/spool tmpfs defaults,noatime,mode=1777 0 0 # SSD tweak : log directory as tmpfs tmpfs /var/log tmpfs defaults,noatime,mode=0755 0 0 如需要控制tmp目录大小,在mod选项前插入“size=nn[G | M]”的选项。 特别提示:会有很多应用程序将日志保存在/var/log路径下并造成SSD的大量访问,如果不在意这些日志丢失,可以将其放在内存中。 限制:
第六步:设置浏览器的缓存 可通过graysky程序来设置所有浏览器的缓存。 # sudo add-apt-repository ppa:graysky/utils # sudo apt-get update # sudo apt-get install profile-sync-daemon ... -------------------------------------------------------------------------- Define which users will make use of the sync in /etc/psd.conf Read the manpage before use or see the wiki page https://wiki./index.php/Profile-sync-daemon ALWAYS backup your profiles data before using utils like psd! -------------------------------------------------------------------------- Adding system startup for /etc/init.d/psd ... /etc/rc0.d/K20psd -> ../init.d/psd /etc/rc1.d/K20psd -> ../init.d/psd /etc/rc6.d/K20psd -> ../init.d/psd /etc/rc2.d/S20psd -> ../init.d/psd /etc/rc3.d/S20psd -> ../init.d/psd /etc/rc4.d/S20psd -> ../init.d/psd /etc/rc5.d/S20psd -> ../init.d/psd 设置/etc/psd.conf ...... USERS="yourlogin" ...... 检测各浏览器的设置: # sudo profile-sync-daemon parse Profile-sync-daemon v5.32 on Ubuntu 13.04. Daemon file /var/run/psd is not present. Psd will manage the following per /etc/psd.conf settings: browser/psname: firefox/firefox owner/group: nicholas/nicholas sync target: /home/nicholas/.mozilla/firefox/gu0ne6mm.default tmpfs dir: /run/shm/nicholas-firefox-gu0ne6mm.default profile size: 25M browser/psname: google-chrome/chrome owner/group: nicholas/nicholas sync target: /home/nicholas/.config/google-chrome tmpfs dir: /run/shm/nicholas-google-chrome profile size: 44M 启动psd服务: # sudo service psd start
|
|