Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.user > #265923

Re: 512e vs 4K sector confusion

From "Alexander V. Makartsev" <avbetev@gmail.com>
Newsgroups linux.debian.user
Subject Re: 512e vs 4K sector confusion
Date 2024-01-14 12:30 +0100
Message-ID <HW6QF-31w6-7@gated-at.bofh.it> (permalink)
References <HW3J7-2ZIb-5@gated-at.bofh.it> <HW3SN-2ZLr-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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
⠈⠳⣄⠀⠀⠀⠀

Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

512e vs 4K sector confusion Andy Smith <andy@strugglers.net> - 2024-01-14 09:10 +0100
  Re: 512e vs 4K sector confusion Andy Smith <andy@strugglers.net> - 2024-01-14 09:20 +0100
    Re: 512e vs 4K sector confusion "Alexander V. Makartsev" <avbetev@gmail.com> - 2024-01-14 12:30 +0100
    Re: 512e vs 4K sector confusion Arno Lehmann <al@its-lehmann.de> - 2024-01-14 12:40 +0100
  Re: 512e vs 4K sector confusion "Thomas Schmitt" <scdbackup@gmx.net> - 2024-01-14 14:30 +0100
    Re: 512e vs 4K sector confusion Andy Smith <andy@strugglers.net> - 2024-01-14 17:20 +0100
      Re: 512e vs 4K sector confusion "Thomas Schmitt" <scdbackup@gmx.net> - 2024-01-14 18:00 +0100
  Re: 512e vs 4K sector confusion Timothy M Butterworth <timothy.m.butterworth@gmail.com> - 2024-01-14 19:20 +0100
  Re: 512e vs 4K sector confusion Stefan Monnier <monnier@iro.umontreal.ca> - 2024-01-15 05:40 +0100
    Re: 512e vs 4K sector confusion Andy Smith <andy@strugglers.net> - 2024-01-15 06:40 +0100
      Re: 512e vs 4K sector confusion Nicolas George <george@nsup.org> - 2024-01-15 22:30 +0100
      Re: 512e vs 4K sector confusion Nicholas Geovanis <nickgeovanis@gmail.com> - 2024-01-15 22:30 +0100
        Re: 512e vs 4K sector confusion Andy Smith <andy@strugglers.net> - 2024-01-16 01:40 +0100
        Re: 512e vs 4K sector confusion Teemu Likonen <tlikonen@iki.fi> - 2024-01-16 17:40 +0100
      Re: 512e vs 4K sector confusion Andy Smith <andy@strugglers.net> - 2024-01-17 08:30 +0100
  Re: 512e vs 4K sector confusion Andy Smith <andy@strugglers.net> - 2024-01-20 22:30 +0100

csiph-web