Replacing storage Hard Drive

New storage Hard Drive

Here are my notes on copying the content of an old storage hard drive over to a new. The label of the old hard drive is "archive" and the label of the new hard drive is "archive_2017". It is assumed that your old hard drive will be mounted at "/archive".

NOTE: There's no guarantee that this will work for you, and some parts might have been left out unintentionally. You need to double-check everything before doing it yourself!

Insert new hard drive and check its name:

sudo lshw -C disk

description: ATA Disk
product: ST2000DM006-2DM1
vendor: Seagate
physical id: 0.0.0
bus info: scsi@4:0.0.0
logical name: /dev/sdc
version: CC26
serial: Z4Z73TZD
size: 1863GiB (2TB)

Look for the product name or size which matches your new hard drive (in this case it is 2TB) and note the logical name, in this case /dev/sdc, it will be used later.

Open Gparted and format the hard drive as ext4, select "gpt" as partition table type:
HDD: /dev/sdc
partition: /dev/sdc1
LABEL: archive_2017
UUID: 1e37f41d-5e07-41e6-855a-0b82aef893c7
PARTUUID: 4c5c2ea6-674d-47f9-b358-5898965a14fc

Chown the partition, exchanging "USERNAME" with your user name

sudo chown -R USERNAME:USERNAME /media/USERNAME/archive_2017/
sudo chmod -R 755 /media/USERNAME/archive_2017/

Test it is mounted

ls /media/USERNAME/archive_2017 -la

Test the difference in content between two hard drives with diff

diff /archive/ /media/USERNAME/archive_2017/

Copy over the content from old to new hard drive with rsync. First, dry-run rsync:

rsync -avhW --dry-run --no-compress --progress /archive/ /media/USERNAME/archive_2017/

Run without --dry-run if it looks good, which will copy the files. This could take some time, dependent on how many files you got.

Find the UUID for the new HDD with

sudo blkid

/dev/sdb4: LABEL="archive" UUID="cb13a23c-14f7-4d40-bc5e-73a1b655e748" TYPE="ext4" PARTUUID="00080ea0-04"
/dev/sdc1: LABEL="archive_2017" UUID="1e37f41d-5e07-41e6-855a-0b82aef893c7" TYPE="ext4" PARTUUID="4c5c2ea6-674d-47f9-b358-5898965a14fc"

Insert the UUID for the new HDD in fstab, so it mounts automatically at boot

sudo vi /etc/fstab

Show which partitions are mounted, and mount points. /dev/sdb4 is old HDD, and /dev/sdc1 is new HDD.

df -aTh | grep dev/sd

/dev/sdb4 ext4 1,3T 1,1T 129G 90% /archive
/dev/sdc1 ext4 1,8T 1,1T 688G 61% /media/USERNAME/archive_2017

Let the update take effect, or simply restart the computer

sudo mount -a


df -aTh | grep dev/sd

/dev/sdb4 - - - - - /archive
/dev/sdc1 ext4 1,8T 1,1T 688G 61% /media/USERNAME/archive_2017
/dev/sdc1 ext4 1,8T 1,1T 688G 61% /archive

RESULT after shutdown and restart, during which the old HDD was removed

df -aTh | grep dev/sd

/dev/sda1 ext4 184G 50G 125G 29% /
/dev/sdb1 ext4 1,8T 1,1T 688G 61% /archive
/dev/sda2 ext4 1,9G 204M 1,5G 12% /boot

The new hard drive should now be the "/archive"-drive.

For more info on rsync, see