Other gpart leaves free space before partition 1 - is this normal?

I have a ZFS pool consisting of two drives in a mirror VDEV. Now I'm replacing one with a larger capacity. So I first add the 3rd (new) drive to the VDEV for resilvering, before I detach the small drive.

However when I partition the new drive in the same way I partitioned my existing drives, I found something different with the new drive - it leaves "- free -" space at the very beginning of the address space.

Here's the command I ran on the new drive (same way I partitioned my other two drives):

Code:
# CREATE GPT PARTITION SCHEME:
gpart create -s gpt ada2

gpart add -t freebsd-boot -a 1m -b 40 -s 512k ada2
gpart add -t freebsd-swap -a 1m       -s 2G   ada2
gpart add -t freebsd-zfs  -a 1m               ada2

# WRITES BOOT CODE TO MBR AND TO BOOT PARTITION:
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 ada2

Here's the result of gpart show - notice how address 40 ~ 2008 are left blank before ada2p1 - which is not the case for the other two drives. Also notice how I made the three partitions of ada0 and ada1 have the same start addresses respectively - which is what I would like the new ada3 partitioned the same way.

Code:
~ gpart show
=>         40  11721045088  ada0  GPT  (5.5T)
           40         1024     1  freebsd-boot  (512K)
         1064          984        - free -  (492K)
         2048      4194304     2  freebsd-swap  (2.0G)
      4196352  11716847616     3  freebsd-zfs  (5.5T)
  11721043968         1160        - free -  (580K)

=>        40  1953525088  ada1  GPT  (932G)
          40        1024     1  freebsd-boot  (512K)
        1064         984        - free -  (492K)
        2048     4194304     2  freebsd-swap  (2.0G)
     4196352  1949327360     3  freebsd-zfs  (930G)
  1953523712        1416        - free -  (708K)

=>        40  7814037088  ada2  GPT  (3.6T)
          40        2008        - free -  (1.0M)
        2048        1024     1  freebsd-boot  (512K)
        3072        1024        - free -  (512K)
        4096     4194304     2  freebsd-swap  (2.0G)
     4198400  7809837056     3  freebsd-zfs  (3.6T)
  7814035456        1672        - free -  (836K)

My question is - is this normal? Why can this happen? Does it affect the ZFS pool's performance or is it considered "misaligned" with the other two drives?

Another question - is there a ZFS command that automatically partition the new drive and mirror the existing drives in a mirror VDEV, so that I don't need to run gpart on the new drive?
 
I had similar situation, and I read that it is normal, and there was explanation why that is normal and why gpart make such partitioning. Unfortunately, I lost that link.
I will never noticed that thing, but running gparted from Linux shows some popup window, kinda "There is some free space (on my FreeBDS disk)...bla bla.. " and asked me if I wanna fix that. BTW, I NEVER accepted to "Fix" from gparted, and FreeBSD is working perfect.
I must clarify that I was not used gparted to make anything for FreeBSD system, that was just an notification when running from Linux on that multiboot computer.
And my partiton scheme looked very similar to Yours (That system was erased, so I can't post You output)
 
  • Thanks
Reactions: klu
You asked to align all partitions on 1MiB boundaries; that's the "-a 1m" switch. If a partition size is not an exact multiple of 1MiB, and because of the size of the partition table itself for the first partition, that means that free space has to be left between partitions. You explicitly asked for the boot partition to be 512KiB, so it can not possible be perfectly aligned at its beginning and end. And it the size of the disk is not an exact multiple of 1MiB, the last partition will have to leave a little free space after it.

This is not at all bad. First, the amount of free space is tiny: You are talking less than 1MiB, a few times, on a ~6TB disk. Second, for performance on disks, the important part is to align partitions on physical block boundaries (physical blocks are often wrongly called "sectors"); since physical blocks on spinning disks are either 512bytes of 4KiB, and on most consumer SSDs are typically powers of two in the range 4KiB to 64KiB, an alignment to 1MiB boundaries is perfect.

Alignment to a large block size (like 1MiB) is a good compromise today; doing any better (performance-wise) requires too much detailed knowledge of the disk drive for practical applications.
 
  • Thanks
Reactions: klu
It's because you asked it to start at the nearest 1 MB (-a 1m) boundary after the 40th physical block on disk (-b 40).

Repartition the drive without the -a or -b option on the first partition, and it will show the first partition starting at the beginning of the disk, free space between it and the second partiton, and the second partition will start at the 1 MB boundary. Use -a on all subsequent partitions to make sure they all line up nicely.

Generally, you don't want to use -a on the first partition. And you don't need to use -b if you are using -a (the a option is really a shorthand for "find a multiple of physical sectors, then start the next one after that using -b internally").

Code:
# CREATE GPT PARTITION SCHEME:
gpart create -s gpt ada2

gpart add -t freebsd-boot -s 512k       ada2
gpart add -t freebsd-swap -s 2G   -a 1m ada2
gpart add -t freebsd-zfs          -a 1m ada2
 
  • Thanks
Reactions: klu
It's because you asked it to start at the nearest 1 MB (-a 1m) boundary after the 40th physical block on disk (-b 40).

Repartition the drive without the -a or -b option on the first partition, and it will show the first partition starting at the beginning of the disk, free space between it and the second partiton, and the second partition will start at the 1 MB boundary. Use -a on all subsequent partitions to make sure they all line up nicely.

Generally, you don't want to use -a on the first partition. And you don't need to use -b if you are using -a (the a option is really a shorthand for "find a multiple of physical sectors, then start the next one after that using -b internally").

Code:
# CREATE GPT PARTITION SCHEME:
gpart create -s gpt ada2

gpart add -t freebsd-boot -s 512k       ada2
gpart add -t freebsd-swap -s 2G   -a 1m ada2
gpart add -t freebsd-zfs          -a 1m ada2

Thanks for the info!
 
Back
Top