VMWare Ubuntu 20.04 increase disk
The disk of my Ubuntu 20.04 used for development was originally 20Gb, and I increased it to 30GB a while ago. This time, the capacity was insufficient again, so I increased it to 50 GB. Every time I did this work, I had a hard time, so I'm going to leave it as a simple post so that I don't repeat the trouble afterwards.
The following is a disk with 30 GB status. The usage is 50%. However, this is because there was not enough disk and the files were temporarily moved to another location. After increasing the disk capacity, the backed up files will be imported again.
root@ubuntusrv:~# df -h Filesystem Size Used Avail Use% Mounted on udev 937M 0 937M 0% /dev tmpfs 196M 1.3M 195M 1% /run /dev/mapper/ubuntu--vg-ubuntu--lv 29G 14G 14G 50% / tmpfs 980M 0 980M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 980M 0 980M 0% /sys/fs/cgroup /dev/sda2 976M 386M 524M 43% /boot /dev/loop1 62M 62M 0 100% /snap/core20/1081 /dev/loop2 56M 56M 0 100% /snap/core18/1997 /dev/loop0 56M 56M 0 100% /snap/core18/2128 /dev/loop3 33M 33M 0 100% /snap/snapd/13170 /dev/loop5 73M 73M 0 100% /snap/lxd/21497 /dev/loop4 33M 33M 0 100% /snap/snapd/12883 /dev/loop6 69M 69M 0 100% /snap/lxd/21390 tmpfs 196M 0 196M 0% /run/user/0
<Total 29GB, 14GB used >
Increase disk size in VMWare
First, shut down the Ubuntu VM. To free the disk allocated to the VM in VMWare, you must first shut down(Not suspend) the VM.
Then go to VM /Settings... And press the Expand... Button. Then enter the desired disk size.
Working with disk growth in Ubuntu
Now boot Ubuntu. And to make things easier, we install gparted, a GUI tool. My Ubuntu is in text-based server mode, not desktop mode. However, if you are using an ssh client that supports X11 (Moba XTerm), you can also use a GUI program.
Install gparted
gparted is installed with the apt command.
sudo apt install gparted
The following is information before disk expansion.
root@ubuntusrv:~# fdisk -l Device Start End Sectors Size Type /dev/sda1 2048 4095 2048 1M BIOS boot /dev/sda2 4096 2101247 2097152 1G Linux filesystem /dev/sda3 2101248 41940991 39839744 19G Linux filesystem /dev/sda4 41940992 101562500 59621509 28.4G Linux filesystem root@ubuntusrv:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT fd0 2:0 1 1.4M 0 disk loop0 7:0 0 55.4M 1 loop /snap/core18/2128 loop1 7:1 0 55.5M 1 loop /snap/core18/1997 loop2 7:2 0 69M 1 loop /snap/lxd/21390 loop3 7:3 0 32.3M 1 loop /snap/snapd/12883 loop4 7:4 0 61.8M 1 loop /snap/core20/1081 loop5 7:5 0 72.5M 1 loop /snap/lxd/21497 loop6 7:6 0 32.3M 1 loop /snap/snapd/13170 sda 8:0 0 50G 0 disk ├─sda1 8:1 0 1M 0 part ├─sda2 8:2 0 1G 0 part /boot ├─sda3 8:3 0 19G 0 part │ └─ubuntu--vg-ubuntu--lv 253:0 0 28.9G 0 lvm / └─sda4 8:4 0 28.4G 0 part └─ubuntu--vg-ubuntu--lv 253:0 0 28.9G 0 lvm / sr0 11:0 1 91.9M 0 rom sr1 11:1 1 1024M 0 rom root@ubuntusrv:~# vgdisplay --- Volume group --- VG Name ubuntu-vg System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 2 Act PV 2 VG Size 28.99 GiB PE Size 4.00 MiB Total PE 7422 Alloc PE / Size 7398 / <28.90 GiB Free PE / Size 24 / 96.00 MiB VG UUID R78YcV-W8iy-Pgym-azqq-oZtC-qaM4-M1aFJ9 root@ubuntusrv:~# lvdisplay --- Logical volume --- LV Path /dev/ubuntu-vg/ubuntu-lv LV Name ubuntu-lv VG Name ubuntu-vg LV UUID nvCCIi-Uz38-7dlc-exDH-5Oam-CAbt-9UVN3n LV Write Access read/write LV Creation host, time ubuntu-server, 2020-07-18 18:28:51 +0900 LV Status available # open 1 LV Size <28.90 GiB Current LE 7398 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
The following figure shows disk /dev/sda4 expanded from 10GB to 30GB using gparted.
In the original initial state, the unallocated area below was 20 GB.
After selecting the disk to be extended as follows, select Resize/Move to bring the Unallocated area. Then the sda4 area will increase as shown in the figure above.
Finally, click the green check button at the top to apply the action.
Changes are confirmed with the fdisk command, but nothing has changed when the mount information is checked with the df command.
Device Start End Sectors Size Type /dev/sda1 2048 4095 2048 1M BIOS boot /dev/sda2 4096 2101247 2097152 1G Linux filesystem /dev/sda3 2101248 41940991 39839744 19G Linux filesystem /dev/sda4 41940992 104855551 62914560 30G Linux filesystem
<fdisk command shows the changes>
However, the mount point (/) checked with the df command does not change.
root@ubuntusrv:~# df -h Filesystem Size Used Avail Use% Mounted on udev 937M 0 937M 0% /dev tmpfs 196M 1.3M 195M 1% /run /dev/mapper/ubuntu--vg-ubuntu--lv 29G 14G 14G 50% / tmpfs 980M 0 980M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 980M 0 980M 0% /sys/fs/cgroup /dev/sda2 976M 386M 524M 43% /boot /dev/loop1 62M 62M 0 100% /snap/core20/1081 /dev/loop2 56M 56M 0 100% /snap/core18/1997 /dev/loop0 56M 56M 0 100% /snap/core18/2128 /dev/loop3 33M 33M 0 100% /snap/snapd/13170 /dev/loop5 73M 73M 0 100% /snap/lxd/21497 /dev/loop4 33M 33M 0 100% /snap/snapd/12883 /dev/loop6 69M 69M 0 100% /snap/lxd/21390 tmpfs 196M 0 196M 0% /run/user/0
<df command shows the no changes>
Final Task
However, at this point, if you check with the df command, nothing has changed.
If you use LVM (Logical Volume Manager) like me, the finishing work is done as follows. Check the LV Path again with the lvdisplay command.
root@ubuntusrv:~# lvdisplay --- Logical volume --- LV Path /dev/ubuntu-vg/ubuntu-lv LV Name ubuntu-lv VG Name ubuntu-vg LV UUID nvCCIi-Uz38-7dlc-exDH-5Oam-CAbt-9UVN3n LV Write Access read/write LV Creation host, time ubuntu-server, 2020-07-18 18:28:51 +0900 LV Status available # open 1 LV Size <28.90 GiB Current LE 7398 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
Finally, if you are using LVM, do two things:
root@ubuntusrv:~# lvextend /dev/ubuntu-vg/ubuntu-lv -l +100%FREE root@ubuntusrv:~#resize2fs /dev/ubuntu-vg/ubuntu-lv
Next reboot the system, and I can check the 50GB disk like this.
root@ubuntusrv:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 937M 0 937M 0% /dev
tmpfs 196M 1.3M 195M 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 49G 14G 33G 29% /
tmpfs 980M 0 980M 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 980M 0 980M 0% /sys/fs/cgroup
/dev/sda2 976M 386M 524M 43% /boot
/dev/loop0 56M 56M 0 100% /snap/core18/1997
/dev/loop1 33M 33M 0 100% /snap/snapd/13170
/dev/loop2 69M 69M 0 100% /snap/lxd/21390
/dev/loop3 73M 73M 0 100% /snap/lxd/21497
/dev/loop5 56M 56M 0 100% /snap/core18/2128
/dev/loop4 33M 33M 0 100% /snap/snapd/12883
/dev/loop6 62M 62M 0 100% /snap/core20/1081
tmpfs 196M 4.0K 196M 1% /run/user/0
댓글
댓글 쓰기