On 14.01.2024 13:15, Andy Smith wrote:
On Sun, Jan 14, 2024 at 08:01:52AM +0000, Andy Smith wrote:
If necessary and if there is a way, I *can* nuke off the target
machine's "foo" volume group and recreate the RAID array if I have
to make it 512e format. But obviously I'd like some way to move this
disk image and have it still work without having to meddle inside it
much — it is a VM disk.
I think I may be able to use hdparm to reformat these Ultrastar DCs
from 4kn to 512e…

hdparm --set-sector-size 512 --please-destroy-my-drive /dev/sdX

https://wiki.archlinux.org/title/Advanced_Format#Advanced_Format_hard_disk_drives

It is okay to destroy the drive contents as there's nothing working
on there yet given this initial failure.

I think that is the only way this is going to work without mounting
filesystems both sides and using an fs-aware tool like tar|ssh or
rsync… which I don't want to do.

Thoughts?
Weird. I can imagine some wild theories. :)
I think it has something to do with a fact that "disk_image" is a LVM volume and you dd copy "/dev/mapper/VG--name-LV--name" not "/dev/sdc2" . Could it be that "dd" sees source and destination as block devices and copies data by sector? I.e. takes 512b sector and place it to the beginning of 4096b sector and padding the rest 3584b of the sector with zeroes. This calls for some tests. I'd create 1G image test file with dos partition table and a few primary partitions:

   $ dd if=/dev/zero of=./1G-disk-image.bin bs=1M count=1000
   1000+0 records in
   1000+0 records out
   1048576000 bytes (1,0 GB, 1000 MiB) copied, 8,07768 s, 130 MB/s

   ...
   $ /sbin/fdisk -l ./1G-disk-image.bin
   Disk ./1G-disk-image.bin: 1000 MiB, 1048576000 bytes, 2048000 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: 0x143acb59

   Device               Boot   Start     End Sectors  Size Id Type
   ./1G-disk-image.bin1         2048  411647  409600  200M 83 Linux
   ./1G-disk-image.bin2       411648 1435647 1024000  500M 83 Linux
   ./1G-disk-image.bin3      1435648 2047999  612352  299M 83 Linux


And dd copied it the same way to disk with 4k sectors.
Just to see if it will be inconsistent too, without LVM mapper involved.

I'd also try to clone disk to image file first, with say "partclone" utility, "scp" the image file and restore it at remote destination with the same utility after recreating dumped partition table layout using "sfdisk". I did this procedure multiple times successfully, but without 4k sector disks and LVM involvement.


--
With kindest regards, Alexander.

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄⠀⠀⠀⠀

Reply via email to