# Upgrade 8.2 -> 9.0 : Boot partition table corrupt ?



## ericmacmini (Jan 14, 2012)

After some struggle I managed to finish the upgrade from R8.2 to R9.0 process.

Adding the following option line in /etc/loader.conf was the main thing....

```
kern.geom.part.check_integrity="0"
```

I am using gmirror, but with gpart show I have following problem:


```
=>       63  976773104  mirror/gm0  MBR  (465G) [CORRUPT]
         63  976773105           1  freebsd  [active]  (465G)

=>        0  976773105  mirror/gm0s1  BSD  (465G)
          0    2097152             1  freebsd-ufs  (1.0G)
    2097152    2097152             2  freebsd-swap  (1.0G)
    4194304   10485760             4  freebsd-ufs  (5.0G)
   14680064    4194304             5  freebsd-ufs  (2.0G)
   18874368  957898737             6  freebsd-ufs  (456G)
```

I tried:


```
sudo /sbin/gpart bootcode -b /boot/pmbr mirror/gm0
gpart: table 'mirror/gm0' is corrupt: Operation not permitted
```

What's the best way to correct the partition table ? Thanks in advance

I filed an official Problem Report, because it's probably not so easy....


----------



## varda (Jan 17, 2012)

You're doing something wrong by trying to place pmbr (gpt boot loader) on device in use and labeled as MBR. Probably you need first to backup data. Then step by step remove BSD labels, then MBR partition. And only then partition it to GPT.

Also there always will be conflict because GPT stores it secondary backup table at the last block of disk. And GEOM sheme places own metadata at the last block of storage device.

You need first to create GEOM device on physical drive (in your case gmirror) and then divide this created device with gpart. gm0 --> gpart. Then there will be gmirror metada on last sector of targeted drive and GPT backup table on last block of gmirror.

Also you will get every boot complains from boot loader that there's no secondary GPT table. But everything will work.

You've been warned.


----------



## wblock@ (Jan 17, 2012)

varda said:
			
		

> You're doing something wrong by trying to place pmbr (gpt boot loader) on device in use and labeled as MBR. Probably you need first to backup data. Then step by step remove BSD labels, then MBR partition. And only then partition it to GPT.
> 
> Also there always will be conflict because GPT stores it secondary backup table at the last block of disk. And GEOM sheme places own metadata at the last block of storage device.
> 
> You need first to create GEOM device on physical drive (in your case gmirror) and then divide this created device with gpart. gm0 --> gpart. Then there will be gmirror metada on last sector of targeted drive and GPT backup table on last block of gmirror.



While I have not heard of data loss from that layout, it's possible.  And of course you lose the ability to restore the GPT table.  Visually:



> Also you will get every boot complains from boot loader that there's no secondary GPT table.



Yes, because GPT, by definition, puts the backup partition table at the end of the *drive*.  So a neater way to do this is to use gpart(8) to create identical partitions on two drives, then use gmirror(8) to mirror those.  Since GEOM does not put its metadata at the end of the drive but at the end of the logical device it creates, it will leave the GPT backup table alone.

gmirror With Disk Partitions shows creating a split-filesystem layout with a mirror for each filesystem.  Creating one big filesystem like FreeBSD-9 does by default is the same, only simpler.


----------

