Resizing a SAN attached volume without rebooting


Ever needed to add some extra space to that LUN on your server, but doing so you think you might need a reboot for the server to recognise the additional space?

The following set of steps talks through what needs doing to avoid that reboot!

Firstly, I should make it clear that this article assumes that any volumes needing expansion are additional volumes and do not include the disk or volume containing the running operating system, the steps required to extend OS partition are different. Also a warning point, several of these steps carry potential risk for data loss if you are unsure or make an error, always have a backup handy before manipulating your filesystems and devices

Here is the scenario: I have a SAN-based data volume named “/my_data” which is currently 20GB in size. I need to extend this filesystem to a new size of 40GB.

My first job is to log into my SAN appliance and extend the LUN containing “/my_data“, as there are many SAN vendors and technologies available I have omitted describing this step in any detail. Suffice to say in my SAN administration console I will add an additional 20GB to the LUN containing “/my_data” to make it a total of 40GB

One warning point for my current SAN is that I need to umount “/my_data” so that it is not being accessed whilst the SAN extends the LUN. Once this task is completed we are ready to move back onto our Linux Server to prepare the volume for its new space.

If we now remount “/my_data” we will see that it still shows as having still only 20GB available, for the purposes of this article the disk device we are presenting to the operating system from the SAN shows in the server logs as /dev/sdb1, and is mounted at “/my_data“.

1.  mount /dev/sdb1 /my_data

2. df /my_data which shows 20GB. – Utils like fdisk at this point will also still see the old value.

3. unmount /my_data again to perform the next step.

Running scripts like will also normally fail to pick up the changes.

Next step is to type the following command into the shell, Here is the magic bit that means we dont have to reboot:

echo 1 > /sys/block/sdb/device/rescan (where sdb is your chosen disk device number).

As the command suggests this instructs the system to rescan the specified device, and check for changes.

After this operation completes using fdisk or something like YaST partition manger will reveal the extra space. However, this doesnt mean that the new space is available for use yet, the filesystem that is already on the disk needs to be told about the extra space.

You can then use GParted(Very user friendly) or your preferred partition manager to extend the extra space into partition /dev/sdb1. When this is done, re-issuing the mount command will reflect the new space, all of which was possible with no reboot!