Aligning MBR for ZFS boot help

Adam Nowacki nowakpl at platinum.linux.pl
Sun Mar 10 22:57:36 UTC 2013


I don't think zfsboot is aware of BSD disklabel (offsets other than 0 
won't boot). Is there any reason you are using BSD disklabel and not two 
partition MBR?

I also don't think there is any merit in aligning to 1MiB. Most ZFS IOs 
will be aligned to sector size (ashift). Unless ZFS pool is created with 
higher ashift then the 63 sector offset is as good as any.

gpart create -s mbr ada0
gpart add -s 52862M -t freebsd ada0
gpart add -s 8G -t freebsd ada0

gpart bootcode -b /boot/mbr ada0
dd if=/boot/zfsboot of=/dev/ada0s1 count=1
dd if=/boot/zfsboot of=/dev/ada0s1 skip=1 seek=1024

zpool create ... /dev/ada0s1
swapon /dev/ada0s2

If you still want that 1MB alignment then you will have to (as explained 
by others) align the MBR partition.

On 2013-03-10 06:12, Cody Ritts wrote:
> Hello all,
>
> I am really struggling to understand what is going on, if anyone could
> tell me where I am going wrong, I would greatly appreciate it.
>
> I have a new intel atom appliance that will not boot from a GPT
> partition table.  It came with an SSD, so I am trying to align it to 1MB
> for the erase block size.
>
> All of these commands are being run from a 9.1-RELEASE-amd64-memstick
>
>
> These commands partition the drive, the system boots just fine:
>> gpart create -s mbr ada0
>> gpart add -t freebsd ada0
>> gpart create -s bsd ada0s1
>> gpart add -s 52862M -t freebsd-zfs  ada0s1
>> gpart add -s 8G  -t freebsd-swap ada0s1
>> gpart set -a active -i 1 ada0
>> gpart bootcode -b /boot/mbr ada0
>> dd if=/boot/zfsboot of=/dev/ada0s1 count=1
>> dd if=/boot/zfsboot of=/dev/ada0s1a skip=1 seek=1024
>
> This is the gpart print output of those commands
>> =>       63  125045361  ada0  MBR  (59G)
>>          63  125045361     1  freebsd  [active]  (59G)
>>
>> =>        0  125045361  ada0s1  BSD  (59G)
>>           0  108261376       1  freebsd-zfs  (51G)
>>   108261376   16777216       2  freebsd-swap  (8.0G)
>>   125038592       6769          - free -  (3.3M)
>
> Here is my disk info
>> root@:/root # diskinfo -v ada0
>> ada0
>>     512             # sectorsize
>>     64023257088     # mediasize in bytes (59G)
>>     125045424       # mediasize in sectors
>>     0               # stripesize
>>     0               # stripeoffset
>>     124053          # Cylinders according to firmware.
>>     16              # Heads according to firmware.
>>     63              # Sectors according to firmware.
>
> 125045361 + 63 = 125045424
> So gpart is for sure printing sectors.
> freebsd-zfs starts at sector 63
>
> So, I need that freebsd-zfs slice to start at 1MB
> 1MB = 2048s
> 2048 - 63 = 1985
> so if I add an offset to my slice:
>> gpart add -b 1985 -s 52862M -t freebsd-zfs ada0s1
>
> should start me at 2048.
>> =>       63  125045361  ada0  MBR  (59G)
>>          63  125045361     1  freebsd  [active]  (59G)
>> =>        0  125045361  ada0s1  BSD  (59G)
>>           0       1985          - free -  (992k)
>>        1985  108261376       1  freebsd-zfs  (51G)
>
> BUT, when i boot, I get this:
>> zfsboot: No ZFS Pools located, can't boot
>
> I think remember reading that freebsd-zfs had to be the first slice (I
> cannot remember where i read that).  And it apparently does not think an
> offset is funny.
>
> So, that leaves me with trying to adjust my MBR partition, so I start
> over and run:
>> gpart add -b 1985 -t freebsd ada0
>
> but that gives me:
>> =>       63  125045361  ada0  MBR  (59G)
>>          63       1953        - free -  (976k)
>>        2016  125043408     1  freebsd  (59G)
>
> HHHMMMMM????  well, 2016 - 1953 = 63  coincidence?  i doubt it, but I
> dont get it.
>
> Poking around on the internet, it looks like gpart is possibly enforcing
> geometry boundaries? so I do the following:
>
>> sysctl kern.geom.part.check_integrity=0
>> root@:/root # gpart add -a 1m -t freebsd ada0
>> ada0s1 added
>> root@:/root # gpart show
>> =>       63  125045361  ada0  MBR  (59G)
>>          63       2016        - free -  (1M)
>>        2079  125042652     1  freebsd  (59G)
>>   125044731        693        - free -  (346k)
>
> Obviously still didnt work.
>
>
> I try a 10MB offset.
> 10MB = 20480s
> 20480-63  = 20417s
>> gpart add -b 20417 -t freebsd ada0
>> =>       63  125045361  ada0  MBR  (59G)
>>          63      20412        - free -  (10M)
>>       20475  125024949     1  freebsd  (59G)
>
> It is still just a few sectors off.  So what if i let gpart
> automatically align it.
>
>> gpart add -a 1m -t freebsd ada0
>
>> =>       63  125045361  ada0  MBR  (59G)
>>          63       2016        - free -  (1M)
>>        2079  125042652     1  freebsd  (59G)
>>   125044731        693        - free -  (346k)
>
>
> And 2079 is still != 2048.
>
> I have tried adjusting those numbers one by one, and it just hops around
> the number I am looking for.  I have tried adding partitions in-front of
> it, setting the alignment to 1s, and adjusting the size.  I cannot get
> it to land on 2048.
>
> It does boot with the padding in the MBR table, but I don't think it is
> aligned.  Maybe it is aligned, and I just dont know any better.
>
> I am at a loss.
>
> Any suggestions would be greatly appreciated.
>
> Thanks,
>
> Cody
> _______________________________________________
> freebsd-fs at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-fs
> To unsubscribe, send any mail to "freebsd-fs-unsubscribe at freebsd.org"



More information about the freebsd-fs mailing list