1

I have a Linux (Virtual) Machine that is running into a storage problem. There is a disk called vda that is split into three partitions, vda1, vda2, and vda3. Originally, vda only had a storage capacity of 25GB but I've increased it to 150GB in light of the problem I'm having - the partition vda1 that is mounted as / maxed out its storage (~22GB).

[root@servername ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda    253:0    0  150G  0 disk
├─vda1 253:1    0 21.5G  0 part /
├─vda2 253:2    0  2.5G  0 part [SWAP]
└─vda3 253:3    0    1G  0 part /boot

Since I've increased the size of this disk now to 150GB, how can I extend the size of the partition vda1 that is mounted to /, without ruining (or potentially ruining) the machine or without ruining the /boot mount on partition vda3?

More details:

vda1 extends from 5 to 88410 of 616809

vda2 extends from 88410 to 98690 of 616809

vda3 extends from 98690 to 102802 of 616809

This virtual machine is running Rocky Linux 8, if that is useful.

Extra ramblings:

I worry that if I just create a new large partition (say vda4), then copy the data from vda1 to vda4, then unmount vda1 from \ to re-mount vda4 as \... I'll run into a problem where my machine will not have a \ mount for that brief time beteween unmounting and remounting and everything will break.

Frighteningly, I am the single Linux admin person for my department with zero formal Linux admin training. I'm learning as I go and have figured some things out on my own, but Linux admin is a small part of my job so I'm struggling with this! And also reaaaaally not wanting to have to rebuild a whole machine if this goes down.

I've looked over other questions like this one, but those answers (seemed to) assume that the partition wanted to be extended was at the end of a disk, like vda3 is. And I'm really worried about it! I really don't want to mess this up.

There is a question here from 2016 - is the process from there the same as I want to do here? Will my system be messed up while / is moved?

  • I would boot a gparted-live image in that VM - `gparted` should make it relatively safe and easy to move things around - relatively being key, there's always a risk, so **create a backup** should always be step 1 when performing this type of task - the process on the question you linked to is "the same" in that the solution is to use a live disk, preferably with gparted - but in your case it should be really simple since you should be able to move partitions freely – Jaromanda X Jun 03 '23 at 03:37
  • The LVM route is complicated so if you have limited Linux experience I wouldn’t recommend it. If you can boot a GParted live environment it is easy. If you cannot do that you need to look for a command line solution such as this https://unix.stackexchange.com/questions/744069/move-a-partition-to-the-right-using-command-line-tools – PonJar Jun 03 '23 at 09:43
  • So, it's a VM, do you have shell access to the host machine? – Jasen Jun 03 '23 at 12:11
  • if so, what OS is the host? – Jasen Jun 03 '23 at 12:19
  • @Jasen the host is CentOS 6 and I do have shell access to the host. – 32tv45twgfr Jun 03 '23 at 13:10
  • @32tv45twgfr When i was using Linux. I never really knew the commands to resize just fdisk to install things like the Distro etc. when I wanted to resize stuff or format stuff I always used gparted. it saved me lots of times. – Big Joe Jun 04 '23 at 00:45

1 Answers1

1

As it's a virtual machine on a linux host you can shut-down the VM and use gparted on the host against the image file to resize the partition

Jasen
  • 3,715
  • 13
  • 14
  • +1 for gparted, it's the right tool for the job. And doing it from the host machine while the VM is shut down is also good (although booting the VM with a gparted ISO image would also work). Also worth mentioning: it would probably be a good idea to move the vda1 partition so that it's after vda2 and vda3, and then extend it. That will make it easier to enlarge again in future if required. The alternative is to move vda2 and vda3 to the end of the disk (and move them again next time the disk is re-sized). – cas Jun 04 '23 at 11:09
  • Moving /boot means putting the partitions in non-numerical order, (or else possibly breaking the boot loader) , I know hat linux is fine with random order, and that this virtual machine will never see a different OS but it's still something I try to avoid. – Jasen Jun 04 '23 at 14:50