Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

Resizing an iSCSI target


FreeNAS Core Team
May 27, 2011
I get asked this a can I resize an iSCSI target without restarting the whole service? For systems that have multiple targets this can be a huge hassle.

The short answer is you can't, however there is a way to fake it that works fairly well.

For starters, some ground rules. There's absolutely no support in iSCSI for resize. You simply will have to disconnect and reconnect to the target at some point.

FreeNAS has no knowledge of the filesystem in your target. If you try to make it smaller you will likely munch the filesystem and lose all your data.

The iSCSI target it FreeNAS supports target reload, however it is limited to adding or removing targets. It has no way to modify a target. That means no resizing, adding, or removing LUNs from a target.

For starters, in the GUI, delete the target that you are going to resize from the GUI. In /var/log/messages you should see the istgt reload. The iSCSI initiator will show the path as dead, and if you have the LUC enabled then running istgtcontrol list from the CLI will no longer show the target.

Find the extent that was used by the target on the filesystem. If it's a file based extent, use the truncate command from the CLI to grow is. So for instance, if you have a file extent at /mnt/tank/iscsi/file run

truncate -s +30G /mnt/tank/iscsi/file

to increase it's size by 30GB. If it's a ZFS zvol then use
zfs set size=newsize poolname/volname
zfs set refreservation=newsize poolname/volname

If you're using a file based extent in the extent screen set the size to 0. It's likely set to the original size of the extent. This allows istgt to create the correct size file when started for the first time. Once the file exists, setting the size to 0 tells istgt to use whatever file is there and determine the size from the file it finds.

Now you can go back to the target screen and add a target that had the same name as the one you deleted. Add the extent to the target, and you should see istgt reload it's config in /var/log/messages. You'll also see the "new" target it istgtcontrol list.

At this point you can rescan the initiator. The path will come back alive and you'll be able to use the clients partition and filesystem tools to grow the volume.

As a last point anytime you do anything to modify the underlying file used by istgt, it's a great idea to back it up, take a snapshot of it, or whatever, as there's always the possibility that something will go wrong and the volume will get munched. Remember that there are two types of computer users, those who have lost data, and those that will.
Apr 5, 2019
This may not be true any longer. I have successfully "resized" a iSCSI disk on a Linux server backed by FreeNAS 11.2. This is what I did.

In FreeNAS, edit the Zvol and increase its size.

In the Linux server,
1. Run iscsiadm -m session --rescan to refresh the iSCSI backend
2. Find out where the disk is mounted (eg. /dev/sdc). lsscsi or lsblk will give you some hints. My disks are mounted in Linux with LVM on top, so I checked with pvs.
3. (Optional) Check that the iSCSI-backed disk has changed in size with fdisk /dev/sdc
4. If you have LVM atop the iSCSI extent, run pvresize /dev/sdc
5. If you use the iSCSI extent as a regular disk, resize the partition using parted (preferably) or fdisk