0

I have Xubuntu 22.04 installed on my PC, that has two hard disk drives: one HDD 1,5 TB and one SSD 128 GB. I have partiotioned these two disks so that my /home folder is in a partition in HDD and the operating system resides in SSD.

Now, my HDD has shown signs that it is about to fail (checked it with Disks tool). So, I bought a new HDD 2 TB to replace the old one. I connected both HDDs in my PC, started my PC from Live USB (Xubuntu 22.04) and attempted to copy one disk to another using the following command: sudo dd if=/dev/sdc of=/dev/sdb conv=noerror,sync bs=4M status=progress

Took almost 20 hours to complete. When it finished, I attempted to remove the old HDD and restart my PC, but that failed. Seems like something went wrong with copying the filesystems.

Sudo fdisk -l yields the following:

sudo fdisk -l
Disk /dev/loop0: 2.33 GiB, 2498256896 bytes, 4879408 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


Disk /dev/loop1: 4 KiB, 4096 bytes, 8 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


Disk /dev/loop2: 61.89 MiB, 64901120 bytes, 126760 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


Disk /dev/loop3: 155.63 MiB, 163188736 bytes, 318728 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


Disk /dev/loop4: 248.76 MiB, 260841472 bytes, 509456 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


Disk /dev/loop5: 81.26 MiB, 85209088 bytes, 166424 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


Disk /dev/loop6: 43.63 MiB, 45748224 bytes, 89352 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


Disk /dev/sda: 119.24 GiB, 128035676160 bytes, 250069680 sectors
Disk model: KINGSTON SV100S2
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: 0x496cc26d

Device     Boot    Start       End   Sectors  Size Id Type
/dev/sda1  *        2048    206847    204800  100M  7 HPFS/NTFS/exFAT
/dev/sda2         206848  71892991  71686144 34.2G  7 HPFS/NTFS/exFAT
/dev/sda3       71892992  87894015  16001024  7.6G 82 Linux swap / Solaris
/dev/sda4       87894016 250068991 162174976 77.3G 83 Linux


Disk /dev/sdb: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: WDC WD20EZBX-22A
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xc3828d0a

Device     Boot      Start        End    Sectors   Size Id Type
/dev/sdb1  *          2048 1043179519 1043177472 497.4G  7 HPFS/NTFS/exFAT
/dev/sdb2       1043179520 2039566335  996386816 475.1G 83 Linux
/dev/sdb3       2039566336 2930276351  890710016 424.7G  7 HPFS/NTFS/exFAT


Disk /dev/sdc: 1.36 TiB, 1500301910016 bytes, 2930277168 sectors
Disk model: WDC WD15EARS-00M
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: 0xc3828d0a

Device     Boot      Start        End    Sectors   Size Id Type
/dev/sdc1  *          2048 1043179519 1043177472 497.4G  7 HPFS/NTFS/exFAT
/dev/sdc2       1043179520 2039566335  996386816 475.1G 83 Linux
/dev/sdc3       2039566336 2930276351  890710016 424.7G  7 HPFS/NTFS/exFAT


Disk /dev/sdd: 28.91 GiB, 31037849600 bytes, 60620800 sectors
Disk model: USB Flash Drive 
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: gpt
Disk identifier: 6522A0ED-ED48-4313-B710-169E0E898DC2

Device       Start      End  Sectors  Size Type
/dev/sdd1       64  5267231  5267168  2.5G Microsoft basic data
/dev/sdd2  5267232  5275727     8496  4.1M EFI System
/dev/sdd3  5275728  5276327      600  300K Microsoft basic data
/dev/sdd4  5279744 60620736 55340993 26.4G Linux filesystem
xubuntu@xubuntu:~$ 

On /dev/sdb (destination disk) we see the same types of filesystems as on /dev/sdc.

But sudo parted -l yields the following:

