# Running gpart boot code after upgrade zfs pool to feature flag?



## gregober (Nov 7, 2013)

Hello, 

I have just successfully upgraded my server from 9.1 to 9.2 and activated the latest feature flag for my zpool. 


```
tube:root 21:04:53 /root # zpool upgrade -a 
This system supports ZFS pool feature flags.

Successfully upgraded 'zroot' from version 28 to feature flags.
Enabled the following features on 'zroot':
  async_destroy
  empty_bpobj
  lz4_compress

If you boot from pool 'zroot', don't forget to update boot code.
Assuming you use GPT partitioning and da0 is your boot disk
the following command will do it:

        gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0
```

I really don't know if I need to issue this command. I have tried to figure out by reading the gpart manual but it is not 100% clear to me. My gpart configuration is as follows:

```
tube:root 21:11:05 /usr/ports/ports-mgmt/poudriere screen # gpart show
=>        34  1677721533  da0  GPT  (800G)
          34         128    1  freebsd-boot  (64k)
         162           6       - free -  (3.0k)
         168     8388608    2  freebsd-swap  (4.0G)
     8388776  1669332784    3  freebsd-zfs  (796G)
  1677721560           7       - free -  (3.5k)

=>       63  113246145  da1  MBR  (54G)
         63  113242122    1  freebsd  [active]  (54G)
  113242185       4023       - free -  (2M)

=>        0  113242122  da1s1  BSD  (54G)
          0    4194304      1  freebsd-ufs  (2.0G)
    4194304    8388608      2  freebsd-swap  (4.0G)
   12582912    4194304      4  freebsd-ufs  (2.0G)
   16777216   31457280      5  freebsd-ufs  (15G)
   48234496   65007626      6  freebsd-ufs  (31G)
```
Shall I run the command provided or not?

`gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0`

Any help will be welcome since I really don't want to mess up with my server. 

Thanks.


----------



## gkontos (Nov 7, 2013)

gregober said:
			
		

> Shall I run the command provided or not ?



Every time you upgrade the zpool version of a bootable drive you should ALWAYS update the boot code. 

So, yes run the command!

PS From 9.1 to 9.2 is not necessary. But if you don't update the boot code you may eventually end up with a system that does not boot.


----------



## gregober (Nov 7, 2013)

```
tube:root 22:33:06 /root screen # gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 da0
bootcode written to da0
```

All went right and smooth. I didn't reboot yet though.  

Thx Thanks for your support.


----------



## gqgunhed (Nov 12, 2013)

Hi @gregober,

I have a system with four harddrives as a RAID 10 via ZFS (two ZFS mirrors attached to each other), so two boot drives. These are ad1 and ad2, as ad0 is an SSD as cache device. The SSD is attached to the mainboard 6G 6 Gb/s SATA port 1 (port 2 left blank) where the spindle-HDDs are attached to ports 3-6 3G 3 Gb/s SATA ports.


```
ad0 - zpool cache device
ad1 - zfs mirror0 1st drive  <-- bootcode needs to be upgraded
ad2 - zfs mirror0 2nd drive  <-- bootcode needs to be upgraded
ad3 ...
```

I did not upgrade my zpool in the first place to see if there are any problems during the upgrade. A few days later I upgraded my ZFS from v28 to version 5000 with feature flags and rebooted, forgetting the manual boot code update. I could not boot until I updated the bootcode manually (via USB live image) for hard drives.

So YES, update your bootcode manually for the correct hard drives, in my case (ad0 is the zpool cache):

```
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ad1
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ad2
```

If you do not upgrade the boot code for both mirrored hard drives and your first drive fails you will get a bootcode error and will not be able to boot your system until bootcode is upgraded.


----------



## gregober (Nov 12, 2013)

Very useful to have detailed information about each drive. Because I have another system with more or less similar configurations. 

Thx Thanks.


----------

