From time to time, you get to the point that you might have to migrate your root/boot disk to another disk – sometimes a smaller disk even.

 

There are many ways of doing this. I recently found out that this might not be as easy as one thinks.

Here are the steps needed to be able to migrate the data and have a bootable disk.

Get some type of external disk – USB/NAS/DAS

Get a USB stick for Xboot

Get Xboot – for creating bootable USB: http://dev.majorgeeks.com/files/details/xboot.html

Get following iso; ubuntu live – clonezilla and lastly gparted.

  1. https://help.ubuntu.com/community/GettingUbuntu
  2. http://clonezilla.org/liveusb.php
  3. http://gparted.sourceforge.net/livecd.php

 

Now create the USB with these 3.

Put the USB into the machine with the HDD you want to migrate.

Start of using gparted – we want to shrink the parition to fit the new SSD

If you get any warnings about sdb or sdc might be a GPT volume – dont get to stressed and check the size of the mentioned drive. Most probably its your USB disk.

Resize the HDD (make sure you have working backups and all that).

Let the server reboot fully into OS after the decrease the size to fix directory issues that might appear.

 

Reboot the server and this time you choose Clonezilla.

choose device-image -> local_dev -> insert the USB/NAS/DAS disk -> choose the inserted this -> pick / -> saveparts -> give it a name <– let it work –>

*shutdown the server when done – I do this step to unplug the original HDD and plugin the SSD (if it isnt already)

Startup with the USB device created with Xboot and choose Clonezilla again.

Do all the steps as marked bold above but this time instead of choosing saveparts – pick restoreparts.

Let it store to your SSD disk (sometimes Clonezilla doesnt find the disk – go to shell and use fdisk to make it visible)

when the restoration is done, reboot the server.

Choose Ubuntu this time at boot with the Xboot USB.

Let it load and pick Try Ubuntu or give me a shell.

type: update-grub /dev/sd* the SSD device

Unplug the USB and reboot the server into your OS – but on the new SSD.

You will most definitely have to update UUIDs in fstab. You will find them by blkuid or ls -l /dev/disk/by-uuid

In some cases you will have to destroy the swap parition and recreate it.

sudo mkswap /dev/sdx

replacing sdx with your partition. Mount this partition as swap with

sudo swapon -U UUID

where UUID is that of your /dev/sdx as read from this

blkid /dev/sdx

Bind your new swap in /etc/fstab by adding this line:

UUID=xxx    none    swap    sw      0   0

If you want to use your swap for hibernating then you need to update the UUID in /etc/initramfs-tools/conf.d/resume with this content RESUME=UUID=xxx. Don’t forget to $ sudo update-initramfs -u.

 

Thats about it – easy as pie. 🙂

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *