Harry Domanski

Moving Linux to New Drive

Moving my Linux install to a new drive.

Why? Well from my dark days as a Windows user, Windows is still on my main SSD as a ‘backup’. Today that will change.

Having not used Windows for many months, I can safely say it will never be needed again. With the EOL of Windows 10, all the more reason.

Good riddance Windows!

Getting Started

Backup

As with any project like this, it is wise to backup any data you would like to keep, so… do that!

For me, I am backing up my Linux install onto another drive. Simply, I’m just rsyncing my user data to a new drive.

From some reading online, it seems a good candidate rsync command would be something like this:

sudo rsync -avxHAX --delete --progress --exclude-from='/path/to/exclude.txt' / /mnt/backup/system_backup

Click here for a better explanation of this command than I can muster up

Setting up Drives

Once this is done, the old Windows install can be wiped.

For which I will use a https://gparted.org/ live drive.

If you use a Bootloader for duel booting already, once you reboot into your computer it should recognise your GParted boot medium.

Once you’re in GParted go to the partition manager.

Find your old drive you would like to move your Linux install to and format those drives (please make sure there is no remaining data you would like to keep from there). Make sure to keep your /efi/ or /boot/ as well, as this will need to be loaded to boot in the future.

If you have a similar experience to me, it may be worth formatting the /efi/ or /boot/ partition, it would seem the Windows Bootloader by default is 100MB but Linux installs recommend 512MB for their install. This caused a headache for me, so it may be worth starting with a clean slate.

Once this is done, reboot into your normal OS and verify all is good.

Now we can move onto moving the data across

Moving Data to New Drive

Similarly to the back, we will use the rsync command.

Make a mount point for the drive you’re moving to e.g. sudo mount /mnt/new and then using rsync again, move all your data to the new drive.

sudo rsync -avxHAX --delete --progress --exclude-from='/mnt/mass/backups/exclude.txt' --dry-run / /mnt/mass/backups/os_backup/

Something like this will be good to move your system, this will preserve system links and the like to make sure your system works on the new drive.

Once this is complete, you will need update the boot files on the system so your bootloader recognises there is indeed an operating system to boot into.

For myself, I used GRUB. rEFInd was attempted, but I was having difficulties with that installation , GRUB worked a lot more seemlessly for me.

To use GRUB you will need to install it first:

On Arch:

sudo pacman -S grub

If you’re logged in as root, of course omit the sudo

Once complete, generate the grub config.

Make sure to generate fstab files again.

Once fstab files have been generating and GRUB installed, in theory you should be ready to restart.

Restart your machine and go into the bootloader.

In the bootloader, select your hopefully now appearing drive you have moved Linux too and try booting into it.

Once complete, you should boot into your backed up Linux system as it nothing changed!

To verify it is running in the correct drive you can use various tools to confirm which drive is running, e.g. btop, lsblk, etc.

Congratulations. You are done!