You are not logged in.

#1 2014-03-12 17:27:56

Danio
Member
Registered: 2010-10-08
Posts: 4

Cloned harddrive has unknown partition table

Hi all,

I've followed this wiki article on how to clone a full disk: https://wiki.archlinux.org/index.php/Disk_Cloning.
Specifically:

dd if=/dev/sdb of=/dev/sdc bs=4096 conv=notrunc,noerror

The drive itself only has one partition that is encrypted with LUKS.
dd finished copying everything over so naturally I wanted to verify that everything works as expected on the cloned harddrive.
Now I've rebooted the machine to make sure that the kernel detects the partition table changes, but there's still something strange going on.
fdisk -l can see the partition table fine, but parted cannot. Here's the output:

$ sudo fdisk -l
Disk /dev/sdc: 931.5 GiB, 1000194400256 bytes, 1953504688 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: 0x36948ce8

Device    Boot Start        End    Blocks  Id System
/dev/sdc1       2048 1953525167 976761560  83 Linux
$ sudo parted /dev/sdc print
Error: Can't have a partition outside the disk!
Model: Samsung M3 Portable (scsi)
Disk /dev/sdc: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: unknown
Disk Flags:

Strange as it is, I can open and mount the encrypted partition and see the files:

$ sudo cryptsetup open --type luks /dev/sdc1 crypt2
$ sudo mount -t xfs /dev/mapper/crypt2 /mnt/crypt2/
$ ls -l /mnt/crypt2/

I'm using XFS so I wanted to try and run a filesystem check on it. After unmounting the partition I run:

$ sudo umount /mnt/crypt2/
$ sudo xfs_repair -n /dev/mapper/crypt2
Phase 1 - find and verify superblock...
xfs_repair: error - read only 0 of 512 bytes

Note that crypt2 is still open and shows up in fdisk -l. So XFS can't find the superblock to check the filesystem but I can somehow still mount it just fine? What am I missing here? I'm sure it's just a stupid oversight on my part, so apologies in advance... smile

Oh, here's the output on xfs_repair -n  on the old harddrive:

Phase 1 - find and verify superblock...
Phase 2 - using internal log
        - scan filesystem freespace and inode maps...
        - found root inode chunk
Phase 3 - for each AG...
        - scan (but don't clear) agi unlinked lists...
        - process known inodes and perform inode discovery...
        - agno = 0
        - agno = 1
        - agno = 2
        - agno = 3
        - process newly discovered inodes...
Phase 4 - check for duplicate blocks...
        - setting up duplicate extent list...
        - check for inodes claiming duplicate blocks...
        - agno = 0
        - agno = 3
        - agno = 1
        - agno = 2
No modify flag set, skipping phase 5
Phase 6 - check inode connectivity...
        - traversing filesystem ...
        - traversal finished ...
        - moving disconnected inodes to lost+found ...
Phase 7 - verify link counts...
No modify flag set, skipping filesystem flush and exiting.

Offline

#2 2014-03-13 17:06:21

Danio
Member
Registered: 2010-10-08
Posts: 4

Re: Cloned harddrive has unknown partition table

Okay so I think I found the problem. I found this link when researching the error that parted threw at me: http://askubuntu.com/questions/48717/ho … tion-table

And indeed, the new HDD has less sectors than the original, and the first partition ends outside of that.

$ sudo fdisk -l

Disk /dev/sdb: 931.5 GiB, 1000204886016 bytes, 1953525168 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: 0x36948ce8

Device    Boot Start        End    Blocks  Id System
/dev/sdb1       2048 1953525167 976761560  83 Linux


Disk /dev/sdc: 931.5 GiB, 1000194400256 bytes, 1953504688 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: 0x36948ce8

Device    Boot Start        End    Blocks  Id System
/dev/sdc1       2048 1953525167 976761560  83 Linux

Since the whole partition is encrypted, I don't want to risk simply resizing the partition. I think I'll just go ahead and make a new partition, encrypt it and copy the files manually. Unless anyone else has some input on this for me?

Offline

Board footer

Powered by FluxBB