Disk Management
All Managed OS VMs must fulfill some requirements to pass the compliance check.
If the requirements are not met, it is not possible to exit the Temp Admin state.
Managed OS distinguishes between file systems belonging to the basic OS and file systems belonging to the customer application. The base OS file systems must not be changed:
- The size of the OS disk must not be changed
- The size of the basic OS file systems must not be changed
- The content of the basic OS file systems must not be changed
- It is not allowed that the customer applications write data into the basic OS file systems
On the other hand, the customer is responsible for configuring the disks and file systems for the customer application.
Disk Requirements for Managed Windows
For the file systems of a Managed Windows to be compliant, the following requirements must be met:
- All additional disks must be formatted with NTFS
- Do not delete any Partition or disks in the Windows Disk manager
Disk Requirements for Managed RHEL
For the file systems of a Managed RHEL to be compliant, the following requirements must be met:
- All additional disks must be managed with the Logical Volume Manager (LVM).
- All additional disks must be in the volume group (VG) called
datavg
ordatavg[0-9][0-9]
. - All additional logical volumes (LV) must be created in the VG
datavg
ordatavg[0-9][0-9]
. - All additional file systems must be created on a LV in the VG
datavg
ordatavg[0-9][0-9]
. - All additional file systems should be of type
xfs
orext4
. - On the VG
vrhvg
only the predefined OS file systems are allowed.
Add disk for a new VM
It is possible to add additional disks to a VM during the VM ordering process.
When ordering a Managed OS VM, there is a Storage tab, where you can click on Create Disk.
Remark:
- The maximum number of allowed disks is 10.
- The maximum size of any single disk is 4096 GB.
- The cumulated maximum size for all disks is 10240 GB.
For a Managed Windows VM no additional action is necessary.
For a Managed RHEL VM you must define Label
, Capacity
and Mount Path
. Only Storage Reservation Policy
is optional. After submitting the request the additional disks will be partitioned, and managed with LVM. All disks will be added to the volume group datavg
. The Label
value will be used as logical volume name. An ext4
file system will be created and mounted. Also the /etc/fstab
entry is created automatically.
Attention:
- Disks with "incorrect"
Mount Path
are not mounted properly and are wrong pre-defined in/etc/fstab
. - Disks with "missing"
Mount Path
are not managed in LVM by default. You have to use LVM commands to fix this.
Add disk for an existing VM
Use the following procedure to add a disk for an existing VM:
- Change from the Swisscom portal to the vRA portal
- Select the VM for which you want to add a disk in the vRA portal
- Change to the Temp Admin state
- Under Actions you can choose Reconfigure
- Switch to the Storage tab
- Click New, configure the capacity in GB and the storage reservation policy for the new disk, and click Submit
Remark:
- The maximum number of allowed disks is 10.
- The cumulated maximum size for all disks is 10240 GB.
For a Managed Windows VM no additional action is necessary.
For a Managed RHEL VM the disk will be partitioned and added to the volume group datavg
.
Then you need to create the logical volume, file system, mount point, and /etc/fstab
entry manually.
The following example commands below can be used. Depending on the specific conditions of the VM, the commands must be adapted. You always have to know what you're doing!
Create a new logical volume
$ sudo lvcreate -L <size>G -n <lvol_name> /dev/datavg
Format the logical volume using the mkfs
tool. This command deletes all data from the specified logical volume, make sure to specify the correct device. In this example we use the ext4
file format. For xfs
use the mkfs.xfs
command.
$ sudo mkfs.ext4 /dev/mapper/datavg-<lvol_name>
Create a directory which serves as the mount point
$ sudo mkdir <mnt_point>
Configure automatic mounting when the VM restarts. Open the /etc/fstab
in a text editor and create an entry like the following:
/dev/mapper/datavg-<lvol_name> <mnt_point> ext4 defaults,nofail 1 2
Replace the following:
- <lvol_name>: the logical volume name you specified in the previous step
- <mnt_point>: the directory which serves as mount point
Remark: The fourth field in /etc/fstab
specifies the nofail
mount option, which lets the OS boot even if the device is unavailable.
Use the mount
command to mount the new file system
$ sudo mount <mnt_point>
Extend disk
Use the following procedure to extend an existing disk:
- Change from the Swisscom portal to the vRA portal
- Select the VM for which you want to add a disk in the vRA portal
- Change to the Temp Admin state
- Under Actions you can choose Reconfigure
- Switch to the Storage tab
- Select the storage volume which you want to extend and click Edit, configure the extended capacity in GB, click the green Save button, then click Submit
Remark:
- The cumulated maximum size for all disks is 10240 GB.
For a Managed Windows VM no additional action is necessary.
For a Managed RHEL VM the disk will only be extended for the VM.
The partitioning, the physical volume, the volume group and the file system needs to be extended manually within the OS.
The following example commands can be used. Depending on the specific conditions of the VM, the commands must be adapted. You always have to know what you're doing!
The example below will create a second partition on the extended disk /dev/sdb
Check which disk that should be extended, and define the DISK
variable
$ ls -1 /dev/sd*
/dev/sda
/dev/sda1
/dev/sda2
/dev/sdb
/dev/sdb1
$ DISK=sdb
Advertise the OS about the disk extension
$ echo 1 | sudo tee /sys/block/${DISK}/device/rescan
Create an additional partition on the new disk with parted
$ sudo parted /dev/${DISK}
Inform parted
about the increased disk
(parted) print
Error: The backup GPT table is not at the end of the disk, as it should be. This might mean that another operating system
believes the disk is smaller. Fix, by moving the backup to the end (and removing the old backup)?
Fix/Ignore/Cancel? Fix
Warning: Not all of the space available to /dev/sdb appears to be used, you can fix the GPT to use all of the space (an extra
4194304 blocks) or continue with the current setting?
Fix/Ignore? Fix
Show the free space
(parted) print free
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 3221MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
17.4kB 1049kB 1031kB Free Space
1 1049kB 1073MB 1072MB primary lvm
1073MB 3221MB 2149MB Free Space
Create a new partition on the free space at the end of the disk
(parted) mkpart primary 1073MB 3221MB
Check the newly created partition
(parted) print
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 3221MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 1073MB 1072MB primary lvm
2 1073MB 3221MB 2149MB primary
Set the lvm
tag on the newly created partition
(parted) set 2 lvm on
(parted) print
Model: VMware Virtual disk (scsi)
Disk /dev/sdb: 3221MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 1073MB 1072MB primary lvm
2 1073MB 3221MB 2149MB primary lvm
Exit parted
and execute partprobe
, to inform the OS about the new partition
(parted) quit
Information: You may need to update /etc/fstab.
$ sudo partprobe
Check the new partition
$ ls -1 /dev/sd*
/dev/sda
/dev/sda1
/dev/sda2
/dev/sdb
/dev/sdb1
/dev/sdb2
Create a physical volume on the new partition
$ sudo pvcreate /dev/${DISK}<number_of_the_new_partition>
$ sudo pvs
Extend the existing volume group datavg
with the new physical volume
$ sudo vgextend datavg /dev/${DISK}<number_of_the_new_partition>
$ sudo vgs
Create a new logical volume or extend an existing one
$ sudo lvcreate -L <total_size>G -n <lvol_name> /dev/datavg
$ sudo lvextend -L <new_total_size>G /dev/datavg/<name_of_existing_lv>
$ sudo lvs
If you have created a new logical volume, create a file system. Format the logical volume using the mkfs
tool. This command deletes all data from the specified logical volume, make sure to specify the correct device. In this example we use the ext4
file format. For xfs
use the mkfs.xfs
command.
$ sudo mkfs.ext4 /dev/datavg/<lvol_name>
Configure automatic mounting when the VM restarts. Open the /etc/fstab
in a text editor and create an entry like the following:
/dev/mapper/datavg-<lvol_name> <mnt_point> ext4 defaults,nofail 1 2
Replace the following:
- <lvol_name>: the logical volume name you specified in the previous step
- <mnt_point>: the directory which serves as mount point
Remark: The fourth field in /etc/fstab
specifies the nofail
mount option, which lets the OS boot even if the device is unavailable.
Example how an /etc/fstab
file could look like:
# VOLUME MOUNTPOINT FILESYSTEM OPTIONS DUMP ON/OFF FSCK
/dev/mapper/vrhvg-slashlv / xfs defaults 0 0
UUID=7aff928b-7aaa-4dba-b554-cb7a79ee82e6 /boot xfs defaults 0 0
/dev/mapper/vrhvg-homelv /home xfs defaults 0 0
/dev/mapper/vrhvg-optlv /opt xfs defaults 0 0
/dev/mapper/vrhvg-tmplv /tmp xfs defaults 0 0
/dev/mapper/vrhvg-usrloclv /usr/local xfs defaults 0 0
/dev/mapper/vrhvg-varlv /var xfs defaults 0 0
/dev/mapper/vrhvg-varloglv /var/log xfs defaults 0 0
/dev/mapper/vrhvg-swaplv01 swap swap defaults 0 0
/dev/mapper/datavg-lvolname /var/log/abc ext4 defaults,nofail 1 2
Use the mount
command to mount the new file system
$ sudo mount <mnt_point>
If you have extended an existing logical volume, resize the file system
$ sudo resize2fs /dev/datavg/<lvol_name>
Shrink disk
Remove disk
It is possible to remove a disk from a Managed OS VM.
Please make sure that the disk is no longer used by the OS!
The Remove Disk action does not check if the disk is still in use, it will only remove the disk from the VM.
If the disk was not removed correctly from the OS, the VM will no longer boot without intervention!
If the disk is no longer in use by the OS, the following procedure will remove an existing disk from a VM.
- For a Managed RHEL VM, execute the Remove the disk from the OS steps first, which are described below.
- Change from the Swisscom portal to the vRA portal
- Select the VM for which you want to remove a disk in the vRA portal
- Change to the Temp Admin state
- Under Actions you can choose Reconfigure
- Switch to the Storage tab
- Select the storage volume which you want to remove and click Delete, click the green Save button, then click Submit
For a Managed RHEL VM - Remove the disk from the OS
If a disk was already used from a file system, then the disk has to be freed up, before the disk can be removed.
You have to unmount the file system, remove the /etc/fstab
entries, remove the disk from LVM manually with the example commands below.
Depending on the specific conditions of the system, the commands must be adapted. You always have to know what you're doing!
$ sudo umount /<no_longer_used_filesystem>
$ sudo vi /etc/fstab
# remove the entry for the no longer used filesystem
$ sudo lvremove /dev/datavg/<no_longer_used_logical_volume>
If the disk is no longer in use or was never used, the disk can be removed from the OS with the example commands below.
The example below wil remove the disk /dev/sdc
. Depending on the specific conditions of the system, the commands must be adapted. You always have to know what you're doing!
Check if the physical volume is empty (PSize = PFree).
$ sudo pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vrhvg lvm2 a-- <31.50g 5.03g
/dev/sdb1 datavg lvm2 a-- 1020.00m 1020.00m
/dev/sdc1 datavg lvm2 a-- <2.00g <2.00g
Remove the physical volume from the datavg
volume group
$ sudo vgreduce datavg /dev/sdc1
If the datavg
volume group has only one physical volume which needs to be removed, the command above will throw an error.
Instead of removing the physical volume from the datavg
volume group, you have to remove the datavg
volume group.
$ sudo vgremove datavg
Remove the physical volume
$ sudo pvremove /dev/sdc1
Remove the disk from the OS
$ echo 1 | sudo tee /sys/block/sdc/device/delete
Now the disk is ready for removing it from the portal.