A hard drive with multiple partitions gets dd'ed onto a partition of a second hard drive (partition big enough to fully contain the first hard drive). Is it possible to access the data on the second drive - and if, how?

Edit: For clarification - I guess a better term for the problem would be "nested partition(s)": enter image description here Which also led me to this answer: Is there a way to allow nested partition tables? - my use case would be similar to the last paragraph, and probably a solution would be to use device mapper. But it seems there is no "easier" way to access the data.

  • You can just mount the partition. If you are using a GUI, you can probably just click on it in the file manager.
    – Hermann
    Feb 9, 2022 at 11:21
  • If partition is logical inside an extended then you are using the old MBR(msdos) partitioning scheme. Better to use gpt, but with gpt you have to dd entire drive as GUID are in primary partition table, backup partition table & partition and must stay in sync. Better to just create partition and rsync data, just as you do for your backups and copies to flash drives. Better to use rsync, not dd askubuntu.com/questions/1331348/… & askubuntu.com/questions/545655/…
    – oldfred
    Feb 9, 2022 at 17:15
  • Why not create partition table entries for individual partitions from the source drive and copy them one by one, instead of copying the whole disk as a single partition? Feb 9, 2022 at 18:48

4 Answers 4


Kind of surprised it hasn’t been mentioned yet, but there are two tools that do this natively on Linux.

The first is called partx, and is part of the util-linux software package that is part of (almost) every Linux install in existence. partx -s - /path/to/disk will list all the partitions the kernel could recognize on that disk. A similar syntax with the -a option will tell the kernel to create device nodes for those partitions, while the equivalent with -d will remove said device nodes if they exist. The lone - is needed to force it to treat the path as a disk instead of a partition.

The other tool, inspired by partx, is kpartx. This is part of the block device multipath tooling available for Linux (usually not installed by default, but packaged by all major distributions with a package name like multipath-tools). In contrast to partx, which just pokes at how the kernel handles partition tables, kpartx reads the partition table itself and then creates device-mapper targets for each partition. This allows it to work in more circumstances than partx normally does. Syntax here is kpartx -l /path/to/device to list partitions, -a instead of -l to add them, and -d to remove them.

This is generally more efficient than using an image file and/or a loop device.


I've never seen nested partitions, but why not just use an image file and mount that?

dd if=/dev/disk of=/big/disk/disk.img 

You can then use a loopback to mount it:

losetup /dev/loop0 /big/disk/disk.img
mount /dev/loop0p1 /mnt/disk_partition1
mount /dev/loop0p2 /mnt/disk_partition2

As shown, you can mount individual partitions of a disk image.

  • Image file seems to be a very suitable option, too - thanks.
    – user236012
    Feb 9, 2022 at 13:07

First use losetup -f to determine the free loop device (it will output something like /dev/loop0). Let's call that /dev/loopN.

Then use losetup -P /dev/loopN /dev/<partition_1_device>.

Now the partitions specified by the nested partition table will be accessible as /dev/loopNp1, /dev/loopNp2 etc. You can use those device names to mount them.

To undo the setup (without rebooting), unmount the nested partitions and run losetup -d /dev/loopN.


In my experience, the answer is yes:

I've migrated disks from one machine to another many times using dd and it works the same whether the partitions/volumes were running Windows or Linux.

As long as the whole disk is copied over, including the file allocation tables, I was able to just fire up the disk and access the volumes.

I've used clonezilla as well to make the process more portable and faster than just a straight dd so you might want to check that out if you're dealing with physical machines instead of VMs.

This worked for me in disk replacement scenarios (as long as the BIOS was configured to boot from the new disk), but there's no reason you can't plug the disk in to another machine/VM and mount the volumes like you would any other disk.

I use this command anytime I make changes to the disks if I don't want to reboot the system and the system is usually able to notice the changes. If it doesn't, then a reboot always works.

for disk in /sys/class/scsi_disk/*; 
 do echo '1' > $disk/device/rescan; 

Once the new disk and volumes are operational, i.e. seen by the OS, you can use other utilities to expand the underlying partitions to fill the remaining disk space or create additional partitions/volumes as you wish.

If you're working with LVM volumes, they'll need to be imported into the system. These links might provide additional helpful information:

  • Nice description, but does not answer the question, which was 'how' do access the data.
    – gerhard d.
    Feb 22, 2022 at 11:16

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.