Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If it should become necessary to expand the storage space for /data, the following set of instructions should help you to perform that change with minimal NMIS downtime.

The resizing procedure is quite simple, for size increases at least. The two required steps are:

  • adding extra storage 'hardware' to the VM
  • informing the operating system of the extra storage, attaching the storage and resizing the active file systems.

This is possible because the Opmantek Virtual appliance makes use of Linux's excellent LVM support (Logical Volume Management, described in more details here).

First Step, determine the current state

login as as root to the VM and run

Code Block
themeEmacs
pvs

which will show you something like this

Code Block
themeEmacs
/dev/sdb   vg_nmis64_data  lvm2 a-   100.00g    0

meaning 100gb are allocated and vg_nmis64_data is using it. Note that on some older VMs the volume group is called vg_data instead; the resizing process can be performed as long as you remember to change the volume group name in the command invocations.

Next run

Code Block
themeEmacs
lvs

and it'll tell you

Code Block
themeEmacs
lv_data vg_nmis64_data -wi-ao 100.00g

that the lv_data logical volume is using all of vg_nmis64_data's space, and a final

Code Block
themeEmacs
df -h

will tell you that

Code Block
 /dev/mapper/vg_nmis64_data-lv_data 99G 39G 56G 42% /data

 /data is the filesystem on top of the logical volume, which has a size of 99GB (plus spare change), of which 39BG are used. It is recommended that you rerun these commands at the end to verify that the resizing has worked.

Second Step,  Resize Storage Hardware

At this point it'll be simplest to open your vmware client, resize the VM's disk 2 to the desired new size and then reboot the VM to make it pick up the size change.

If you would like to avoid any downtime and not reboot, that's also possible if your virtualisation system allows adding or resizing disks "on the go": Virtualbox doesn't allow that, Vmware does. Please note that Vmware doesn't let you resize disks if there are any snapshots present; if that is the case, then these snapshots must be removed before the resize can occur.

In many cases it will be simpler to add another 'disk' to the system rather than resizing either of the existing 'disks'.

Third Step, Informing the OS and resizing the file system

When the VM boots the newly resized disk 2 (aka /dev/sdb) will be detected but volume group and logical volume still need to be told about the change of 'hardware'.

If you added a new disk

If you did add disks instead of resizing existing ones, the OS should have picked them up dynamically and they should show up as /dev/sdc, sdd etc. In this case they must be registered as physical volumes (optionally after partitioning), and added to the volume group.

To do so, login as root first. Then check under what id your new disk has shown up, and add it as a whole as a new physical volume:

Code Block
cat /proc/scsi/scsi
...
Host: scsi2 Channel: 00 Id: 01 Lun:  # the '2' indicates /dev/sdc is the device file
# this marks the whole disk as physical volume
pvcreate /dev/sdc 
# this addds the pv to the volume group
vgextend vg_nmis64_data /dev/sdc
If you resized an existing disk

In this case we just tell the LVM subsystem that there's now more space available in a particular physical volume. Login as root, then run

Code Block
themeEmacs
pvresize /dev/sdb

which will tell you that sdb is now as large as the disk2 size you gave in vmware.

New or resized disk

Finally run

Code Block
themeEmacs
lvextend -l 100%VG /dev/vg_nmis64_data/lv_data

to perform the resizing for the logical volume, follwed by

Code Block
themeEmacs
resize2fs /dev/vg_nmis64_data/lv_data

which will take a bit of time and eventuallly tell you that  it has resized the file system for the new extended disk size. A final

Code Block
themeEmacs
df -h

should show that /data is now larger than before.

Resizing from disk1


Add a x(g,m,k) new partition  type 8E (Linux LVM) 

Code Block
themeEmacs
cfdisk /dev/sda
reboot
pvcreate /dev/sda3

Extend the vg_nmis64_data with the new partition

Code Block
themeEmacs
vgextend vg_nmis64_data /dev/sda3

The Logical Volume needs to be extended.

Code Block
themeEmacs
lvextend -L+x(g,m,k) /dev/vg_nmis64_data/lv_data
where
x(g,m,k) is the assigned size in the disk 1 -L+200G as example

Now we extend the filesystem this can take a while depends of the size assigned.

Code Block
themeEmacs
resize2fs /dev/vg_nmis64_data/lv_data

Verify the new size.

Code Block
themeEmacs
df -h 

pvs