bug-ddrescue
[Top][All Lists]
Advanced

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

Re: How to clone to a smaller HDD without messing up partitions?


From: Shahrukh Merchant
Subject: Re: How to clone to a smaller HDD without messing up partitions?
Date: Sun, 27 Oct 2019 19:11:51 -0300
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1

Thanks to all for the great suggestions, especially Dr. Anonymous, both of whose suggestions worked perfectly (I tried them both). Robert Backhaus had also previously suggested Method A below in private email.

To summarize:

A. PARTITION AGNOSTIC METHOD (using -s parameter to constrain size of transfer):

Step 1. Run
        fdisk -l
to check the last used sector on the disk (it will be the ending sector number of the last partition on the disk. Since sector numbers start with 0, you have to add at least 1 to this number (call it 123456789) in the -s parameter in the following command.

Step 2.
        ddrescue -f -v -s123456790s /dev/sda /dev/sdb logfile

(In practice, I didn't try to get the sector size exact and rounded up to what in this illustration would be -s130000000s. The "s" at the end is needed to specify "sectors" as the unit, otherwise it defaults to bytes.)

B. PRELOADING MFT METHOD

Step 1. Copy the MBR first, which is the first sector of the disk, Sector 0--this copies the partition structure to the new disk.
        ddrescue -f -v -s1s /dev/sda /dev/sdb logfile0

(Confirmed with lsblk and fdisk that the partition structure correctly appeared on the destination disk after this.)

Step 2. Then copy the actual contents of the partitions.
        ddrescue -f -v /dev/sda1 /dev/sdb1 logfile1
        ddrescue -f -v /dev/sda2 /dev/sdb2 logfile2

NOTES:
-----
1. I tried both methods and the results were exactly the same and the resulting disk booted just fine in both cases. The unallocated space at the end was as expected and I could expand into it or create a new partition normally.

2. In case there is a lot of unallocated space between the 2 partitions (not the case for me, where the 2 partitions were contiguous), Method B seems more efficient as it does not have to copy the unallocated space between partitions. On the other hand, Method A seems more general as Method B seems specific to MFT disks (as mine indeed were) and would not work for GPT disks.

3. I used "fdisk -l" and "lsblk -o NAME,SIZE,FSTYPE,LABEL,MODEL" liberally after each incremental step above to make sure I was understanding what was going on and the changes were consistent with my understanding (they were).

Thanks again, and hope this summary is useful to someone!

Shahrukh

On 2019-10-26 6:06 AM, Dr. Anonymous wrote:
There is one more way to do exactly you want! Without copying any unneeded 
sectors and without determining the exact sizes!
Assuming /dev/sdc to be the source and /dev/sdb to be our destination.
First, copy the MBR (the very first sector):
ddrescue /dev/sdc /dev/sdb -s1s
Then, either reboot the system or anyway make the kernel recognize the new MBR 
of the destination drive.
Then copy the initial partitions to the destination:
ddrescue /dev/sdc1 /dev/sdb1 ~/1.log
ddrescue /dev/sdc2 /dev/sdb2 ~/2.log
That's all.



reply via email to

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