ZFS zpool Expansion…

WARNING: The example scripts and commands used here are destructive and will destroy your drive/s unless you know what you are doing. For proper interpretation, I am running:

  • six SATA HDDs, which appear in my bare-metal Ubuntu LTS environment as /dev/sd[a-f] (meaning sda, sdb, ..., sdf)
  • there was only one partition on each of these HDDs i.e. /dev/sd[a-f]1, and each was (and still is) the RAIDZ2 raidz=type vdev (i.e. part of the RAIDZ2 pool)
  • there was (and still is) one SLOG using partition #5 on my NVMe drive

Having moved my entire RAIDZ2 cluster to a bigger drives quite a while ago, I never had the need to expand the entire volume size (yet). But since I was to embark on creating a new RAIDZ3 for some other reason, I decided to first expand the part1s across all six disks (where by RAIDZ2 was sitting astride):

Gather all “before” data:

  • zpool get autoexpand <POOL NAME>
  • zpool list <POOL NAME>
  • sfdisk -l /dev/sd[a-f]

Export the zpool:

  • zfs export <POOL NAME>

Backup the GPT tables:

mkdir -p /root/gpt-backup

for d in /dev/sd[a-f]; do
    sgdisk --backup="/root/gpt-backup/$(basename "$d").gpt" "$d";
done

Then resize part1 across all 6 disks, based on your expanded ending sector (use ‘0‘ if you want to extend to maximum allowable, leaving correct end-disk spacing for backup GPT and the like):

for d in /dev/sd[a-f]; do
    sgdisk --delete=1 "$d";
    sgdisk --new=1:2048:20835092399 "$d";
    sgdisk --typecode=1:BF01 "$d";
    sgdisk --change-name=1:<POOL NAME> "$d";
done

Don’t worry: sgdisk re-creating the partition 1 information with the same starting sector and later ending sector simply means your data is still there, but the partition is expanded.

You can now check the “new” boundaries:

  • sfdisk -l /dev/sd[a-f]

And you can also check that the ZFS labels still exist:

for d in /dev/sd[a-f]1; do
    echo "===== $d ====="
    zdb -l "$d" | grep -E 'name:|pool_guid:|top_guid:|guid:|txg:'
done

You can then proceed to re-import the pool, either with a blanket command below, or using specific IDs:

  • zpool import -d /dev/disk/by-id <POOL NAME>

Then check:

  • zpool status -P <POOL NAME>

Ensure the pool is set to auto-expand:

  • zpool set autoexpand=on <POOL NAME>

And then explicitly  set each member vdev to expand:

# P.S. READ TO THE END BEFORE YOU TRY THIS
for d in /dev/sd[a-f]1; do
    zpool online -e <POOL NAME> "$d"
done

And this where all the trouble started…

No matter how many times I did that last two commands, or even exported and reimported, ZFS refused to expand the individual vdevs, despite the “extra space” being acknowledged (by the EXDPANDSZ parameter showing as such)…

# zpool sync
# zpool list <POOL>
NAME      SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
<POOL>   32.5T  30.7T  1.85T        -     25.2T    18%    94%  1.00x    ONLINE  -
# zpool list -v <POOL>
NAME                                                  SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
<POOL>                                               32.5T  30.7T  1.85T        -     25.2T    18%    94%  1.00x    ONLINE  -
  raidz2-0                                           32.5T  30.7T  1.85T        -     25.2T    18%  94.3%      -    ONLINE
    ata-<redacted>-part1                             9.70T      -      -        -         -      -      -      -    ONLINE
    ata-<redacted>-part1                             9.70T      -      -        -         -      -      -      -    ONLINE
    ata-<redacted>-part1                             9.70T      -      -        -         -      -      -      -    ONLINE
    ata-<redacted>-part1                             9.70T      -      -        -         -      -      -      -    ONLINE
    ata-<redacted>-part1                             9.70T      -      -        -         -      -      -      -    ONLINE
    ata-<redacted>-part1                             9.70T      -      -        -         -      -      -      -    ONLINE
logs                                                     -      -      -        -         -      -      -      -         -
  nvme-<redacted>-part5                                 4G   536K  3.97G        -         -     0%  0.01%      -    ONLINE

Continue reading →

ZFS Importing /dev/disk/by-id…

I had the dubious pleasure of having to (re-)import a ZFS pool by disk ID… i.e. zpool import -d /dev/disk/by-id <POOL NAME>, unfortunately, on my system, everything appeared as WWNs, like “wwn-0x5111c500c8708981-part1” – instead of my expected “ata-<MODEL>-<BUILD>_<HDD SERIAL>-part1” where I could easily determine which disk a specific zpool/zvol was on.

So the fix, given I know I had all my SATA drives’ “part1” as part of my zpool, and that my log was on my NVMe drive, the following commands imported the individual vdevs according to my desired tags/handles:

d_devices=()
for dev in /dev/disk/by-id/ata-*-part1; do
    d_devices+=(-d "$dev")
done
# Include the NVMe SLOG explicitly
d_devices+=(-d /dev/disk/by-id/nvme-<MODEL>_<BUILD>_<SERIAL>-part5)

Doing a last check:

  • printf '%s\n' "${d_devices[@]}"

Then check the import:

  • zpool import "${d_devices[@]}"

And finally, assuming all is good, import!

  • zpool import "${d_devices[@]}" <POOL NAME>

