Wednesday, May 16, 2018

Migrating from SSD to M.2 or NVMe in Ubuntu

A couple years ago I started working with NVMe drives at work.  They advertise "up to 6x the speed of SSD", and are pretty neat to play with when working with vSAN.  Of course these are industrial grade NVMe drives, which are pretty much a board with a bunch of M.2 drives on it and a string of capacitors with some other chips sprinkled in for advanced capabilities.  I obviously needed to have something similar in my computer.  So I ordered a 960 EVO and PCI-e adapter.  First impression is that these things are small.  About the size of laptop RAM.  My next observation was that my old box wasn't going to be able to use it as a boot drive, it was just too old.  So I put it in my system to use for ripping and transcoding video files.

Aggregate 1:
Isn't it pretty?

But then I upgraded to a motherboard that has an M.2 socket, so I had to make it my boot drive.  The nice thing about Linux is that it tends to be easier to make backups and move the OS around.  So, I built my new box, popped in the old SSD, booted up and made sure everything worked the way I wanted it to.  Then, I had to study to migrate the data, and find the missing pieces in the instructions.  First step was to create a Ubuntu DVD, I used 18.04 since I knew it would have a decent nouveau driver (got a 1070 in my new rig).  Booted from the disk and ran it live, which takes a long time to complete boot and get to a working screen.  This part was rough because I had to do it a few times due to missing instructions. 

Aggregate 2:
The Bionic Beaver

Once booted, I needed to install gddrescue and copy the SSD to the M.2.  I probably could have figured out how to do this with dd, but I was hoping this would be the one and only step.  For those that intend on pulling out their old SSD after upgrade, it probably could be.  A quick note before anyone begins on this endeavor, check the block size of your disks.  I got lucky with uniform 4k blocks on my devices, but I have seen 512 and 8k block sizes on devices.  A simple blockdev --getbsz /dev/sda1 to view block sizes on that partition can mean the difference between completing the task quickly and having to reboot into a live disk an additional time.  The instructions for using ddrescue are simple enough,   sudo ddrescue -v --force /dev/sda /dev/sdb to clone data from one drive to another.  NVMe or M.2 would look a little more like sudo ddrescue -v --force /dev/sda /dev/nvme0n1  and the full instructions for moving stuff around on bigger and smaller drives are in the following aggregate.

Aggregate 3:
Migrating the OS

The part that I got stuck on was the UUID.  Cloning the drive leaves the new device with the identical UUID of the old one.  I had to make changes to the drive, so I decided to fix it in gparted.  Yes, this can also be done in parted, if you want to get down like that.  The first task was to edit the M.2 drive to use all of the storage, since it has double the capacity of the old drive.  This part is dangerous, you can break the install on the drive you are modifying if something goes wrong.  That is also the reason for the UUID change, so I could easily get back to a working SSD if something bad happened.  Once the capacity change is completed, go to the Partition menu in gparted and give each partition a new UUID. 

Aggregate 4:
Gparted capacity increase instructions

Now that you have new UUIDs associated with the partitions, you need to fix your boot parameters.  What was normally a difficult and boring part of Linux administration is automated, which is great because there are too many ways to fat finger a UUID if you have to enter it manually.  All that is needed is to run boot-repair.  Just make sure you check out all of the options, select the drive you want to repair (nvme0), and only write to that drive.  That way you can pull the M.2 drive out and go back to the SSD if things seem to become too dire after reboot. 

Aggregate 5:
Boot repair, but not from a cobbler

Reboot your system, verify the boot option in the BIOS, and see how fast the system comes to life.  I've heard some optane systems can be up and running before you pull your hand back from pushing the power button.  Once you are sure everything is to your liking, you can wipe the old drive and use it for tier 2 storage, or a new mount point for /var.


No comments:

Post a Comment

3d design for printing

I don't want to sound like an idiot.  I really don't.  I just lack the patience to learn Blender.  It's not just because the nam...