replace spinning HD with SSD

Questions about hardware and drivers
Forum rules
Before you post please read this

replace spinning HD with SSD

Postby Riko on Mon May 27, 2013 8:20 am

Hi all,

I plan to replace the spinning HD of the system in my signature with a SSD drive of the same capacity. My /home partition in encrypted using the ecryptfs utilities. My plan is:

1) boot the machine from a stick
2) clone the spinning HD to SSD via dd or gddrescue
3) put the SSD in and I'm good
3a) Maybe I have to recreate the MBR on the newly installed SSD

Am I missing something? As far as I could find out, there are no problems with encrypted filesystems on SSDs, are there?

Thanks and cheers,
Riko
Dell Latitude E6230 with Intel i7, 8GB RAM, 500 GB SSD
dual boot: LMDE and Antergos both running gnome-shell
surviving in a Windows world with VMware WS 10 and Crossover 13
Riko
Level 3
Level 3
 
Posts: 128
Joined: Fri Dec 09, 2011 9:10 am
Location: Hamburg, Germany

Linux Mint is funded by ads and donations.
 

Re: replace spinning HD with SSD

Postby cwsnyder on Mon May 27, 2013 10:50 am

AFAIK, and I don't have a SSD, so take my advice with a large grain of salt, the main problems with a SSD replacing a spinning HD are any swap partition and the file journaling system. You may want to do some reading of blogs talking about SSD replacement of hard drives.
LMDE Mate 64-bit, LM16 Mate 64-bit
Debian Xfce 64-bit, Xubuntu 13.10 64-bit, Xubuntu Trusty Tahr 64-bit, Antergos Xfce 64-bit, PCLinuxOS LXDE 64-bit
cwsnyder
Level 6
Level 6
 
Posts: 1039
Joined: Wed Oct 20, 2010 6:49 am
Location: Nappanee, IN, USA

Re: replace spinning HD with SSD

Postby Riko on Mon May 27, 2013 3:24 pm

Interesting!
I would have never thought that that would be a problem. There is a fairly comprehensive (as far as I can tell) article in the Arch Wiki:

https://wiki.archlinux.org/index.php/Solid_State_Drives#Tips_for_Maximizing_SSD_Performance

which claims, with the proper options ext4 (as all my partitions are) can be used in most cases without much additional wear. Since I don't do much compiling, I guess I'm safe. As far as swap is concerned, reducing swappiness might just be the solution, or replacing the swap partition with a swap file as suggested here. I don't experience swapping anyway with 8GB of RAM.

http://ubuntuforums.org/showthread.php?t=1937251

Since hibernate is not working with encrypted fs on swap, I don't miss out on hibernation anyway :)

Maybe, instead of just dd'ing the SSD, I partition it manually, copy the data over and re-write the MBR. However, just removing swap and updating the mount options in /etc/fstab before booting from the new device should do the trick as well!?

Thanks for pointing me in that direction. Any more thoughts are highly appreciated.

Cheers, Riko
Dell Latitude E6230 with Intel i7, 8GB RAM, 500 GB SSD
dual boot: LMDE and Antergos both running gnome-shell
surviving in a Windows world with VMware WS 10 and Crossover 13
Riko
Level 3
Level 3
 
Posts: 128
Joined: Fri Dec 09, 2011 9:10 am
Location: Hamburg, Germany

Re: replace spinning HD with SSD

Postby catweazel on Mon May 27, 2013 5:07 pm

Riko wrote:Maybe, instead of just dd'ing the SSD, I partition it manually, copy the data over and re-write the MBR. However, just removing swap and updating the mount options in /etc/fstab before booting from the new device should do the trick as well!?

Yes, that's correct. However there are a lot of things you can do that will extend the life of your SSD. For starters, formatting it from the command line with various options to enhance the filesystem for SSD, setting options in fstab, mounting certain drive locations into RAM, not running Google's Chrome browser, and more.

I will put together a tutorial for migrating from HDD to SSD and post it in the tutorials section. It might be ready tomorrow. Keep your eyes open for it.
Mint Testing Team & Mint Donor #3606
KDE 4.12.0, custom preemptive kernel 3.12.5,
Intel i7 4770K @ 4.7GHz, 16GB 2666MHz XMP,
4 Samsung 840 PRO 512GB SSDs in RAID0,
6TB HW RAID10, dual 24" Acer X243H,
Gigabyte nVidia GTX 680 Super Overclock
User avatar
catweazel
Level 7
Level 7
 
Posts: 1656
Joined: Fri Oct 12, 2012 9:44 pm

Re: replace spinning HD with SSD

Postby GeneBenson on Mon May 27, 2013 5:16 pm

Hi Riko,

I have a desktop model and installed an SSD along with my HDD's a few months ago. I don't encrypt so I can't help there. However, here are a few thoughts:

You might want to have a look at Clonezilla. If your SSD is the same capacity as your HDD then you could use Clonezilla to do the cloning.
Have a look in /boot/grub/grub.cfg. You will see that grub uses UUID's to locate where to boot from so merely changing entries in /etc/fstab probably won't be enough.
GParted has an option, which I have never used, to change a UUID if needed. So if you have a different UUID after the cloning it should be possible to change it. Just as long as you write the old one down first. :D
Parted Magic contains both Clonezilla and GParted so that may be an option for you.

Clonezilla: http://www.clonezilla.org/
Parted Magic: http://partedmagic.com/doku.php

Hope this helps. :wink:
GeneBenson
Level 3
Level 3
 
Posts: 181
Joined: Fri Sep 17, 2010 9:55 pm

Re: replace spinning HD with SSD

Postby catweazel on Tue May 28, 2013 2:34 am

GeneBenson wrote:You might want to have a look at Clonezilla. If your SSD is the same capacity as your HDD then you could use Clonezilla to do the cloning.

That is not good advice for a SSD. Your suggestion means A) the filesystem on the SSD will be tuned for a HDD and not a SSD. That in turn means B) the journal is written to the disk before the data, the result being absolutely unnecessary disk writes to a limited write-life device. C) He can't take advantage of directory indexing, and not only that, D) the partition boundaries most certainly will not be aligned to a cylinder, which will cause the SSD to choke on extended writes.
Mint Testing Team & Mint Donor #3606
KDE 4.12.0, custom preemptive kernel 3.12.5,
Intel i7 4770K @ 4.7GHz, 16GB 2666MHz XMP,
4 Samsung 840 PRO 512GB SSDs in RAID0,
6TB HW RAID10, dual 24" Acer X243H,
Gigabyte nVidia GTX 680 Super Overclock
User avatar
catweazel
Level 7
Level 7
 
Posts: 1656
Joined: Fri Oct 12, 2012 9:44 pm

Re: replace spinning HD with SSD

Postby Riko on Tue May 28, 2013 4:45 am

Hey guys,

thanks for your replies. After what I read already also in the links I posted last night, I will not actually clone my spinning HD onto the SSD. This

http://apcmag.com/how-to-maximise-ssd-performance-with-linux.htm

gives some useful hands-on tips as well. So my updated replace-spinning-HD-with-SSD strategy now looks as follows:

1) partition the SSD manually (block aligned partitions as advised)
2) copy partitions over by just doing "cp -a source dest" from a live distro with the old spinning and the SSD mounted
3) update the partition UUIDs in fstab on the SSD /-partitions and setting the proper TRIM flags on the ext4-fs
4) finally I need to boot LMDE from the new SSD via a USB stick and re-install grub/MBR.

Essentially the same steps I already did before when replacing small spinning HD with a bigger one on the device.

Thanks again for your comments, more are welcome and much appreciated. I'll definately report back on the results. However, this will take a few since it's my business laptop and the SSD will be purchased by my employer.

Cheers, Riko
Dell Latitude E6230 with Intel i7, 8GB RAM, 500 GB SSD
dual boot: LMDE and Antergos both running gnome-shell
surviving in a Windows world with VMware WS 10 and Crossover 13
Riko
Level 3
Level 3
 
Posts: 128
Joined: Fri Dec 09, 2011 9:10 am
Location: Hamburg, Germany

Re: replace spinning HD with SSD

Postby catweazel on Tue May 28, 2013 5:43 am

Riko wrote:1) partition the SSD manually (block aligned partitions as advised)
2) copy partitions over by just doing "cp -a source dest" from a live distro with the old spinning and the SSD mounted
3) update the partition UUIDs in fstab on the SSD /-partitions and setting the proper TRIM flags on the ext4-fs
4) finally I need to boot LMDE from the new SSD via a USB stick and re-install grub/MBR.

Do this at step 2 rather than use cp:
Code: Select all
sudo rsync -vax /src /dest/

With those 4 steps you will have to chroot into the destination and run update-grub.
Mint Testing Team & Mint Donor #3606
KDE 4.12.0, custom preemptive kernel 3.12.5,
Intel i7 4770K @ 4.7GHz, 16GB 2666MHz XMP,
4 Samsung 840 PRO 512GB SSDs in RAID0,
6TB HW RAID10, dual 24" Acer X243H,
Gigabyte nVidia GTX 680 Super Overclock
User avatar
catweazel
Level 7
Level 7
 
Posts: 1656
Joined: Fri Oct 12, 2012 9:44 pm

Re: replace spinning HD with SSD

Postby Riko on Mon Jun 17, 2013 5:12 pm

Follow-up: my SSD finally arrived and these are the steps I did to migrate from the spinning HD to the SSD.

Before I actually got the SSD I set up a few things advised to reduce writes to the disk and therefore increase lifetime. All if these actions are also useful for a spinning HD toimprove performance. The measures taken are:

1) move some of the tmp dirs from disk to ram. Since I have plenty of ram, no problem with this, also helps to speed up your system. Edit your /etc/fstab file and add
Code: Select all
# tmpfs for (some) temp and logs
tmpfs   /tmp       tmpfs   defaults,noatime,mode=1777   0  0
tmpfs   /var/tmp   tmpfs   defaults,noatime,mode=1777   0  0
tmpfs   /var/log   tmpfs   defaults,noatime,mode=0755   0  0


2) I didn't want to get rid of swap altogether, since this machine is also a host to some VMs and you never know. However you can force to swap only if ram is physically low. I think, this is just a precaution, because Linux seems to be pretty good in avoiding swapping already. Anyway, I added to /etc/rc.local:
Code: Select all
# pretty much disable swap except when there is no RAM left
echo 0 > /proc/sys/vm/swappiness


3) move the profile folders of your browsers also to ram disk, but sync with your home dir, to keep history, extensions and the like. There is actually a little tool, that does the trick called profile-sync-daemon (psd). See for example here: http://forum.linuxmint.com/viewtopic.php?f=47&t=126397 how to install. I used the quantal ppa (yeah, yeah, I know this is LMDE but works just fine). Once you installed it, you need to configure a few minimal things for the daemon to actually do the job (e.g. select users and browses). Mine looks like this now:
Code: Select all
> cat /etc/psd.conf
# List users separated by spaces whose browser(s) profile(s) will get symlinked
# and sync'ed to tmpfs
USERS="wichmann"

# List browsers separated by spaces to include in the sync. Useful if you do not
# wish to have all possible browser profiles sync'ed
# Otherwise all available/supported browsers will be managed
BROWSERS="google-chrome midori firefox"

# Define where browser profiles will reside in tmpfs
VOLATILE="/run/shm"

# Define where the pid file for psd will reside
DAEMON_FILE="/var/run/psd"


(I removed most of the comments to keep this sort.)

As I said, these 3 steps I did already before I got my SSD to experiment and make sure things work as expected. A word of caution. I lost my Chrome extensions in the process of moving things to ram-disk. I had a back-up of my profle dir, but didn't manage to restore them. Didn't try very hard either, because they were quick to just re-install.

4) Put the new SSD into a external usb case and plug it into your computer

5) boot the machine with a Live Distro of your choice, I used Mint :)

6) partition your SSD using for example gparted. I used the same partition layout as the spinning HD only adjusted the sizes a bit. You may what to rethink your partitioning since you start from scratch anyway :) When creating your partitions, make sure to align them to full block or MiB, respectively. gparted gives you an align option to do so.
I had ext4 fs on the spinning HD and use ext4 on the SSD. I did set the "boot" flag on my system partition. Not sure, if that is actually necessary

7) after your partitions are created, mount the one by one all spinning HD partitions and the respective SSD partitions, e.g.
Code: Select all
sudo mkdir /media/src
sudo mkdir /media/dest
sudo mount /dev/sda1 /media/src    # this is partition 1 of the (original) spinning HD
sudo mount /dev/sdd1 /media/dest  # this of the (new) SSD, adjust if necessary

and then copy src to dest
Code: Select all
sudo rsync -ax /media/src/ /media/dest/
sudo umount /media/src
sudo umount /media/dest

Do this for all your partitions!

8 ) get the UUID for your new device from
Code: Select all
sudo /sbin/blkid


9) mount your system partition of the SSD (!!) where Mint is installed again, in my case this was sdd1:
Code: Select all
sudo mount /dev/sdd1 /media/dest

open /media/dest/etc/fstab and replace the UUIDs of your old device with the ones for your new SSD.

10) since the SSD system partition is still mounted, you can take care of setting the proper mount options to reduce wear of the SSD, e.g. add "noatime,discard" to the mount options. Mine looks like that
Code: Select all
> cat /media/dest/etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc   /proc   proc   defaults   0   0
# /dev/sda1
UUID=55a8f139-f99b-4d48-a4f1-fd8526c77919   /   ext4   noatime,discard,errors=remount-ro   0   1
# /dev/sda6
UUID=35aaea0d-f1cc-4cfe-b436-19470e6d0fac   /home   ext4   noatime,discard,rw,errors=remount-ro   0   0
# swap partiton: sda5
/dev/mapper/cryptswap1 none swap sw 0 0

# tmpfs for (some) temp and logs
tmpfs   /tmp       tmpfs   defaults,noatime,mode=1777   0  0
tmpfs   /var/tmp   tmpfs   defaults,noatime,mode=1777   0  0
tmpfs   /var/log   tmpfs   defaults,noatime,mode=0755   0  0


## data partition
UUID=7da6f032-6f48-44b8-8fd1-729e53379aed       /mnt/data       ext4    noatime,discard,rw,errors=remount-ro        0       2


also, you want o adjust the scheduler to organize the I/O queue by adding to /media/dest/etc/rc.local
Code: Select all
echo deadline >/sys/block/sda/queue/scheduler

assuming sda will be your SSD device after (!!) you put it into your machine.

11) Now, it's time to get out the screw driver and remove the spinning HD and put the SSD in.

12) boot again your favorite Live distro because we still need to re-install grub2 in the MBR

13) to re-install grub,
a) mount your system partition (in my case sda1, this is now your (internal) SSD)
Code: Select all
sudo mount /dev/sda1 /mnt
       

b) mount some of the system fs you need:
Code: Select all
for i in /sys /proc /run /dev; do sudo mount --bind "$i" "/mnt$i"; done
       

c) chroot into your installation and re-install grub2
Code: Select all
      sudo chroot /mnt
      grub-install /dev/sda
      update-grub
     

d)
Code: Select all
exit


Now it's time to shutdown your Live distro, pray to the big penguin above, hold your breath :) and boot from your newly installed SSD.

The improvements I saw in start-up times where for spinning HD vs SSD:
31 secs vs 11 sec for boot
30 secs vs 7 secs for Cinnamon start-up.

Cannot say much about battery life time yet.

Hope that helps and please send comments if you think something should be changed.

Cheers and good luck,

Riko

References:
Of course, haven't figure that out myself, but use community information!
[1] Arch Wiki with info regarding SSD and reference to the profile-sync-daemon: https://wiki.archlinux.org/index.php/Solid_State_Drives
[2] PSD repositories which work for LMDE as well: http://forums.debian.net/viewtopic.php?f=6&t=96425
[3] same info, but shorter: http://apcmag.com/how-to-maximise-ssd-performance-with-linux.htm
[4] re-install grub: http://askubuntu.com/questions/88384/how-can-i-repair-grub-how-to-get-ubuntu-back-after-installing-windows
Dell Latitude E6230 with Intel i7, 8GB RAM, 500 GB SSD
dual boot: LMDE and Antergos both running gnome-shell
surviving in a Windows world with VMware WS 10 and Crossover 13
Riko
Level 3
Level 3
 
Posts: 128
Joined: Fri Dec 09, 2011 9:10 am
Location: Hamburg, Germany

Re: replace spinning HD with SSD

Postby Arnoud on Thu Jul 25, 2013 3:22 am

Congrats on your new SSD. :) Have you considered enabling and testing TRIM? More info here: https://sites.google.com/site/lightrush ... andworking
Arnoud
Level 1
Level 1
 
Posts: 5
Joined: Wed Jul 24, 2013 7:56 am

Re: replace spinning HD with SSD

Postby zolar1 on Thu Dec 12, 2013 1:34 pm

Out of curiosity, how do you trim an external SSD?

Typing in long UUID's is no fun if that is necessary.

And should you trim flash drives?
zolar1
Level 3
Level 3
 
Posts: 101
Joined: Fri Oct 05, 2012 9:07 pm

Linux Mint is funded by ads and donations.
 

Return to Hardware Support

Who is online

Users browsing this forum: No registered users and 2 guests