I should first note that this guide is for TrueNAS Scale, as that is what most people (myself included) use.

Tools required:

  • sg_format
  • tmux
  • smartctl

Procedure

The first thing you’ll need to do is figure out the ID’s of the drives that need to be resectored. The easiest way I have found to do this is to open the Storage > Disks window in the TrueNAS webui and look for drives that have a listed size of zero. Copy the ID’s of these drives down somewhere so you can refrence them without having switching to switch back to the Disks page.

The next thing you’ll want to do is verify that your drive needs to be resectored and that you are selecting the correct drive

sudo smartctl -a /dev/<id>

This will list out all of the SMART information related to the selected drive, but all we really care about is the “Logical Block Size” line.

I would HIGHLY recommend double checking the size/serial number of the selected drive against that of the drive you want to resector, just to be 100% sure that you have the right drive selected.

TrueNAS (and basically any non-vendor OS for that matter) wants drives to have a block size of 512 bytes, so if it’s anything other than that (usually 520 bytes for EMC and NetApp drives), you will need to resector the drive.

I would recommend running the following commands in a tmux session so you can resector multiple drives at once, and still monitor the progress of the operation if your terminal closes.

tmux (to start a new tmux session)

tmux attach -d -t <session number> (to attach to an existing tmux session)


WARNING: CHANGING THE BLOCK SIZE OF A DRIVE WILL RESULT IN ALL DATA ON THE DRIVE BEING DESTROYED


Once in a new tmux session, run the following command to change the block size of the selected drive to 512 bytes:

sudo sg_format -v --format --size=512 /dev/<id>

Note: This MUST be run as sudo, as normal users do not have access to the sg_format command.

The resectoring process will take quite a while (hours to days for multi-TB hard drives), as the entire drive has to be rewritten with empty blocks of the new size.

To disconnect from the current tmux session, press ctrl+B and then D. Repeat the above steps for each drive you need to change the block size of.