Blog Post

SQL Server on Linux Series: Expanding LVM Drives

,

Next in our SQL Server on Linux series is one important question. On Windows, if you’re about to run out of space, you get your VM admin / storage admin to expand one or more of your drives, and you go to Disk Management and expand the drive with no downtime. How do we accomplish this same task on Linux?

First, SSH into your VM. Get your appropriate system engineer to expand the drive that needs to be expanded. You won’t be able to see it at first in Linux because, just like in Windows, it’ll need to rescan the storage to ‘see’ the extra space. Sometimes Windows does it automatically, and sometimes you have to initiate it manually. In Linux it only does this on system startup.

Let’s grow our data drive from 250GB to 300GB first.

Note, I’m running all commands as the Linux ‘root’ user to keep me from typing ‘sudo’ numerous times.

This drive in question is listed as /dev/sdc in Linux, which we used the LVM to mount as /var/opt/mssql/data/data01 in a previous post. This drive was formatted as the XFS file system.

To rescan the storage without a restart, issue the command ‘echo 1 > /sys/class/block/sdc/device/rescan’ where sdc is replace with the device from your system.

You’ll now see the new space listed in the list block devices command.

‘pvdisplay’ can display the physical volumes and the volume groups, and we’ll need the volume group name to extend the volume.

Resize the physical volume boundaries.

You can now see that the physical volume boundaries have changed by reissuing the ‘pvdisplay’ command.

Use ‘lvextend’ to extend the logical volume to add the extra space, and the ‘-r’ parameter to tell it to resize.

Done!

We’ve now expanded our data drive by 50GB to make room for new data coming in. All in all, it’s not too bad, and quite procedural to do as needed.

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating