Table of Contents |
---|
Introduction
...
Warning |
---|
It is always advisable to make a backup of the target VM first, ensuring you can recover your original VM should things go wrong ! |
Introduction
Generally you should only be needing to resize the partiton at the /data mount point on mountpoint on an NMIS VM as this partition contains the following directories:
- nmis9/
- database/
- var/
- backups
- omk/
- var/
- mongo/
- ( mongo/ is the directory set as the storage.dbPath set in /etc/mongod.conf )
...
If it should become necessary to expand the storage space for the partition at the /data mountpoint, the following set of instructions should help you to perform that change with minimal NMIS downtime.
First, determine whether the NMIS VMs' partitions are using Logical Volume Manager (LVM)
First, determine whether the NMIS VM is using LVM:
If the sudo lsblk command produces partition entries in the TYPE column of type lvm, then that partition is using LVM.
In the example command below, using a recent release of the NMIS VM that does not use LVM, we have disks /dev/sda and /dev/sdb.
/dev/sda has partitions /dev/sda1 to /dev/sda4 and all partitions are TYPE part
/dev/sdb has partition /dev/sdb1 of TYPE part
Code Block |
---|
sudo lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 120G 0 disk ├─sda1 8:1 0 1G 0 part /boot ├─sda2 8:2 0 15G 0 part / ├─sda3 8:3 0 1G 0 part [SWAP] └─sda4 8:4 0 103G 0 part /var sdb 8:16 0 120G 0 disk └─sdb1 8:17 0 120G 0 part /data |
In the example command above, using a recent release of the NMIS VM that does not use LVM, we have disks /dev/sda (disk 1) and /dev/sdb (disk 2).
Disk 1 (/dev/sda) has partitions /dev/sda1 to /dev/sda4 and all partitions are TYPE part
Disk 2 (/dev/sdb) has partition /dev/sdb1 of TYPE part
If your NMIS VM is using partitions partition of type lvm lvm for partition at mountpoint /data, then proceed to the paragraph further below NMIS VMs' using Logical Voume Manager (LVM)
Otherwise, continue with the next paragraph NMIS VMs' using Traditional Disk Partitions
...
Code Block |
---|
df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 17M 3.9G 1% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda2 15G 6.1G 7.8G 44% / /dev/sda4 23G 805M 21G 4% /var /dev/sda1 976M 95M 815M 11% /boot /dev/sdb1 40G 8.5G 29G 23% /data tmpfs 783M 0 783M 0% /run/user/0 tmpfs 783M 0 783M 0% /run/user/1000... |
df -h command returns this information for /data partition:
...
Third Step, Informing the OS and resizing the file system
Install growpart:
Code Block |
---|
# centos|rhel sudo yum update sudo yum install -y cloud-utils-growpart#growpart # debian|ubuntu sudo apt update sudo apt install -y cloud-guest-utils |
Grow the partition at the /data mount point mountpoint, which we now know from the df -h commands above is /dev/sdb1:
Code Block |
---|
# note there is a space between '/dev/sdb' and '1':
sudo growpart /dev/sdb 1
CHANGED: partition=1 start=2048 old: size=83884032 end=83886080 new: size=251656159 end=251658207 |
Resize the filesystem, which will take a bit of time and eventuallly tell you that it has resized the file system for the new extended disk size:
Code Block |
---|
# note there is NOT a space between '/dev/sdb' and '1':
sudo resize2fs /dev/sdb1
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/sdb1 is mounted on /data; on-line resizing required
old_desc_blocks = 5, new_desc_blocks = 15
The filesystem on /dev/sdb1 is now 31457019 blocks long. |
Finally check that /dev/sdb1 has been resized as expected:
Code Block |
---|
df -h
Filesystem Size Used Avail Use% Mounted on
...
/dev/sdb1 118G 8.5G 105G 8% /data
... |
Moving and Resizing partitions /dev/sda1 to /dev/sda4 as needed where NMIS VM is using Traditional Partitions
This should not be necessary with regards to the NMIS VM and requires more thought, effort and skill to achieve.
For example, one could consider adding additional disks to the NMIS VM and moving the /home directory and|or any other directory consuming huge disk space to its own mountpoint on the additional disks as an alternative to growing partitions on disk 1 (/dev/sda).
One should also keep in mind that moving or resizing the /boot partition [ fortunately at partition 1 on disk 1 (/dev/sda1) ] can cause the VM not to boot afterwards.
Since disk 1 (/dev/sda) has more than 1 partition, GParted is probably a useful tool for this task:
https://gparted.org/display-doc.php%3Fname%3Dmoving-space-between-partitions
NMIS VMs' using Logical Volume Manager (LVM)
The resizing procedure is quite simple, for size increases at least. The two required steps are:
...
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 adddsadds the pv to the volume group vgextend vg_nmis64_data /dev/sdc |
...