Lastly, verify the vdev paths:

  • zpool status -P <POOL NAME>

ZFS Partition IDs…

WARNING: The example scripts and commands used here are destructive and will destroy your drive/s unless you know what you are doing. For proper interpretation, I am running:

  • six SATA HDDs, which appear in my bare-metal Ubuntu LTS environment as /dev/sd[a-f] (meaning sda, sdb, ..., sdf)
  • there was only one partition on each of these HDDs i.e. /dev/sd[a-f]1, and each was (and still is) the RAIDZ2 raidz=type vdev (i.e. part of the RAIDZ2 pool)
  • there was (and still is) one SLOG using partition #5 on my NVMe drive

While doing some maintenance, I ran: sudo sfdisk -l /dev/sd[a-z] in attempt to list all partitions on my 6x 16TB of spinning rust i.e. /dev/sd*, which produced:

Disk /dev/sda: 14.55 TiB, 16000900661248 bytes, 31251759104 sectors
Disk model: <redacted>
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: <redacted>

Device     Start         End     Sectors  Size Type
/dev/sda1   2048 11721043967 11721041920  5.5T Linux filesystem


Disk /dev/sdb: 14.55 TiB, 16000900661248 bytes, 31251759104 sectors
Disk model: <redacted>
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: <redacted>

Device     Start         End     Sectors  Size Type
/dev/sdb1   2048 11721043967 11721041920  5.5T Linux filesystem


Disk /dev/sdc: 14.55 TiB, 16000900661248 bytes, 31251759104 sectors
Disk model: <redacted>
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: <redacted>

Device     Start         End     Sectors  Size Type
/dev/sdc1   2048 11721043967 11721041920  5.5T Linux filesystem


Disk /dev/sdd: 14.55 TiB, 16000900661248 bytes, 31251759104 sectors
Disk model: <redacted>
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: <redacted>

Device     Start         End     Sectors  Size Type
/dev/sdd1   2048 11721043967 11721041920  5.5T Linux filesystem


Disk /dev/sde: 14.55 TiB, 16000900661248 bytes, 31251759104 sectors
Disk model: <redacted>
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: <redacted>

Device     Start         End     Sectors  Size Type
/dev/sde1   2048 11721043967 11721041920  5.5T Linux filesystem


Disk /dev/sdf: 14.55 TiB, 16000900661248 bytes, 31251759104 sectors
Disk model: <redacted>
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: <redacted>

Device     Start         End     Sectors  Size Type
/dev/sdf1   2048 11721043967 11721041920  5.5T Solaris /usr & Apple ZFS

 

That was odd, considering all these partitions are ZFS type (i.e. blue highlights are correct, red highlights are incorrect).

Continue reading →

Missing The (Mount) Point…

So my Silverstone DS-380 casing’s power LED seems to have bought it… In an attempt to try fix it (or at least test it), I had to get to the motherboard and that meant I had to remove all the drives, drive cage, etc… Since piecing everything back together again was a pain, I left the 3.5″ spinning media drives out to boot the system several times during testing.

After giving up on the power LED, I re-plugged in everything + the drives… Only to find that, of some 11 different ZFS sub pools, 10 were missing…

My heart stopped and the universe whirled around me…

zpool status showed the drives were all present and accounted for…

Thankfully, zfs list showed all my ZFS sub pools/”partitions” were still there… So, what gives?

Continue reading →

Sharing The Love…

So, the ZFS datasets have been created, and we now have to start creating the shares…

<rant>No thanks to Micro$oft, NFS support on is now only available on Enterprise versions of Windows 10, and therefore I will cannot use (the more efficient) NFS in my largely Windows environment network.</rant>

Goals

My goal was to:

  1. set up several different shares, mapping directly to the ZFS datasets
    1. this meant setting up SAMBA in a “WORKGROUP” environment
  2. allow different users to map this share on Windows, and be able to view only, or modify any objects within (add/delete/edit) according to their permissions per share

What follows is the steps required to:

  • create the SAMBA share(s) and securing it (or at least setting the correct permissions)
  • set-up the SAMBA user(s)

Note: There is a difference between Linux uid/user and gid/group and SAMBA SID/user and GID/group; within this context, I attempt to refer to the latter as “SMB User” and “SMB group” for disambiguation.

Continue reading →

RAIDZ2… Finally

Finally, we start installing the ZFS packages and start the RAIDZ2 set-up (no screenshot):

apt-get zfsutils-linux

For several reasons, I chose to use:

  • vdevs created “by-id”:
    • as per advice from multiple places online, using the “easier” /dev/sdx identifier may break things should the order be changed (e.g. you swapped cable ends or drive cages, etc.)
  • lz4 compression
    • as per statistics from some places, the “cost” of LZ4 is relatively low/negligible

Continue reading →

Reading Up On ZFS…

Attempting to implement ZFS and the decisions that go into it is enough to make any newbie give up (and/or get terribly confused)…

Unfortunately, Google does not help, what with old information (e.g. installation instructions: old vs. new; possibly outdated information) and different “package variations” of ZFS (e.g. Ubuntu-native ZFS packages vs. ZFS-native), and the endless arguments on the “correct number of disks” for RAIDZ/2 (mirrored vdevs only? RAIDZ? RAIDZ2? mirrored RAIDZ/2? block size?)…

I read through all those articles linked above, including some other helpful(?) ones:

Some other “associated” links/articles/comments/posts that I came across:

My decision?

Continue reading →