0

I have a virtual disk for my virtual machine (XCP-NG) that has a broken filesystem and I can't repair it because the (virtual) disk somehow seems to be read only. So I want to clone the (broken) virtual disk to a new virtual disk in the hope that I will be able to write to the new disk and repair the filesystem. I tried dd and clonezilla but both seem to require a working filesystem. Is there another utility that just clones the disk bit-by-bit without needing a functioning filesystem?

The physical disk is fine. Other virtual disks that run on the physical disk work.

Thanks in advance
Patryk

5
  • 2
    Surely if you clone a disk with a broken file system bit-by-bit, you clone all the breaks and wind up with another disk with a broken file system. Don't you want to repair the file system first? Commented Aug 20, 2021 at 12:35
  • I can't repair it because the disk is read only. My hope is that I will be able to repair it on the new drive. Commented Aug 20, 2021 at 13:11
  • 1
    You could boot the VM into rescue mode and try a filesystem check/repair within the rescue mode. If that doesn't work you could try ddrescue from that VM's disk to a different image/disk. I haven't tried that with virtual machines yet, though. Commented Aug 20, 2021 at 13:28
  • XCP-NG seems to have quite a number of different storage configurations available. Is your virtual disk thick or thin provisioned? Is the repository containing the virtual disk file- or block-based? Which filesystem type, and are you using shared storage? All these things may have an effect on how to best recover from the filesystem breakage. Commented Aug 20, 2021 at 13:45
  • @Chenmunka it's good practice to make a bitwise clone of a broken filesystem and attempt to repair the clone rather than the original (or if the original was a PITA to clone because it's on failing hardware with lots of read errors, repair a copy of the copy so you don't have to stress the original HW again if you need multiple attempts). That way, if the repair fails or makes things worse, you still have the original to make another attempt. Same applies to a corrupted file: you should attempt to repair a copy of the file, not the original. Commented Aug 21, 2021 at 3:33

1 Answer 1

0

ddrescue did the trick. The command I used was sudo ddrescue --force {origin-partition} {target-partition}

Thanks to eblock.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.