sudo parted -l
Model: ATA KINGSTON SV100S2 (scsi)
Disk /dev/sda: 128GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system     Flags
 1      1049kB  106MB   105MB   primary  ntfs            boot
 2      106MB   36.8GB  36.7GB  primary  ntfs
 3      36.8GB  45.0GB  8193MB  primary  linux-swap(v1)
 4      45.0GB  128GB   83.0GB  primary  ext4


Model: ATA WDC WD20EZBX-22A (scsi)
Disk /dev/sdb: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size   Type     File system  Flags
 1      1049kB  534GB   534GB  primary  ntfs         boot
 2      534GB   1044GB  510GB  primary
 3      1044GB  1500GB  456GB  primary


Model: ATA WDC WD15EARS-00M (scsi)
Disk /dev/sdc: 1500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size   Type     File system  Flags
 1      1049kB  534GB   534GB  primary  ntfs         boot
 2      534GB   1044GB  510GB  primary  ext4
 3      1044GB  1500GB  456GB  primary  ntfs


Model: ADATA USB Flash Drive (scsi)
Disk /dev/sdd: 31.0GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name       Flags
 1      32.8kB  2697MB  2697MB               ISO9660    hidden, msftdata
 2      2697MB  2701MB  4350kB               Appended2  boot, esp
 3      2701MB  2701MB  307kB                Gap1       hidden, msftdata
 4      2703MB  31.0GB  28.3GB  ext4

The filesystems on my old disk (1,5TB /dev/sdc) don't seem to be present to my new disk (/dev/sdb).

I have attempted to fix this with fsck. Here are the results:

sudo fsck -y /dev/sdb
fsck from util-linux 2.37.2
e2fsck 1.46.5 (30-Dec-2021)
ext2fs_open2: Bad magic number in super-block
fsck.ext2: Superblock invalid, trying backup blocks...
fsck.ext2: Bad magic number in super-block while trying to open /dev/sdb

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 <device>
 or
    e2fsck -b 32768 <device>

Found a dos partition table in /dev/sdb

Is there any way to fix the filesystems and just use my new disk in place of the old, failing one?

Bonus question: assuming we succeed in fixing the new HDD, can I use Gparted to resize my partitions and take advantage of the extra 500GB or do I risk losing data and/or make the HDD unusable again?

3
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Jul 17 at 17:15
  • 1
    Part of issue is new drive is 4K. 512B/4096B and old drive is Not 4K. 512B/512B. dd would erase any partitions you create in advance on new drive. Better to follow Zeye's answer and create partitions and update fstab with new UUIDs. Also since new drive better to use gpt as long as you do not plan to boot Windows in old BIOS mode from new drive. I have used gpt since 2010 for both Ubuntu BIOS boot and UEFI boot of both Windows & Ubuntu. gpt Advantages & wiki.archlinux.org/title/…
    – oldfred
    Commented Jul 17 at 18:12
  • This might help (at own risk) unix.stackexchange.com/questions/728099/…
    – david
    Commented Jul 18 at 8:42

1 Answer 1

1

Since the folders you are copying are data and not actually portions of the operating system, treat the new HDD as a new thing. Since you're dealing with /home specifically, you'll probably have to make some tweaks after the big data copy. Perhaps instead of /home at the root of the new drive, make it /newhome until the massive copy is complete. Now, use the cp command to perform the copy. There are options on the cp command to preserve ownership etc as the copy is made if that is important. It's very likely in this specific case, some portions of the copy will fail because of error on the old drive. Get everything you can easily get first then work the areas with errors. At least you'll get most of it. If you've got decent backup, you may be able to recover files in the erred portion as well.

You do not have to copy everything with one huge cp command. It is more than likely one or more files are irrecoverable so, divide the copy into multiple large parts then, further divide each copy that fails. Sort of like a binary search for the failing file.

Once you've copied everything to /newhome, it's time to consider how you'd replace the current /home with /newhome. I am curious how that might be done since every ID, even if coming in with a command line interface such as telnet, uses /home. Your question is how to more as much as possible off a failing drive before it's too late.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .