On Linux and need to move lots of data from one hard drive to another? If so, consider using the Gparted partition editing tool for Linux. Aside from editing hard drive layouts, it can quickly clone any partition onto multiple hard drives (or even duplicate partitions on the same hard drive) making it a great tool to transfer a Linux installation to a different hard drive.
Copying partitions with Gparted is very easy, but it doesn’t work with mounted partitions. You’ll need to make sure that the hard drive you’re working with isn’t in use with the primary system. It is possible just to install the tool to your Linux distribution, and use it from there, but it’s best to work with a live system. Having a live system ensures that no partitions are currently in use.
To get started with the live disk, download the latest version of the Gparted ISO image. Also, get out a USB flash stick of at least 1GB in size, and download the freshest version of the Etcher USB tool.
Create Live Disk
Plug in the USB stick and open up Etcher to start the live disk creation process. Inside Etcher, select the ISO file and click the “flash” button to create the disk. Etcher will take a bit of time, but when it’s complete, reboot your PC and load up the BIOS. Using the BIOS on your PC, change the bootloader, so it loads the Gparted live disk first.
Load Gparted Live
Even though this live disk is a graphical tool, it doesn’t start out that way. Go through the instructions on the screen to select your language and keyboard layout. Then, enter “startx” into the prompt, and it’ll load up the live desktop environment. From here, find “Gparted” and double-click on it to open the partitioning tool.
if (navigator.appVersion.indexOf(“Mac”)!=-1) document.write(”);
RECOMMENDED FOR YOU
When it opens, the tool scans every hard drive that is connected to your system and readable. Using the drop-down menu on the right, select the drive you’d like to copy data from. In this article, the drive we’ll be copying data from is /dev/sda, and the drive that will be receiving the reproduced data is /dev/sdb.
Copying Partition Layouts
A straightforward way to transfer a Linux installation from one hard drive to another is by using the “copy partition” function in the Gparted partition tool. Keep in mind that the drive you’re copying a partition from must be blank. To blank it, open up a terminal window and follow our guide on how to securely erase a hard drive. When the process is complete, go back to Gparted and select the drive (in our example, this hard drive is /dev/sdb).
Click “Device,” then “create partition table.” Keep in mind that this hard drive MUST have the same scheme as the one giving the data. If /dev/sda is a GPT partition with EFI, /dev/sdb must also be, and vice versa.
Instead of creating a fresh partition with the dialog on /dev/sdb, go to the hard-drive selection menu and select /dev/sda. Look for the partition that holds your data. In this example, we’ll be copying our /home folder, and its label is/dev/sda2.
Right-click on the partition and click “copy” (or Ctrl + C), then, once again, go back to the hard drive selection menu and move back to /dev/sdb. Right-click on the white-space, and select “Paste” (or Ctrl + V). Selecting the paste option will start a partition copying sequence, which will take a long time (depending on how large the partition is). Let Gparted do its thing, and eventually, your data will be moved to the new drive!
Using these instructions, feel free to do it as many times as you like, to copy multiple partitions over from one hard drive to another.
When Gparted finishes copying the data, feel free to close it. Then, reboot your PC. All of your data should be moved over.
Aside from using Gparted, there are other ways to transfer a Linux installation from one hard drive to another. The best and fastest way to directly clone a partition is with DD. To do this, open up a terminal and use the lsblk command to reveal hard drives on the system. Like in the Gparted method, the source hard drive is /dev/sda, and the destination hard drive is /dev/sdb. To clone the home partition from the source drive, you’ll need to blank the disk.
Once /dev/sdb is clear, use the parted command to create a new partition table.
sudo parted /dev/sdb
Create a new partition table and make sure that it’s the same as the source (if the source is EFI, use GPT. If it is MBR, use MS-DOS).
mklabel msdos quit
Next, use the DD command to start a copy of /dev/sda to /dev/sdb.
sudo dd if=/dev/sda of=/dev/sdb bs=1M
When the terminal is usable again, DD is finished.