Last active
March 16, 2022 19:08
-
-
Save Ham5ter/af205b4e496b787dbbb7baa5a039e21f to your computer and use it in GitHub Desktop.
This Script is an example for growing a Simple LVM inside a virtual machine, without downtime.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Dont just copy and paste it! | |
# i am not responsible for any dataloss or other damage! | |
### grow the Disk in vSphere ### | |
# Just do it, there is no way to Script that | |
### rescan all SCSI Devices to detect the Change ### | |
for scsi in /sys/class/scsi_device/*/device/rescan; do | |
echo 1 > $scsi | |
done | |
### delete and recreate the LVM Partition on /dev/sda1 to utilize all the free Space ### | |
### this assumes that /dev/sda only has one Partition (/dev/sda1), containing an LVM ### | |
parted --script /dev/sda \ | |
rm 1 \ # Deletes the First Partition | |
mkpart primary 1 100% \ # recreates the first partition (1 is the Offset in MB) | |
set 1 lvm on # enables lvm on the first partition | |
### rescan the Partition table ### | |
partprobe -s | |
### grow the "physical volume" on /dev/sda1 ### | |
pvresize -v /dev/sda1 | |
############################################################################# | |
#### The Following needs to be "adjusted" depending on the actuall needs #### | |
############################################################################# | |
### grow the logical volume "var" by 90%FREE ### | |
lvresize -r -l +90%FREE /dev/mapper/vg_os-lv_var | |
### grow the logical volume "root" to fill up the remaining 10%FREE ### | |
lvresize -r -l +100%FREE /dev/mapper/vg_os-lv_var |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment