Expanding single drive to two drive mirror?

Status
Not open for further replies.

mjws00

Guru
Joined
Jul 25, 2014
Messages
798
I went through this same scenario recently and it went smoothly. I started with a single 3TB WD Red that I set up using the gui. I then copied the data off of my other 3TB WD Red to the new pool. After the data was moved I put the 2nd drive in the server and manually partitioned it in a similar way to the post mjws00 linked to.

The only problem I ran in to was the drive I set up using the gui (9.2.1.8 at the time) was NOT using 4k aligned partitions. I don't get why all of these CLI posts about partitioning drives recommend 4k aligned (the -a 4096 in gpart) when the gui does not partition drives 4k aligned. This caused be a fair bit of grief at the time when I went to attach the new drive to the pool.

Seeing as how you already have 1 drive running in freenas, follow the link mjws00 posted. Only make sure to omit the '-a 4096' from the gpart commands. The instructions in that link show how to set up 2 drives from scratch using the CLI. You only need to do 1 drive.
The posts recommend -4k aligned because it is in the code. Here is the snippet from notifier.py

Code:
commands = []
        commands.append("gpart create -s gpt /dev/%s" % (devname, ))
        if swapsize > 0:
            commands.append("gpart add -a 4k -b 128 -t freebsd-swap -s %d %s" % (swapsize, devname))
            commands.append("gpart add -a 4k -t %s %s" % (type, devname))
        else:
            commands.append("gpart add -a 4k -b 128 -t %s %s" % (type, devname))
 

kjp4756

Contributor
Joined
Feb 11, 2014
Messages
102
The posts recommend -4k aligned because it is in the code. Here is the snippet from notifier.py

Code:
commands = []
        commands.append("gpart create -s gpt /dev/%s" % (devname, ))
        if swapsize > 0:
            commands.append("gpart add -a 4k -b 128 -t freebsd-swap -s %d %s" % (swapsize, devname))
            commands.append("gpart add -a 4k -t %s %s" % (type, devname))
        else:
            commands.append("gpart add -a 4k -b 128 -t %s %s" % (type, devname))

Interesting. I had a feeling the GUI should be using 4k aligned partitions. I don't understand why my 3TB WD Red was not created 4k aligned.

ada0 is the drive I used when I first created a single drive zfs pool. It doesn't look like it's 4k aligned. ada1 was partitioned manually without '-a 4k'

Code:
=>        34  5860533101  ada0  GPT  (2.7T)
          34          94        - free -  (47k)
         128     4194304     1  freebsd-swap  (2.0G)
     4194432  5856338696     2  freebsd-zfs  (2.7T)
  5860533128           7        - free -  (3.5k)

=>        34  5860533101  ada1  GPT  (2.7T)
          34          94        - free -  (47k)
         128     4194304     1  freebsd-swap  (2.0G)
     4194432  5856338696     2  freebsd-zfs  (2.7T)
  5860533128           7        - free -  (3.5k)
 

mjws00

Guru
Joined
Jul 25, 2014
Messages
798
So it took me a second to figure out what you were worried about. Those disks are 4k aligned. 'gpart list' will show you the stripe offset which is divisible by 4096.

But if you take that first number 4194432 * 512 (which is the block size) You will get 2147549184 which is the stripe offset and physical (4096) block 524304.

I never bothered with that math. Just took gpart -a 4k at its word ;) Turns out the math works too.
 
Last edited:

kjp4756

Contributor
Joined
Feb 11, 2014
Messages
102
Sorry I should've finished what I was trying to say. I was half asleep at the time.

In the text I pasted yesterday the start position for the freebsd-swap partition is 128. When I manually partitioned my new drive with 'gpart add -a 4k -b 128 -t freebsd-swap /dev/ada1' the start position of freebsd-swap became 4096 instead of 128. That is why I was under the impression that the GUI wasn't using -a 4k.

EDIT: Just did some testing using a dummy block device. Got some interesting results. '-a 4k' and '-a 4096' yield different results. When I first attempted this a month ago I was trying '-a 4096'

'gpart add -a 4k -b 128 -t freebsd-swap -s 2G /dev/md0' gives:

Code:
=>        6  786431989  md0  GPT  (3T)
          6        122       - free -  (488k)
        128     524288    1  freebsd-swap  (2.0G)
     524416  785907579       - free -  (2.9T)


'gpart add -a 4096 -b 128 -t freebsd-swap -s 2G /dev/md0' gives:

Code:
=>        6  786431989  md0  GPT  (3T)
          6       4090       - free -  (16M)
       4096     524288    1  freebsd-swap  (2.0G)
     528384  785903611       - free -  (2.9T)


Not sure what to think other than I should just stop worrying about it. I was almost ready to split my mirror and repartition the drives.

EDIT2: Figured it out. the -a parameter specifies sectors not bytes. I've come across numerous posts that say to use 'gpart add -a 4096 ...' which is wrong. 'gpart add -a 4k ...' is correct.
 
Last edited:

jakeandchase

Explorer
Joined
Aug 26, 2014
Messages
53
The only problem I ran in to was the drive I set up using the gui (9.2.1.8 at the time) was NOT using 4k aligned partitions. I don't get why all of these CLI posts about partitioning drives recommend 4k aligned (the -a 4096 in gpart) when the gui does not partition drives 4k aligned. This caused be a fair bit of grief at the time when I went to attach the new drive to the pool.


I was confused by this too. Seems to be all good though.
 
Status
Not open for further replies.
Top