Moving Linux installation to bigger disk/SSD

I recently had an experience helping customer moving its Linux installation from 4GB CF to 16GB SSD. Normally, we can transfer existing installation from one medium to another easily if the size is the same. Unfortunately this is not the case. So, here are the high level steps to achieve do this.

1. Attach the new disk on spare SATA port.
2. Re-create new partition structure in the new disk. Maintain the partition ordering based on each function (either root, home or swap). Use fdisk.
3. Format each partition on the new disk based on its type. e.g. mkfs.ext3 /dev/sdb1 or mkswap /dev/sdb3
4. Create filesystem structure on the new partitions and copy files according to filesystem structure except /dev /proc /sys (kernel related mount points).
5. Test your new filesystem by rebooting the system and pointing the root to target disk
     e.g. on the GRUB boot screen, edit the option by changing root=/dev/sdb1 or the root partition on the new disk. Ensure the OS boots up OK on the new disk.

6. Install Grub boot loader on new disk.
In order to install the boot loader on the new disk, please ensure that /boot folder from previous installation are properly placed and mount. Then execute the grub as root.
On the GRUB prompt, set the root disk
> root hd(1,0)
(root located at secondary HDD port at at partition 1.)
> setup (hd1)
(setup boot loading scheme on secondary disk).
If there is no error, the boot loading should be installed on the secondary disk. Now shutdown the system and replace the old disk with your newly provisioned disk.

I hope this would help.


Comments