Score:1

Extend Ubuntu virtual disk partition in absence of a swap partition

pw flag

On a Windows 10 laptop, I installed Ubuntu 20.04.3 LTS (ubuntu-20.04.3-desktop-amd64.iso) on VirtualBox 6.1.28. I alloted 20GB to the virtual disk, but am running out of room. I followed this page to resize the virtual disk to 40GB.

I tried to follow the 3 pages below to extend the partition used by Ubuntu. They all refer to a swap partition.

Is there a dummy's process to extend my Ubuntu partition in the absence of a swap partition?

Here are the 3 pages I tried to follow...

(1) Use gparted in a live running Ubuntu VM

enter image description here

I can't follow the procedure because I have no line item that corresponds to a swap partition (at least not that I recognize). I assume that sda5 is my main file system since it is 20GB and mostly used. I right-clicked it and chose "Resize/Move".

enter image description here

The new size "19965" seems suspiciously close to the original 20GB size, so I entered 2x that amount (39930). Unfortunately, it is not accepted. If I press Return or Tab, it reverts back to 19965. I can't simply click the "Resize" button because it is grayed out.

(2) Use fdisk -l

The result of df -h is:

Filesystem Size Used Avail Use% Mounted on
udev       1.9G    0  1.9G   0% /dev
tmpfs      394M 1.3M  393M   1% /run
/dev/sda5   20G  15G  3.4G  82% /
tmpfs      2.0G 6.2M  2.0G   1% /dev/shm
tmpfs      5.0M 4.0K  5.0M   1% /run/lock
tmpfs      2.0G    0  2.0G   0% /sys/fs/cgroup
/dev/loop0 128K 128K     0 100% /snap/bare/5
/dev/loop2  56M  56M     0 100% /snap/core18/2128
/dev/loop3 219M 219M     0 100% /snap/gnome-3-34-1804/72
/dev/loop1  56M  56M     0 100% /snap/core18/2246
/dev/loop4  66M  66M     0 100% /snap/gtk-common-themes/1519
/dev/loop5  51M  51M     0 100% /snap/snap-store/547
/dev/loop6  33M  33M     0 100% /snap/snapd/12704
/dev/loop7  33M  33M     0 100% /snap/snapd/13640
/dev/loop8  66M  66M     0 100% /snap/gtk-common-themes/1515
/dev/sda1  511M 4.0K  511M   1% /boot/efi
User.Name  476G 237G  240G  50% /media/sf_User.Name
tmpfs      394M  48K  394M   1% /run/user/1000
/dev/sr0    59M  59M     0 100% /media/lnxadmin/VBox_GAs_6.1.28

I didn't follow the subsequent fdisk -l because it makes reference to a swap partition, which I don't have. Plus, it refers to VM Workstation, which I do not have.

(3) Use fdisk /dev/sda

After launching the fdisk app using fdisk /dev/sda, I entered p to see the partitions:

Device    Boot   Start      End  Sectors  Size Id Type
/dev/sda1 *       2048  1050623  1048576  512M  b W95 FAT32
/dev/sda2      1052670 41940991 40888322 19.5G  5 Extended
/dev/sda5      1052672 41940991 40888320 19.5G 83 Linux

Again, I have no swap partition. Since the procedure refers to a swap partition, I abandoned this as well.

in flag
You will need to first expand `/dev/sda2` to use the 40GB, *then* expand `/dev/sda5`
pw flag
Thanks, will give it a go. I suspect that I have to be very precise. For sda5, can I simply double the 19965 to 39930? I'm not sure if it matters, but the current size of sda2 slightly different from sda5 -- sda2 is 19966 MiB (but can be extended to 40446 MiB).
in flag
The precision is handled by the system. Just have the partitions use the full space, and the software will handle the rest
pw flag
@matigo: It works! Thanks!! There are probably many people like me who move to an Ubuntu VM out of necessity, but without any Linux experience. Your comment can probably save them a *ton* of time. Would you please post it as an answer? Maybe with a (very brief) explanation of what it means for a partition to be a subordinate of another (e.g., sda2 under sda5)?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.