L
L
lagudal2022-03-15 14:01:46
virtual box
lagudal, 2022-03-15 14:01:46

How to correctly increase disk size of ubuntu server under virtualbox?

The vdi disk, using virtualbox increased its size to 25G, now in the virtualbox settings I see the new disk size, but in the guest system (ubuntu server 20.04) the size is the same (20 G)
I can’t understand where these 5 gigs have gone, how to add them to the partition ?
findings:

# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            1.9G     0  1.9G   0% /dev
tmpfs           394M  724K  393M   1% /run
/dev/sda1        20G   18G  950M  96% /
tmpfs           2.0G     0  2.0G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           2.0G     0  2.0G   0% /sys/fs/cgroup
tmpfs           394M     0  394M   0% /run/user/0


~# parted
GNU Parted 3.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sda: 21.5GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  21.5GB  21.5GB  primary  ext4         boot

(parted) resizepart 1                                                     
Warning: Partition /dev/sda1 is being used. Are you sure you want to continue?
Yes/No? yes                                                               
End?  [21.5GB]? 24.5G                                                     
Error: The location 24.5G is outside of the device /dev/sda.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
lagudal, 2022-03-16
@lagudal

Problem solved - in case anyone else comes across:
how to resize a virtual disk.
1. With the virtual machine running, execute the command :

sh-3.2# VBoxManage modifyhd --resize 26725 /Users/alex/VirtualBox\ VMs/userver\ 2004/Snapshots/{5ef573a7-a19b-4c5b-a48f-5d74132b0f4a}.vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

It is important to slip not the virtual disk itself into VBoxManage (I previously upgraded it), but snapshots - I have one for backup, and one reflects the current state, which one can be found out by unmounting and re-mounting the disk, selecting the state from dropdown. Or just increase for all snapshots.
Interestingly, I found this solution almost immediately, but applied it on a turned off VM, and I got an error. On the working everything is ok.
2. Turn off the VM and remount the virtual disk.
3. We start the VM and in the guest OS we see free space - in any convenient way (gparted etc) we expand our partition.
All.

D
Drno, 2022-03-15
@Drno

This is because the section has increased, and the file system is not aware of this
, there are two options.
1. boot from liveCD gparted and expand the disk
2. to "live". I do this on remote VPS
https://askubuntu.com/questions/116351/increase-pa...
Well, of course, instead of the swap partition, you need to carry out all the actions with the existing partition

R
rPman, 2022-03-15
@rPman

something went wrong with the increase in disk size, I
advise you to spit and solve the problem by creating a new disk and cloning data using partclone, booting from livecd inside a virtual machine or clonezilla

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question