Solved GEOM: invalid disklabel

I would like to multi-boot FreeBSD[13.1-RESEASE], OpenBSD[7.1] and Debian[sid] on my SSD.

Before doing it on physical disks, I tried it on VirtualBox on my FreeBSD-13.1-RELEASE.

I installed OpenBSD on ada0p4 with full disk encryption.

To do/practice it twice, I booted into FreeBSD, delete and re-create ada0p4 for another installation.

Despite error messages, ada0p4 deleted and ada0p4 added successfully.

I can re-install OpenBSD on ada0p4 too.

But, I would like to know what are those "GEOM: invalid disklabel" errors and how to fix them?

I still don't see any ill effect though.

Thanks in advance.


Code:
# gpart show -p
=>       40  188743600    ada0  GPT  (90G)
         40    1048576  ada0p1  efi  (512M)
    1048616   56623104  ada0p2  freebsd-zfs  (27G)
   57671720    5242880  ada0p3  freebsd-swap  (2.5G)
   62914600   62914560  ada0p4  openbsd-data  (30G)
  125829160   56623104  ada0p5  linux-data  (27G)
  182452264    4194304  ada0p6  linux-swap  (2.0G)
  186646568    2097072  ada0p7  ms-basic-data  (1.0G)

# gpart delete -i 4 ada0
ada0p4 deleted

# gpart add -t linux-data ada0
GEOM: ada0p4: invalid disklabel.                                                    
GEOM: gptid/f1fb5cad-db84-11ec-8959-080027b3481a: invalid disklabel.
ada0p4 added

# dmesg | grep GEOM
GEOM: ada0p4: invalid disklabel.
GEOM: gptid/1882d6c5-db86-11ec-8959-080027b3481a: invalid disklabel.
GEOM: diskid/DISK-VB9d83c0cb-145f75f5p4: invalid disklabel.
 
gpart(8) doesn't recognize the (ada0p4) "openbsd-data" label, it's not listed as a known label, therefore it's considers as invalid.
But, even though deleting openbsd-data and adding as linux-data, which is a known label, the error persists.

This is how it looks before re-installing OpenBSD.

Code:
# gpart show -p
=>       40  188743600    ada0  GPT  (90G)
         40    1048576  ada0p1  efi  (512M)
    1048616   56623104  ada0p2  freebsd-zfs  (27G)
   57671720    5242880  ada0p3  freebsd-swap  (2.5G)
   62914600   62914560  ada0p4  linux-data  (30G)
  125829160   56623104  ada0p5  linux-data  (27G)
  182452264    4194304  ada0p6  linux-swap  (2.0G)
  186646568    2097072  ada0p7  ms-basic-data  (1.0G)

Someone needs to bother to add the "openbsd-data" label to the source code.
Thanks. It seems harmless error message then. But I wonder how to make it disappear when I don't need/want to use "openbsd-data" disk anymore?
 
Ah, sorry, I overlooked the adding of the "linux-data" partition, got distracted. "openbsd-data" would explain the missing label in the source code, but not "linux-data".

FreeBSD sets in /boot/loader.conf as default
Code:
kern.geom.label.disk_ident.enable="0"
kern.geom.label.gptid.enable="0"

Check if GEOM continues to complain when both are set to "1".
 
Tried using -i on geom add to make sure it overwrites the right entry?
I think you mean gpart add so I tried with it.

Check if GEOM continues to complain when both are set to "1".

I set both of them to 1 in /boot/loader.conf and rebooted but the error persists.

Code:
# gpart delete -i 4 ada0           
ada0p4 deleted     
# gpart add -t linux-data -i 4 ada0           
GEOM: ada0p4: invalid disklabel.
GEOM: gptid/60e45eab-dbe3-11ec-9ed8-080027b3481a: invalid disklabel.
ada0p4 added
 
My experiment continues and found out that the first few part (sectors or block?) of the ada0p4 is the problem. I can avoid the error message by leaving some free space [512B] at the start of the partition. But it might just be a workaround. The problem is still there. Is this because of the doing disk encryption (softraid) with OpenBSD there?


This is the disk layout. I deleted all other partitions.
Code:
# gpart show -p
=>       40  188743600    ada0  GPT  (90G)
         40    1048576  ada0p1  efi  (512M)
    1048616   56623104  ada0p2  freebsd-zfs  (27G)
   57671720    5242880  ada0p3  freebsd-swap  (2.5G)
   62914600  125829040          - free -  (60G)
Simply adding freebsd-ufs partition gave me error. Either gpart add -t freebsd-ufs ada0 or gpart add -t freebsd-ufs -i 4 ada0 gave the same result.
Code:
# gpart add -b 62914600 -t freebsd-ufs -f x ada0
GEOM: ada0p4: invalid disklabel.
GEOM: gptid/536b4929-dc46-11ec-a592-080027b3481a: invalid disklabel.
GEOM: ufsid/628e53b6492f8f3b: invalid disklabel.
ada0p4 added
So, I undo the partitioning.
Code:
# gpart undo ada0
Adding partition by leaving 1 block free space and no error output.
Code:
# gpart add -b 62914601 -t freebsd-ufs -f x ada0
ada0p4 added
This is the disk layout now.
Code:
# gpart show -p
=>       40  188743600    ada0  GPT  (90G)
         40    1048576  ada0p1  efi  (512M)
    1048616   56623104  ada0p2  freebsd-zfs  (27G)
   62914600          1          - free -  (512B)                                                   
   62914601  125829039  ada0p4  freebsd-ufs  (60G)
Commit the changes.
Code:
# gpart commit ada0

geom -t show this weird gptid?

