2021-07-26 10:39:47 +02:00
|
|
|
= Guest Disk Resize SOP
|
|
|
|
|
|
|
|
Resize disks in our kvm guests
|
|
|
|
|
|
|
|
== Contents
|
|
|
|
|
2021-09-01 15:09:46 +02:00
|
|
|
* <<_contact_information>>
|
|
|
|
* <<_how_to_do_it>>
|
|
|
|
** <<_kvmlibvirt_guests>>
|
2021-07-26 10:39:47 +02:00
|
|
|
|
|
|
|
== Contact Information
|
|
|
|
|
|
|
|
Owner:::
|
|
|
|
Fedora Infrastructure Team
|
|
|
|
Contact:::
|
|
|
|
#fedora-admin, sysadmin-main
|
|
|
|
Location:::
|
|
|
|
PHX, Tummy, ibiblio, Telia, OSUOSL
|
|
|
|
Servers:::
|
|
|
|
All xen servers, kvm/libvirt servers.
|
|
|
|
Purpose:::
|
|
|
|
Resize guest disks
|
|
|
|
|
|
|
|
== How to do it
|
|
|
|
|
|
|
|
=== KVM/libvirt Guests
|
|
|
|
|
|
|
|
[arabic]
|
2021-09-01 15:09:46 +02:00
|
|
|
. SSH to the kvm server and resize the guest's logical volume. If you
|
2021-07-26 10:39:47 +02:00
|
|
|
want to be extra careful, make a snapshot of the LV first:
|
2021-09-01 15:09:46 +02:00
|
|
|
+
|
2021-07-26 10:39:47 +02:00
|
|
|
....
|
|
|
|
lvcreate -n [guest name]-snap -L 10G -s /dev/VolGroup00/[guest name]
|
|
|
|
....
|
2021-09-01 15:09:46 +02:00
|
|
|
+
|
|
|
|
Optional, but always good to be careful
|
|
|
|
|
2021-07-26 10:39:47 +02:00
|
|
|
. Shutdown the guest:
|
|
|
|
+
|
|
|
|
....
|
|
|
|
sudo virsh shutdown [guest name]
|
|
|
|
....
|
2021-09-01 15:09:46 +02:00
|
|
|
|
2021-07-26 10:39:47 +02:00
|
|
|
. Disable the guests lv:
|
|
|
|
+
|
|
|
|
....
|
|
|
|
lvchange -an /dev/VolGroup00/[guest name]
|
|
|
|
....
|
2021-09-01 15:09:46 +02:00
|
|
|
|
2021-07-26 10:39:47 +02:00
|
|
|
. Resize the lv:
|
|
|
|
+
|
|
|
|
....
|
|
|
|
lvresize -L [NEW TOTAL SIZE]G /dev/VolGroup00/[guest name]
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
lvresize -L +XG /dev/VolGroup00/[guest name]
|
|
|
|
(to add X GB to the disk)
|
|
|
|
....
|
|
|
|
. Enable the lv:
|
|
|
|
+
|
|
|
|
....
|
|
|
|
lvchange -ay /dev/VolGroup00/[guest name]
|
|
|
|
....
|
2021-09-01 15:09:46 +02:00
|
|
|
|
2021-07-26 10:39:47 +02:00
|
|
|
. Bring the guest back up:
|
|
|
|
+
|
|
|
|
....
|
|
|
|
sudo virsh start [guest name]
|
|
|
|
....
|
|
|
|
. Login into the guest:
|
|
|
|
+
|
|
|
|
....
|
|
|
|
sudo virsh console [guest name]
|
|
|
|
You may wish to boot single user mode to avoid services coming up and going down again
|
|
|
|
....
|
2021-09-01 15:09:46 +02:00
|
|
|
|
2021-07-26 10:39:47 +02:00
|
|
|
. On the guest, run:
|
|
|
|
+
|
|
|
|
....
|
|
|
|
fdisk /dev/vda
|
|
|
|
....
|
2021-09-01 15:09:46 +02:00
|
|
|
|
2021-07-26 10:39:47 +02:00
|
|
|
. Delete the the LVM partition on the guest you want to add space to and
|
|
|
|
recreate it with the maximum size. Make sure to set its type to LV (8e):
|
|
|
|
+
|
|
|
|
....
|
|
|
|
p to list partitions
|
|
|
|
d to delete selected partition
|
|
|
|
n to create new partition (default values should be ok)
|
|
|
|
t to change partition type (set to 8e)
|
|
|
|
w to write changes
|
|
|
|
....
|
2021-09-01 15:09:46 +02:00
|
|
|
|
2021-07-26 10:39:47 +02:00
|
|
|
. Run partprobe:
|
|
|
|
+
|
|
|
|
....
|
|
|
|
partprobe
|
|
|
|
....
|
2021-09-01 15:09:46 +02:00
|
|
|
|
2021-07-26 10:39:47 +02:00
|
|
|
. Check the size of the partition:
|
|
|
|
+
|
|
|
|
....
|
|
|
|
fdisk -l /dev/vdaN
|
|
|
|
....
|
|
|
|
+
|
|
|
|
If this still reflects the old size, then reboot the guest and verify
|
|
|
|
that its size changed correctly when it comes up again.
|
2021-09-01 15:09:46 +02:00
|
|
|
|
2021-07-26 10:39:47 +02:00
|
|
|
. Login to the guest again, and run:
|
|
|
|
+
|
|
|
|
....
|
|
|
|
pvresize /dev/vdaN
|
|
|
|
....
|
2021-09-01 15:09:46 +02:00
|
|
|
|
2021-07-26 10:39:47 +02:00
|
|
|
. A vgs should now show the new size. Use lvresize to resize the root
|
|
|
|
lv:
|
|
|
|
+
|
|
|
|
....
|
|
|
|
lvresize -L [new root partition size]G /dev/GuestVolGroup00/root
|
|
|
|
|
|
|
|
(pvs will tell you how much space is available)
|
|
|
|
....
|
2021-09-01 15:09:46 +02:00
|
|
|
|
2021-07-26 10:39:47 +02:00
|
|
|
. Finally, resize the root partition:
|
|
|
|
+
|
|
|
|
....
|
|
|
|
resize2fs /dev/GuestVolGroup00/root
|
|
|
|
(If the root fs is ext4)
|
|
|
|
|
|
|
|
or
|
|
|
|
|
|
|
|
xfs_growfs /dev/GuestVolGroup00/root
|
|
|
|
(if the root fs is xfs)
|
|
|
|
....
|
|
|
|
+
|
|
|
|
verify that everything worked out, and delete the snapshot you made if
|
|
|
|
you made one.
|