0

I have a hard disk of 320GB attached to a debian machine and a new 2TB drive which will be an upgrade for the smaller drive.

I've just tried to clone the smaller drive to the larger drive using the following command:

sudo dd if=/dev/disk5 of=/dev/disk2 bs=4096 conv=sync,noerror

However this has resulted in the 2TB drive showing as 320GB.

When I run (the sda numbers have changed as I did the clone from my mac and then plugged the drive into the debian machine):

sudo fdisk -u /dev/sda1

I get the following output showing that the 2TB drive has shrunk to the smaller drive size.

Disk /dev/sda1: 298.1 GiB, 320071884800 bytes, 625140400 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x5094580b

How do I expand the drive to show it's full capacity, preferably without having to dd again as it took a very long time?

I've tried:

sudo resize2fs /dev/sda1

But that doesn't do anything. It gives the following output:

The filesystem is already 78142550 (4k) blocks long.  Nothing to do!

UPDATE:

If I run:

sudo fdisk -l

I get the following:

Disk /dev/sda: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x54bd406a

Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1        2048 625142447 625140400 298.1G 83 Linux
0

It appears that on your Mac, /dev/disk2 is actually a partition on the new disk rather than the disk itself. The upshot is that you have cloned the old disk to a partition on the new disk. So the disk is still 2TB but its first partition (/dev/sda1 on your Linux-based system) is the 300GB clone.

You need to copy disk to disk, not disk to partition. I don't have easy access to a Mac so I cannot advise how you find the appropriate disk device name.

On a Linux-based system you would be looking for /dev/sdX (where X is a letter) rather than /dev/sdXN (where X is a letter and N is a digit).

cat /dev/sda >/dev/sdb    # This will clone disk sda to disk sdb
0

dd isn't aware of what a file system is or what a partition is. Your problem is that resize2fs will only resize the file system not the partition. I recommend using partclone instead of dd but since you already copied the entire disk you just have to recreate the partition.

Confirm that /dev/sda is the right disk. I like to use /dev/disk/by-id/ or /dev/disk/by-label/

sudo fdisk /dev/sda

O Uppercase O! Then save it as backup.mbr

o to create a new DOS table

p Confirm the sector size is 512 and the unit is sector.

n to create a new partition. Confirm the first sector is at 2048 which is where the partition started before.

But this time let the last sector go to the end of the disk.

It already defaulted to Linux filesystem but if you needed to do that its t and code 20.

p To confirm the partition table is how you want it.

w to write those changes to the disk.

I recommend also running partprobe

Finally run resize2fs /dev/sda1

  • It occurs to me you might want to also convert to GPT here which means you'd need to make an EFI system partition and make Debian boot via UEFI. In that case use g instead of o when creating partitions and make the last sector -128M then create another partition at the end of the disk with type 1. – jdwolf Oct 12 '18 at 23:05
0

I've cloned smaller disks to larger ones using dd, then expanded (using gparted) the partition to fill the remaining space on the larger destination disk.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.