Showing posts with label SSD. Show all posts
Showing posts with label SSD. Show all posts

Wednesday, September 09, 2015

SSD trim


This article explains what is TRIM and how to handle in Windows platform.

Below two related to Ubutu, and I am happy to see there is already weekly job for trimming.


tail -n1 /etc/cron.weekly/fstrim 
/sbin/fstrim --all || true
 
http://askubuntu.com/questions/443761/how-is-trim-enabled

http://askubuntu.com/questions/18903/how-to-enable-trim

 
However, due to my SSD capacity is small (120GB) only, I decided to have a daily cron job instead
 as shown below..


/etc/cron.daily$ cat trimssd
#!/bin/sh
LOG=/var/log/trimssd.log
echo "*** $(date -R) ***" >> $LOG
fstrim -v / >> $LOG


hmc@hmc-P55A-UD3:/etc/cron.daily$ sudo chmod 755 trimssd
hmc@hmc-P55A-UD3:/etc/cron.daily$ sudo ./trimssd
hmc@hmc-P55A-UD3:/etc/cron.daily$ cat /var/log/trimssd.log
*** Wed, 09 Sep 2015 23:11:59 +0800 ***
/: 3.3 GiB (3499556864 bytes) trimmed

migrate ubuntu 15.04 from HDD to SSD

Factors:
a.) 9 bad sectors reported by gnome-disks.
b.) Interested on new stuff - SSD
e.) Attractive price from Comex: Sandisk 120GB only S$72.

Did some research on the web.

A good article https://help.ubuntu.com/community/MovingLinuxPartition , but seems not update-to-date. Anyway it explains what is going on in details. I followed from step 1 to 4,  and part of step 5 & 6 . Since I have no confidence on editing grub.cfg and didn't see below (maybe few detail steps is not descripted clearly)


1) UBUNTU...
  • Finally, once rebooted successfully on new Ubuntu partition
As I found it still use my HDD for bootup.

Thus I abandom the "Refresh the GRUB 2 menu "


sudo update-grub


Instead , I followed below step to install grub mentioned in http://frugaltech.happystoic.com/ssdlinux and https://frankfzw.wordpress.com/2014/12/23/migrate-ubuntu-14-04-from-hdd-to-ssd/


$ sudo mount -o bind /dev   /mnt/ssd/dev
$ sudo mount -o bind /sys   /mnt/ssd/sys
$ sudo mount -t proc /proc  /mnt/ssd/proc
#$ sudo cp /proc/mounts /media/SSD/etc/mtab    --> I skip this command, as it doesn't seem to use UUID. 

$ sudo chroot /mnt/ssd
$ grub-install /dev/sdc
$ grub-install --recheck /dev/sdc       # only in case of errors in the step before
$ update-grub2

Reboot PC and Yes!18 seconds instead of previous 45 seconds.




Later on I study somemore on mtab and fstab.

Here is one short comparison : http://www.linuxquestions.org/questions/linux-newbie-8/difference-between-mtab-and-fstab-924190/

and more can be found http://ubuntuforums.org/showthread.php?t=1737715



For UUID to be used in fstab, in fact I prefer to use device ID & partition ID, as I have 2 HDDs (1TB Hitachi and 2TB Toshiba) and 1 SDD (120GB Sandisk).  Here is my fstab, easier for me to understand.

root@hmc-P55A-UD3:/etc# cat   fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' 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).
#
#              
# / was on /dev/sda10 during installation
# /mnt/shared was on /dev/sda8 during installation
# /mnt/staging was on /dev/sda9 during installation
# /mnt/vm was on /dev/sda7 during installation
# swap was on /dev/sda5 during installation

/dev/disk/by-id/ata-Hitachi_HDT721010SLA360_STF610MR15HK9P-part7 /mnt/vm ext3 defaults 0 2
/dev/disk/by-id/ata-Hitachi_HDT721010SLA360_STF610MR15HK9P-part8 /mnt/shared ext3 defaults 0 2
/dev/disk/by-id/ata-Hitachi_HDT721010SLA360_STF610MR15HK9P-part9 /mnt/staging ext3 defaults 0 2
#/dev/disk/by-id/ata-Hitachi_HDT721010SLA360_STF610MR15HK9P-part10 / ext4 errors=remount-ro 0 1
/dev/disk/by-id/ata-SanDisk_SDSSDA120G_152480401043-part1 / ext4 noatime,nodiratime,errors=remount-ro 0 1
/dev/disk/by-id/ata-Hitachi_HDT721010SLA360_STF610MR15HK9P-part5 none swap sw 0 0
#/dev/disk/by-id/ata-Hitachi_HDT721010SLA360_STF610MR15HK9P-part2 none swap sw 0 0
/dev/disk/by-id/ata-TOSHIBA_DT01ACA200_43J1EREGS-part1 /mnt/localubt ext4 defaults 0 2
/dev/disk/by-id/ata-TOSHIBA_DT01ACA200_43J1EREGS-part2 /mnt/shared2 ext4 defaults 0 2
 


gnome-disks a handy tool to manipulative this.



I also referenced https://radu.cotescu.com/migrating-your-ubuntu-machine-to-a-ssd-drive/

Prepared a few rescue Swiss knives like boot-repair, gparted, unetbootin, clonezilla, Ubuntu live CD (same version as my HDD) in bootable thumdrives.