[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-ddrescue] How to restore just a single partition of a multi-par

From: Antonio Diaz Diaz
Subject: Re: [Bug-ddrescue] How to restore just a single partition of a multi-partition image file?
Date: Wed, 23 Jan 2019 15:30:11 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i586; en-US; rv: Gecko/20110420 SeaMonkey/2.0.14

Subject: Re: Bug-ddrescue Digest, Vol 151, Issue 8
From: "Joe Kickman" <address@hidden>
Date: Tue, 22 Jan 2019 17:36:44 +0300
To: <address@hidden>

Hello, Shahrukh Merchant!
There really IS a simple way to write a single partition from a whole drive image to the place you want using ddrescue. First, look at the partition table of the image and that of the drive that has enough space to fit the needed partition.
On Unix-like systems use something like this:
sudo fdisk /path/fulldrive.img
It'll show the partitions, their starting sectors and their length. Usually, C: starts in sectors 63, 2048 or 206848. Let's assume it starts at sector 206848 and is 400000000 sectors long.
Then do the same with your drive:
sudo fdisk /dev/sda
You will see the last sector occupied by existing partitions. For example, it is 2419999999 (1.21 Tb used).
So, from the sector 2420000000 the drive space is not used by partitions.
You'd better add 2048 sectors to that value and then write there (starting from sector 2420002048) your partition using something like this: sudo ddrescue /path/fulldrive.img /dev/sda ~/200g-copy --ask -f -i206848s -s400000000s -o2420002048s
-o means the offset in the output file, here it is 2420002048 sectors.
-s is the size of the partition you are cloning, here it is 400 million sectors.
-i is the offset in the input file (your full drive image), 206848 sectors.

There is also another way, more safe.
Create an empty/raw partition on the free space of your disk. You may use fdisk etc. Its size must be (better) equal to or (safe, but not recommended) greater than the size of needed partition in the disk-image-file. List the partition table again using fdisk:
sudo fdisk /dev/sda
and remember the partition name (let's assume it is /dev/sda7)
Then use ddrescue:
sudo ddrescue /path/fulldrive.img /dev/sda7 ~/200g-copy --ask -f -i206848s -s400000000s

Also you can somehow mount a whole drive image without mounting its partitions. Then use something like this (I've never done that, so I am not sure about the syntax of the name of the partitions in the case you mounted fulldrive.img as a loop device. Maybe someone else or Google can help you. Here I assumed /dev/loop1 to be your mounted fulldrive image, its partition table is MBR, not GPT. And /dev/loop1p2 to be its second partition):
sudo ddrescue /dev/loop1p2 /dev/sda7 ~/200g-copy --ask -f

There is also a non-GNU way, using proprietary, but free for personal use program, DMDE. It is a disk editing and partition manipulting program with simple GUI, that has a feature to copy any range of sectors from images or devices to other or even the same images or devices. Also, it can help you to reconfigure your partition table, convert MBR to GPT and vice versa, etc. Free version is not very friendly to copy from damaged sources, so I use ddrescue to make clones or images; and DMDE to manipulate partition tables, bootsectors, FAT or MFT records, etc.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]