I revert back and tested it. And yes. They are showing the same gptid.

Code:
# gpart add -t freebsd-ufs ada0                                                                   
GEOM: ada0p4: invalid disklabel.                                                                    
GEOM: gptid/afe77b29-dc4a-11ec-a592-080027b3481a: invalid disklabel.                                
GEOM: ufsid/628e53b6492f8f3b: invalid disklabel.                                                    
ada0p4 added

# geom -t | grep ada0p4
  ada0                                           PART       ada0p4                                  
    ada0p4                                       LABEL      gptid/afe77b29-dc4a-11ec-a592-080027b3481a
    ada0p4                                       LABEL      ufsid/628e53b6492f8f3b                  
    ada0p4                                       DEV

# reboot

# dmesg | grep "invalid disklabel"          
GEOM: ada0p4: invalid disklabel.
GEOM: gptid/afe77b29-dc4a-11ec-a592-080027b3481a: invalid disklabel.
GEOM: ufsid/628e53b6492f8f3b: invalid disklabel.
GEOM: diskid/DISK-VB9d83c0cb-145f75f5p4: invalid disklabel.
 
hmmm disklabel ada0?

Oh, OpenBSD partitions are still there. disklabel ada0 results disklabel ada0: /dev/ada0: no valid label found. So I did disklabel ada0p4 .

Code:
# gpart show -p        
=>       40  188743600    ada0  GPT  (90G)
         40    1048576  ada0p1  efi  (512M)
    1048616   56623104  ada0p2  freebsd-zfs  (27G)
   57671720    5242880  ada0p3  freebsd-swap  (2.5G)
   62914600  125829040  ada0p4  freebsd-ufs  (60G)

# disklabel ada0p4                                                                        
# /dev/ada0p4:
16 partitions:
#          size     offset    fstype   [fsize bsize bps/cpg]
  a:   62914560   62914600         ?
  c:  188743680          0    unused        0     0     # "raw" part, don't edit                                                                            
  i:    1048576         40     MSDOS                                                                                                                        
  j:   56623104    1048616   unknown                                                                                                                        
  k:    5242880   57671720   unknown                                                                                                                        
  l:   56623104  125829160    EXT2FS                                                                                                                        
  m:    4194304  182452264   unknown                                                                                                                        
  n:    2097072  186646568     MSDOS                                                                                                                        
partition a: partition extends past end of unit                                                                                                              
partition c: partition extends past end of unit                                                                                                              
disklabel: partition c doesn't cover the whole unit!                                                                                                        
disklabel: An incorrect partition c may cause problems for standard system utilities              
disklabel: partition j: size 0, but offset 1701735777                                              
partition j: offset past end of unit                                                              
partition j: partition extends past end of unit
 
The problem is solved by zeroing out the first few parts of the effected partition with dd .

Code:
# gpart show -p               
=>       40  188743600    ada0  GPT  (90G) 
         40    1048576  ada0p1  efi  (512M) 
    1048616   56623104  ada0p2  freebsd-zfs  (27G) 
   57671720    5242880  ada0p3  freebsd-swap  (2.5G) 
   62914600  125829040  ada0p4  freebsd-ufs  (60G) 
 
# dd if=/dev/zero of=/dev/ada0p4 bs=512 count=32               
32+0 records in 
32+0 records out 
16384 bytes transferred in 0.012140 secs (1349643 bytes/sec) 

# gpart delete -i 4 ada0   
ada0p4 deleted 
                                              
# gpart add -t freebsd-ufs ada0
ada0p4 added 
                                  
# disklabel ada0p4
disklabel: /dev/ada0p4: no valid label found 
                                      
# geom -t | grep ada0p4
  ada0                                           PART       ada0p4 
    ada0p4                                       LABEL      gptid/3ab8db24-dd03-11ec-b13e-080027b3481a 
    ada0p4                                       LABEL      ufsid/628e53b6492f8f3b 
    ada0p4                                       DEV         
                                                  
# reboot

# dmesg | grep "invalid disklabel"
                                    <---- empty
 
Hmm, so what's going on here. Is there a bug in gpart that didn't delete the (OpenBSD) disklabel and then stuffed the linux partition inside of it?
 
Hmm, so what's going on here. Is there a bug in gpart that didn't delete the (OpenBSD) disklabel and then stuffed the linux partition inside of it?
Actually, that is the whole disk layout seen by OpenBSD while installing it. I'll add some comment on that output below. OpenBSD use c to describe the whole partition (at least, it is how I understand).

I think what happen here is OpenBSD store that layout (is it called metadata?) on the very beginning of ada0p4. And I've read somewhere on this forum that gpart(8) don't really do formatting. Formatting is done by newfs(8). gpart(8) seems to be a high level tool which don't really go deep to low level and formatting and deleting things.



Code:
# disklabel ada0p4                                                                       
# /dev/ada0p4:
16 partitions:
#          size     offset    fstype   [fsize bsize bps/cpg]
  a:   62914560   62914600         ?                    # openbsd-data [fstype=RAID]
  c:  188743680          0    unused        0     0     # "raw" part, don't edit                                                                           
  i:    1048576         40     MSDOS                    # EFI                                                                                                   
  j:   56623104    1048616   unknown                    # freebsd-zfs                                                                                                   
  k:    5242880   57671720   unknown                    # freebsd-swap                                                                                                   
  l:   56623104  125829160    EXT2FS                    # linux-data                                                                                                   
  m:    4194304  182452264   unknown                    # linux-swap                                                                                                   
  n:    2097072  186646568     MSDOS                    # ms-basic-data [created for testing purpose]
 
Back
Top