Duplicating partitions to a larger drive #ZFS #FreeBSD

As I was writing a different blog post, I came across this interesting situation. I couldn’t create the same partition layout on the new drive.

This is the existing drive:

root@r730-04:~ # gpart show ada0
=>       40  242255584  ada0  GPT  (116G)
         40     532480     1  efi  (260M)
     532520       2008        - free -  (1.0M)
     534528   16777216     2  freebsd-swap  (8.0G)
   17311744  224942080     3  freebsd-zfs  (107G)
  242253824       1800        - free -  (900K)

root@r730-04:~ # 

I started to duplicate the layout on the new drive:

root@r730-04:~ # gpart create -s gpt da0
da0 created
root@r730-04:~ # gpart add -t efi -s 260M da0
da0p1 added
root@r730-04:~ # gpart add -t freebsd-swap -s 8G -a 4k da0
da0p2 added
root@r730-04:~ # gpart show da0
=>        40  1953525088  da0  GPT  (932G)
          40      532480    1  efi  (260M)
      532520    16777216    2  freebsd-swap  (8.0G)
    17309736  1936215392       - free -  (923G)

root@r730-04:~ # 

So why no 1M free between partition 1 and 2?

I can do this instead (after destroying the partitions on da0, not shown here):

root@r730-04:~ # gpart backup ada0 | gpart restore da0
root@r730-04:~ # gpart show da0
=>        34  1953525101  da0  GPT  (932G)
          34           6       - free -  (3.0K)
          40      532480    1  efi  (260M)
      532520        2008       - free -  (1.0M)
      534528    16777216    2  freebsd-swap  (8.0G)
    17311744   224942080    3  freebsd-zfs  (107G)
   242253824  1711271311       - free -  (816G)

root@r730-04:~ # 

Next, I resize the last partition to use up what is availble:

root@r730-04:~ # gpart resize -i 3 -a 4k da0
da0p3 resized
root@r730-04:~ # gpart show da0
=>        34  1953525101  da0  GPT  (932G)
          34           6       - free -  (3.0K)
          40      532480    1  efi  (260M)
      532520        2008       - free -  (1.0M)
      534528    16777216    2  freebsd-swap  (8.0G)
    17311744  1936213384    3  freebsd-zfs  (923G)
  1953525128           7       - free -  (3.5K)

I’ll go with this one.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

Leave a Comment

Scroll to Top