[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Why start the first partition at 2 MIB, why not at any multiple of 4096 bytes ...



On 2020-09-11 07:21, David Wright wrote:
On Thu 10 Sep 2020 at 16:15:05 (-0700), David Christensen wrote:
On 2020-09-09 23:02, David wrote:
On Thu, 10 Sep 2020 at 11:26, David Christensen <dpchrist@holgerdanske.com> wrote:
On 2020-09-09 08:03, David Wright wrote:
... having been bitten by
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=923561

2020-09-10 14:01:58 root@tinkywinky ~
# parted /dev/disk/by-id/ata-ST3300622AS_******** unit s print free
Error: The backup GPT table is corrupt, but the primary appears OK, so
that will be used.

I don't know what might have got your disk into this state, but
I'm happy that you got it fixed. My own strategy would have been
to use gdisk (my preferred partitioning program) to rewrite the
backup table from the main table (command r for the recovery menu,
then d).

Thank you for the pointer. I will look at gdisk(8) the next time I have a need that I cannot figure out.


I don't think the bug affects ordinary 512/512 disks, but only
Advanced Format ones with larger block sizes, and then only if
"they" also supply an erroneous I/O value, eg:

Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes

It's possible that this only occurs with USB disks, too.
The partition can be 1MB aligned, but cryptsetup is fooled into
setting the wrong alignment, eg:

device-mapper: table: 254:1: adding target device sdb2 caused an alignment inconsistency:
physical_block_size=4096, logical_block_size=512, alignment_offset=0, start=33553920

which was produced by this partition:

/dev/sdb2  1302349824 1953521663  651171840 310.5G  c W95 FAT32 (LBA)

1302349824/2048
635913.0


So, as my notes show, for the simple life, I always create
partitions with 2MB alignment regardless of future use¹,
and always add  --align-payload 2048 to my cryptsetup
commands. This option is benign because it's the default
when the kernel doesn't supply a value. The man page says
to prefer --offset, but as I know nothing about what any
of these options actually do, I don't use --offset just
because there's no default value given for it. (I suspect
it may be the same as for --align-payload.)

¹ I don't worry about the initial BIOS boot partition.

That sounds like some hard-won knowledge. I hope they fix the bug before I stumble into it.


David


Reply to: