From Fedora Project Wiki
(add kvm info) |
(Update with more instructions for kvm case) |
||
Line 33: | Line 33: | ||
=== KVM/libvirt Guests === | === KVM/libvirt Guests === | ||
# SSH to the kvm server and resize the guest's logical volume. If you want to be extra careful, make a snapshot of the LV first: <pre>lvcreate -n [guest name]-snap -L 10G -s /dev/VolGroup00/[guest name] # Optional, but always good to be careful</pre><pre> | # SSH to the kvm server and resize the guest's logical volume. If you want to be extra careful, make a snapshot of the LV first: <pre>lvcreate -n [guest name]-snap -L 10G -s /dev/VolGroup00/[guest name] # Optional, but always good to be careful</pre><pre> | ||
# | # Shutdown the guest: <pre>sudo virsh shutdown [guest name]</pre> | ||
# Disable the guests lv: <pre>lvchange -an /dev/VolGroup00/[guest name]</pre> | |||
# Resize the lv: <pre>lvresize -L [NEW TOTAL SIZE]G /dev/VolGroup00/[guest name]</pre> | |||
# Bring the guest back up: <pre>sudo virsh start [guest name]</pre> | |||
# Login into the guest: <pre>sudo virsh console [guest name]</pre> | # Login into the guest: <pre>sudo virsh console [guest name]</pre> | ||
# On the guest, run <pre>fdisk /dev/ | # On the guest, run <pre>fdisk /dev/vda</pre> | ||
# Delete the | # 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 LVM (8e) | ||
# Run partprobe: <pre>partprobe</pre> | # Run partprobe: <pre>partprobe</pre> | ||
# Check the size of the | # Check the size of the partition: <pre>fdisk -l /dev/vdaN</pre> If this still reflects the old size, then reboot the guest and verify that its size changed correctly when it comes up again. | ||
# Login to the guest again, and run <pre>pvresize /dev/ | # Login to the guest again, and run <pre>pvresize /dev/vdaN</pre> | ||
# A vgs should now show the new size. Use lvresize to resize the root lv: <pre>lvresize -L [new root partition size]G /dev/GuestVolGroup00/root</pre> | # A vgs should now show the new size. Use lvresize to resize the root lv: <pre>lvresize -L [new root partition size]G /dev/GuestVolGroup00/root</pre> | ||
# Finally, resize the root partition: <pre>resize2fs /dev/GuestVolGroup00/root</pre>, verify that everything worked out, and delete the snapshot you made if you made one. | # Finally, resize the root partition: <pre>resize2fs /dev/GuestVolGroup00/root</pre>, verify that everything worked out, and delete the snapshot you made if you made one. | ||
[[Category:Infrastructure SOPs]] | [[Category:Infrastructure SOPs]] |
Revision as of 19:31, 9 May 2011
Resize disks in our Xen guests
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
Xen Guests
- SSH to the xen server and resize the guest's logical volume. If you want to be extra careful, make a snapshot of the LV first:
lvcreate -n [guest name]-snap -L 10G -s /dev/VolGroup00/[guest name] # Optional, but always good to be careful
lvresize -L [new total size]G /dev/VolGroup00/[guest name]
- Shutdown the guest and then start it up again:
xm shutdown -w [guest name]
xm create [guest name]
- Login into the guest:
xm console [guest name]
- On the guest, run
fdisk /dev/xvda
- Delete the third partition (the LVM partition on the guest) and recreate it with the maximum size. Make sure to set its type to LVM.
- Run partprobe:
partprobe
- Check the size of the third partition:
fdisk -l /dev/xvda3
If this still reflects the old size, then reboot the guest and verify that its size changed correctly when it comes up again. - Login to the guest again, and run
pvresize /dev/xvda3
- 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
- Finally, resize the root partition:
resize2fs /dev/GuestVolGroup00/root
, verify that everything worked out, and delete the snapshot you made if you made one.
KVM/libvirt Guests
- SSH to the kvm server and resize the guest's logical volume. If you want to be extra careful, make a snapshot of the LV first:
lvcreate -n [guest name]-snap -L 10G -s /dev/VolGroup00/[guest name] # Optional, but always good to be careful
- Shutdown the guest: <pre>sudo virsh shutdown [guest name]
- Disable the guests lv:
lvchange -an /dev/VolGroup00/[guest name]
- Resize the lv:
lvresize -L [NEW TOTAL SIZE]G /dev/VolGroup00/[guest name]
- Bring the guest back up:
sudo virsh start [guest name]
- Login into the guest:
sudo virsh console [guest name]
- On the guest, run
fdisk /dev/vda
- 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 LVM (8e)
- Run partprobe:
partprobe
- 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. - Login to the guest again, and run
pvresize /dev/vdaN
- 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
- Finally, resize the root partition:
resize2fs /dev/GuestVolGroup00/root
, verify that everything worked out, and delete the snapshot you made if you made one.