How to Resize Partitions After DD Clone to Larger Drive in Linux: Fixing Unallocated Space Issues


3 views

When you use dd to clone a smaller drive to a larger one, the partition table gets copied exactly as-is from the source drive. This means:

  • The original partition boundaries remain unchanged
  • All additional space shows as unallocated
  • Traditional tools like fdisk may not automatically recognize available space

First, let's examine the exact situation with lsblk and parted:


sudo lsblk
sudo parted -l

This will show the actual disk geometry versus what's allocated to partitions. In your case, the output shows about 500GB of unused space beyond the last partition.

Method 1: Expanding the Last Partition

For modern Linux systems using GPT partitions:


sudo gdisk /dev/sda
# In gdisk:
# p (print partitions)
# d (delete last partition)
# n (create new partition)
# Use default values to maximize space
# w (write changes)

Then resize the filesystem (ext4 example):


sudo resize2fs /dev/sda11

Method 2: Creating a New Partition

Sometimes it's better to keep the original partitions intact and create a new one in the empty space:


sudo fdisk /dev/sda
# In fdisk:
# n (new partition)
# p (primary)
# Accept default sector start
# Accept default sector end (max available) 
# w (write changes)

Format the new partition:


sudo mkfs.ext4 /dev/sda12
  • MSDOS vs GPT: Older systems using MSDOS partition tables are limited to 2TB. Consider converting to GPT if dealing with larger drives:
    sudo gdisk /dev/sda
    

    Then enter 'w' to convert (data will be preserved)

  • Filesystem corruption: Always run fsck after resizing:
    sudo e2fsck -f /dev/sda11
    
  • LVM considerations: If using LVM, you'll need to extend the physical volume first:
    sudo pvresize /dev/sdaX
    sudo lvextend -r -l +100%FREE /dev/mapper/vg-root
    

For graphical users, these can simplify the process:


sudo apt install gparted
gparted

Or for more advanced scenarios:


sudo apt install partitionmanager

When you use dd to clone a smaller drive to a larger one, Linux sees the original partition table exactly as it was on the source device. The disk geometry (heads, sectors, cylinders) gets copied verbatim, leaving the additional space unallocated.

# Original disk layout copied via dd
Disk /dev/sda: 600.1 GB, 600127266816 bytes
255 heads, 63 sectors/track, 72961 cylinders
Total 1172123568 sectors

The key issue lies in the extended partition (sda4 in your case) which acts as a container for logical partitions. The partition table doesn't automatically expand to fill available space, even if the physical disk is larger.

1. Backup your partition table first:

sfdisk -d /dev/sda > parttable_backup.txt

2. Delete the extended partition (sda4):

fdisk /dev/sda
Command: d
Partition number: 4

3. Recreate the extended partition using all available space:

Command: n
Partition type: e
First sector: (use default)
Last sector: (use default)

4. Recreate your logical partitions within the new extended partition:

Command: n
First sector: (specify start)
Last sector: +size (e.g., +10G for 10GB)

For modern systems, parted often handles large disks better:

parted /dev/sda
(parted) print free
(parted) resizepart 4 100%
(parted) quit

Then resize the filesystem (for ext4):

resize2fs /dev/sda4

If you're using LVM, the process is simpler:

pvresize /dev/sdaX
lvextend -l +100%FREE /dev/mapper/vg-root
resize2fs /dev/mapper/vg-root
  • Always backup critical data before partition operations
  • Consider using gdisk instead of fdisk for GPT partition tables
  • For production systems, test the procedure on a non-critical system first