0

I cannot resize the Virtual Hard Disk I created when setting up my Virtual Machine on Oracle Virtual Box 6.1.

I'm running Ubuntu Server 22.04 on Oracle Virtual Box 6.1 that's installed on a Windows 10 Machine.

I chose 10 GB when I started out, but now it seem that that's not enough.

I've tried resizing the Virtual Drive doing

  1. File -> Virtual -> Media Manager -> Hard disks -> Size -> 20GB

  2. Running vboxmanage.exe modifymedium "C:\Users\Core\VirtualMachines\Ubuntu Server 22.04\Ubuntu Server 22.04-disk002.vdi --resize 20480

  3. Loading gparted and resizing the drive

Even after all of this my drive still shows 8.87GB when I start Ubuntu Server 22.04.

How can I fix this? In the screen shots below you can see it says 20GB, but when Ubuntu 22.04 is powered on it shows 8.87GB.

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

1 Answer 1

0

"Regular" Ubuntu setup would look like this:

┌────────────────────────────────────────────────────────┐
│   The virtual drive                                    │
│  ┌────────┐ ┌───────────────────────────────────────┐  │
│  │        │ │  OS partition                         │  │
│  │        │ │ ┌───────────────────────────────────┐ │  │
│  │  some  │ │ │                                   │ │  │
│  │  boot  │ │ │         root filesystem           │ │  │
│  │ parti- │ │ │                                   │ │  │
│  │ tions  │ │ └───────────────────────────────────┘ │  │
│  │        │ │                                       │  │
│  └────────┘ └───────────────────────────────────────┘  │
│                                                        │
└────────────────────────────────────────────────────────┘

The usual mistake here is resizing the drive, but forgetting to resize the partition, so there's empty space after the partition but the partition (and by extension the filesystem within it) are still the same, old size. You did well by avoiding this one.

A variant of this is resizing the drive and the partition, but not the filesystem inside. GParted and similar tools do this automatically, but some users choose to delete the partition using more advanced tools (fdisk, gdisk, parted, …), then recreate it, and forget that the filesystem doesn't grow automatically to fill the partition.

In your case you have a setup with LVM. Desktop Ubuntu uses this when instructed or when you choose to enable full disk encryption. I wouldn't be surprised if this was the default for Ubuntu Server. LVM adds another layer of abstraction that gives you slightly more flexibility when distributing disk space between multiple partitions.

┌────────────────────────────────────────────────────────────────┐
│  The virtual drive                                             │
│ ┌────────┐ ┌─────────────────────────────────────────────────┐ │
│ │        │ │  Partition                                      │ │
│ │        │ │ ┌─────────────────────────────────────────────┐ │ │
│ │        │ │ │   LVM volume group                          │ │ │
│ │        │ │ │                                             │ │ │
│ │        │ │ │  ┌───────────────────────────────────────┐  │ │ │
│ │        │ │ │  │  OS volume                            │  │ │ │
│ │        │ │ │  │ ┌───────────────────────────────────┐ │  │ │ │
│ │  some  │ │ │  │ │                                   │ │  │ │ │
│ │  boot  │ │ │  │ │         root filesystem           │ │  │ │ │
│ │ parti- │ │ │  │ │                                   │ │  │ │ │
│ │ tions  │ │ │  │ └───────────────────────────────────┘ │  │ │ │
│ │        │ │ │  │                                       │  │ │ │
│ │        │ │ │  └───────────────────────────────────────┘  │ │ │
│ │        │ │ │                                             │ │ │
│ │        │ │ └─────────────────────────────────────────────┘ │ │
│ │        │ │                                                 │ │
│ └────────┘ └─────────────────────────────────────────────────┘ │
│                                                                │
└────────────────────────────────────────────────────────────────┘

You have resized the disk, the partition and the volume group, but the volume inside it and its filesystem are still the old size.

Switch to the volume group using the dropdown in the top right corner of GParted's window. If you don't see it there, you need a newer version of GParted. The one included on Ubuntu Desktop 22.04 live media should work. GRML works too, I think.

Then you'll see what's inside the volume group and you should be able to grow the partition. As I've mentioned earlier, GParted will resize the filesystem for you automatically.

3
  • I've been at this since I received your reply. After hours, I'm currently at the following screen i.imgur.com/RnS055G.jpg The dropdown at the right won't let me select anything. I cannot extend the ext4 partition with the lvm2 pv partition. I can only extend the lvm2 pv part with the unallocated space, but that still wont merge with the ext4 partition...
    – Norman
    Nov 28, 2022 at 11:36
  • @Norman This doesn't look like your previous screenshot. Previously the VG was ~19 GB and now it somehow shrunk back to 9 GB? Don't bother with /dev/sda2 - that's probably where the boot files are stored, but it's not your main partition. The main one is inside LVM.
    – gronostaj
    Nov 28, 2022 at 14:04
  • I've replicated your setup in a fresh VM. Indeed the VG doesn't appear in the dropdown, so I don't know where I took that from. Answers here suggest that GUI tools called system-config-lvm and KVPM could help if you want to see what you're doing. Otherwise console tools are available too.
    – gronostaj
    Nov 28, 2022 at 15:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .