Hi, I'm currently fiddling with KVM, Proxmox and various VMs. I setup a very basic VM with a manual (fdisk) partitioning scheme: one /boot partition, one swap partition, and one root partition, the latter being the last partition and thus expandable). I'm starting with a reduced disk size (6 GB in total) and a minimal installation. The idea behind this approach is that I can clone this minimal VM and then eventually expand it to fit my needs. Here's how I expand the available disk size. First I increase the virtual disk in the hypervisor. Then I fire up the VM and do the following: # yum install cloud-utils-growpart # lsblk # growpart -v /dev/sda 3 # resize2fs /dev/sda3 Now here's my question (finally): is there any risk involved in this sort of operation? Or can it be performed on a production system without having to worry about data loss? Cheers from the sunny South of France, Niki -- Microlinux - Solutions informatiques durables 7, place de l'?glise - 30730 Montpezat Site : https://www.microlinux.fr Blog : https://blog.microlinux.fr Mail : info at microlinux.fr T?l. : 04 66 63 10 32 Mob. : 06 51 80 12 12
On 08.04.21 17:43, Nicolas Kovacs wrote:> Hi, > > I'm currently fiddling with KVM, Proxmox and various VMs. > > I setup a very basic VM with a manual (fdisk) partitioning scheme: one /boot > partition, one swap partition, and one root partition, the latter being the > last partition and thus expandable). > > I'm starting with a reduced disk size (6 GB in total) and a minimal > installation. The idea behind this approach is that I can clone this minimal VM > and then eventually expand it to fit my needs. > > Here's how I expand the available disk size. > > First I increase the virtual disk in the hypervisor. > > Then I fire up the VM and do the following: > > # yum install cloud-utils-growpart > # lsblk > # growpart -v /dev/sda 3 > # resize2fs /dev/sda3 > > Now here's my question (finally): is there any risk involved in this sort of > operation? Or can it be performed on a production system without having to > worry about data loss?Just a hint - man virt-resize -- Leon
> Hi, > > I'm currently fiddling with KVM, Proxmox and various VMs. > > I setup a very basic VM with a manual (fdisk) partitioning scheme: one > /boot > partition, one swap partition, and one root partition, the latter being > the > last partition and thus expandable). > > I'm starting with a reduced disk size (6 GB in total) and a minimal > installation. The idea behind this approach is that I can clone this > minimal VM > and then eventually expand it to fit my needs. > > Here's how I expand the available disk size. > > First I increase the virtual disk in the hypervisor. > > Then I fire up the VM and do the following: > > # yum install cloud-utils-growpart > # lsblk > # growpart -v /dev/sda 3 > # resize2fs /dev/sda3 > > Now here's my question (finally): is there any risk involved in this sort > of > operation? Or can it be performed on a production system without having to > worry about data loss?I'm often doing something similar but *not* with partitions. I have either disk images or logical volumes on the KVM host which I grow and then use "virsh blockresize" to adjust size. Then on the guest I only have to resize the filesystem or in case using LVM on the guest, first "lvextend" and then resize the filesystem. Fiddling with partitions without the ability to reboot always scares me a bit. That's why I prefer not to so it and therefore I have not used "growpart". BTW, are you not using XFS these days? Regards, Simon
I'm using VirtualBox for a few VMs, the biggest one is a Ubuntu 20.04 that ocassionally grows too small, so I use virtualbox tools to enlarge the disk then boot up something that h as gparted in it and use gparted to stretch/move partitions. Not being familiar with (i.e., not having used) KVM I can't say what's the best way, but it seems to me that gparted would be easier than the steps you described., once you've changed the partition size. On Thu, Apr 8, 2021 at 11:43 AM Nicolas Kovacs <info at microlinux.fr> wrote:> Hi, > > I'm currently fiddling with KVM, Proxmox and various VMs. > > I setup a very basic VM with a manual (fdisk) partitioning scheme: one > /boot > partition, one swap partition, and one root partition, the latter being the > last partition and thus expandable). > > I'm starting with a reduced disk size (6 GB in total) and a minimal > installation. The idea behind this approach is that I can clone this > minimal VM > and then eventually expand it to fit my needs. > > Here's how I expand the available disk size. > > First I increase the virtual disk in the hypervisor. > > Then I fire up the VM and do the following: > > # yum install cloud-utils-growpart > # lsblk > # growpart -v /dev/sda 3 > # resize2fs /dev/sda3 > > Now here's my question (finally): is there any risk involved in this sort > of > operation? Or can it be performed on a production system without having to > worry about data loss? > > Cheers from the sunny South of France, > > Niki > > -- > Microlinux - Solutions informatiques durables > 7, place de l'?glise - 30730 Montpezat > Site : https://www.microlinux.fr > Blog : https://blog.microlinux.fr > Mail : info at microlinux.fr > T?l. : 04 66 63 10 32 > Mob. : 06 51 80 12 12 > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos >
You could make a copy of the VM, and? see if you can resize things? with the copy and see if it breaks? On 4/8/21 9:43 AM, Nicolas Kovacs wrote:> Hi, > > I'm currently fiddling with KVM, Proxmox and various VMs. > > I setup a very basic VM with a manual (fdisk) partitioning scheme: one /boot > partition, one swap partition, and one root partition, the latter being the > last partition and thus expandable). > > I'm starting with a reduced disk size (6 GB in total) and a minimal > installation. The idea behind this approach is that I can clone this minimal VM > and then eventually expand it to fit my needs. > > Here's how I expand the available disk size. > > First I increase the virtual disk in the hypervisor. > > Then I fire up the VM and do the following: > > # yum install cloud-utils-growpart > # lsblk > # growpart -v /dev/sda 3 > # resize2fs /dev/sda3 > > Now here's my question (finally): is there any risk involved in this sort of > operation? Or can it be performed on a production system without having to > worry about data loss? > > Cheers from the sunny South of France, > > Niki >
Antonio da Silva Martins Junior
2021-Apr-09 19:02 UTC
[CentOS] Resize a VM: any risk involved ?
Hi, Wow... I didn't know about "growpart" :) I do, however, on XenServer (now XCP-NG) almost the same thing for ages: - shutdown the VM - increase disk size on XCenter - boot VM on maintenance mode (with DVD boot) - do fdisk /dev/xvda, remove the desired partition (in your case 3), and recreate it with the same initial block and occupying the rest of the disk. - make what's is need to use the new space on the partition, in my case it's a LVM partition used as a PVE block. Than pvresize, vgextend, etc... Until now, no problems... Att., Antonio. Em qui., 8 de abr. de 2021 ?s 12:44, Nicolas Kovacs <info at microlinux.fr> escreveu:> Hi, > > I'm currently fiddling with KVM, Proxmox and various VMs. > > I setup a very basic VM with a manual (fdisk) partitioning scheme: one > /boot > partition, one swap partition, and one root partition, the latter being the > last partition and thus expandable). > > I'm starting with a reduced disk size (6 GB in total) and a minimal > installation. The idea behind this approach is that I can clone this > minimal VM > and then eventually expand it to fit my needs. > > Here's how I expand the available disk size. > > First I increase the virtual disk in the hypervisor. > > Then I fire up the VM and do the following: > > # yum install cloud-utils-growpart > # lsblk > # growpart -v /dev/sda 3 > # resize2fs /dev/sda3 > > Now here's my question (finally): is there any risk involved in this sort > of > operation? Or can it be performed on a production system without having to > worry about data loss? > > Cheers from the sunny South of France, > > Niki > > -- > Microlinux - Solutions informatiques durables > 7, place de l'?glise - 30730 Montpezat > Site : https://www.microlinux.fr > Blog : https://blog.microlinux.fr > Mail : info at microlinux.fr > T?l. : 04 66 63 10 32 > Mob. : 06 51 80 12 12 > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos >-- *Antonio da Silva Martins Jr. * *Analista de Suporte* NPD - N?cleo de Processamento de Dados UEM - Universidade Estadual de Maring? email: *asmartins at uem.br* <asmartins at uem.br> fone: +55 (44) 3011-4015 / 3011-4411 inoc-dba: 263076*100 "Real Programmers don?t need comments ? the code is obvious."
On 4/8/21 11:43 AM, Nicolas Kovacs wrote:> # yum install cloud-utils-growpart > # lsblk > # growpart -v /dev/sda 3 > # resize2fs /dev/sda3 > > Now here's my question (finally): is there any risk involved in this sort of > operation? Or can it be performed on a production system without having to > worry about data loss?Risk from a Virtual Machine perspective or just generally? One of the many operations I do often with VMs is "mess" with disks treating them as logical devices means I can add storage later, easy, when needed. In most cases I don't take the system down at all. "It just works". But there are always risks. If you're doing this manually, typos can bring down your system. Another part of your risk is using partitions. Partions, particular the "system" drive where rootfs is, can act oddly on Linux when it's live. It's not rare that you find the kernel refusing to do a "partprobe" on /dev/sda - which means you need a reboot for the kernel to see the new size of a partition. Next, your partition stuff is very limited - compared to so many other things you have in CentOS you should really avoid using partitions for anything - well, perhaps but that's about it. I use LVM on all my systems. To expand a system I simply add a new virtual disk, expand the VG, and then expand the filesystem using "lvexpand -r". It's painless and there are no risks of conflicts. LVM allows me to remove the disk later if need be - ie. the first disk size you added was 50GB but you realize a few months later that you calculated wrong as should have added 500GB. LVM allows you to add a new disk of 500GB, move everything from the old disk to the new, and then you can remove the new one - all without taking down the file system! It also comes with snapshot features for persistent backups. So at a risk of sounding like a broken record, don't use partitions. If risk is what you're focused on, there's a lot more risk using plain partitions vs. volume management. -- Regards Peter Larsen