Aligning MBR for ZFS boot help

Peter Maloney peter.maloney at brockmann-consult.de
Thu Mar 14 11:47:20 UTC 2013


On 2013-03-14 10:41, Bruce Evans wrote:
> On Wed, 13 Mar 2013, Cody Ritts wrote:
>
>> So, by setting those CHS values I am:
>>  making the partition table more compatible with other operating
>> systems and BIOSes?
>>  and giving some utilities the CHS stuff they need to function right?
>
> It's not completely clear that S=32 H=64 is portable, but it is what most
> old SCSI BIOSes used.
>
> Also, if the disk already has some partitions with a certain geometry,
> use
> the same geometry for other partitions and don't use fdisk's defaults if
> they differ.
>
> Bruce

Oh man... I thought yeah that -a 1 or -a 2048 should work, but it
doesn't. And then I thought I'd be extra crafty and use dd to directly
write the partition table myself and send that as a solution to you
guys, but even that fails!


Here's writing a 63 alignment mbr to the disk, just to prove dd can do this:

# gdd if=mbr.img of=/dev/md10 bs=512 count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 16.8709 s, 0.0 kB/s

# gpart show md10
=>     63  4194241  md10  MBR  (2.0G)
       63    40950     1  freebsd  (20M)
    41013  4153291        - free -  (2G)

Here's changing the start sector on the first partition to 2048 ;)
Writing to the device works with bs=512, but not bs=1, so we use a file
and bs=1 to do our edits, and then bs=512 to the disk.

# gdd if=<(echo -ne "\x00\x08" ) of=mbr.img bs=1 seek=454
2+0 records in
2+0 records out
2 bytes (2 B) copied, 0.000112023 s, 17.9 kB/s

Here's writing the new 2048 aligned mbr to the disk:

# gdd if=mbr.img of=/dev/md10 bs=1 count=1
gdd: writing `/dev/md10': *Invalid argument*
1+0 records in
0+0 records out
0 bytes (0 B) copied, 21.0247 s, 0.0 kB/s

:O


More information about the freebsd-fs mailing list