Balling’s Bits

Preparing Samsung HD204UI as 4K Sector Drive for Use in ZFS Zpool

I had six Samsung HD204UI drives from a previous NAS that I wanted to use in a zpool (two vdevs each consisting of a three-way mirror). The HD204UI drives are advanced format drives with 4k sectors, but they report a 512 byte sector size to the OS. This can be overcome in zfs by forcing 4k size in sd.conf and using ashift=12 when creating the zpool.

Before creating a zpool the drives must be prepared so that zfs and disk sectors are aligned. The following approach is gleaned from the illumos wiki entry on the subject by George Wilson.

To find the device names of all disks use the format command (use Ctrl-C to exit):

1
2
3
4
5
6
7
8
9
root@srv01:~# format
Searching for disks...done
...
AVAILABLE DISK SELECTIONS:
...
       2. c3t50024E900496C9E7d0 <ATA-SAMSUNG HD204UI-0001-1.82TB>
          /scsi_vhci/disk@g50024e900496c9e7
...
Specify disk (enter its number):

To use 4K sectors the partition table must be changed to a GUID partition table (GPT). Use the mklabel gpt command to change partition table (this will destroy all data on the disk):

1
parted /dev/rdsk/c3t50024E900496C9E7d0 mklabel gpt

To align sectors create a partition which starts at sector 256 (256 sectors of 512 bytes is 131072 bytes or 32 4K sectors, i.e. aligned). The size of the partition should be total number of disk sectors minus 16640 sectors (256 sectors for start + 16384 sectors for down-sizing to allow new disks of identical size to have slightly different geometry and still be used as replacement for the drive we are partitioning). 3907029168 sectors minus 16640 sectors equals 3907012528 sectors:

1
parted /dev/rdsk/c3t5000CCA23DC00778d0p0 uni s mkpart zfs solaris 256 3907012528

The disk is now ready to use in a zpool.

Comments