Enlarge freebsd-boot?

Recently a server was upgraded to 11.0-RELEASE from 10.3-RELEASE using freebsd-update. The ZFS type bootloader couldn't be installed due to insufficient space in the freebsd-boot partition. The boot disks are a ZFS mirror as follows:

Code:
=>       34  500118125  ada0  GPT  (238G)
         34         94     1  freebsd-boot  (47K)
        128    2097152     2  freebsd-swap  (1.0G)
    2097280  165150720     3  freebsd-zfs  (79G)
  167248000   67108864     4  freebsd-zfs  (32G)
  234356864    2097152     5  freebsd-zfs  (1.0G)
  236454016  263664143        - free -  (126G)

=>       34  500118125  ada1  GPT  (238G)
         34         94     1  freebsd-boot  (47K)
        128    2097152     2  freebsd-swap  (1.0G)
    2097280  165150720     3  freebsd-zfs  (79G)
  167248000   67108864     4  freebsd-zfs  (32G)
  234356864    2097152     5  freebsd-zfs  (1.0G)
  236454016  263664143        - free -  (126G)

I would like to permanently borrow space from the swap in order to enlarge the freebsd-boot partition to 512K. Looking at another server with a fresh 11.0-RELEASE installed, it shows the following partition information:

Code:
root@squid:/root# gpart show
=>       34  488397101  ada0  GPT  (233G)
         34       1024     1  freebsd-boot  (512K)
       1058    4194304     2  freebsd-swap  (2.0G)
    4195362  484201773     3  freebsd-zfs  (231G)

How do I modify the freebsd-boot partition so that it ends at 1024 and the freebsd-swap partition begins at 1058? What are the steps I need to perform to accomplish this? Boot into LiveCD, delete both the freebsd-boot partition and the freebsd-swap partition, recreate these using the correct parameters as follows:

Code:
# gpart delete -i 1 ada0
# gpart delete -i 1 ada1
# gpart delete -i 2 ada0
# gpart delete -i 2 ada1
# gpart show                      # confirm deletions
# gpart add -t freebsd-boot -b 34 -s 512K -i 1 ada0
# gpart add -t freebsd-boot -b 34 -s 512K -i 1 ada1
# gpart add -t freebsd-swap -b 1058 -s ???? -i 2 ada0
# gpart add -t freebsd-swap -b 1058 -s ???? -i 2 ada0
# gpart show                      # confirm additions
# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ada0
# gpart bootcode -b /mnt2/boot/pmbr -p /mnt2/boot/gptzfsboot -i 1 ada1

As you can see, I am very unsure as to the exact size that needs to be allocated for the swap partition. If I recall, a sector is 512 bytes. To arrive at the needed number of sectors, I subtract 1058 from 2097152 arriving at 2096094 sectors. Multiply that by 512 to come up with 1073200128 as the desired size. Correct?

Or is gpart smart enough to fill it up without assigning it the size parameter?

Side note: I have noted that the swap is little used by the server in question so I believe shrinking the swap file should not be of concern. Correct me if that is not the case.

Another side note: Are there any plans to enlarge the ZFS bootloader for 12.0-RELEASE? I am quite sure we will continue to use this server for quite a while so I aim to upgrade to at least 12.0-RELEASE and possibly beyond. I would like to have a freebsd-boot partition large enough for future releases without the need to adjust!

~Doug
 
According to gpart(8), the size can be omitted and will automatically be calculated. As for the math, it should be

2097280 - 1058 = 2096222
2096222 sectors / 2 sectors per KiB = 1048111 KiB

Remember that the second column in gpart is the size of the partition, but you want to subtract from the start of the next partition.

As for your second side note, I don't know anything about where bootloader development is headed, but 512K is a lot of space considering the present size of /boot/gptzfsboot (~83K on my machine). There is always the option of writing the second stage boot code into the ZFS metadata area, but I don't think that will ever catch on.
 
Back
Top