Extend Root Partition Without LVM

Extend partisi root tanpa lvm

  • Login ke server dengan ssh, existing root size 20GB, size disk 600GB
  • Cek partisi linux, root partisi ada di sda2 sebesar 20GB
root@lacak-mobil:~# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0      2:0    1    4K  0 disk
loop0    7:0    0 61.9M  1 loop /snap/core20/1169
loop1    7:1    0 55.5M  1 loop /snap/core18/1988
loop2    7:2    0 69.9M  1 loop /snap/lxd/19188
loop3    7:3    0 67.2M  1 loop /snap/lxd/21835
loop4    7:4    0 32.3M  1 loop /snap/snapd/11107
loop5    7:5    0 55.5M  1 loop /snap/core18/2246
loop6    7:6    0 32.5M  1 loop /snap/snapd/13640
sda      8:0    0  600G  0 disk
├─sda1   8:1    0    1M  0 part
└─sda2   8:2    0   20G  0 part /
sr0     11:0    1 1024M  0 rom
  • Cek type file system, partisi root mengunakan file system ext4
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs   16G     0   16G   0% /dev
tmpfs          tmpfs     3.2G  1.2M  3.2G   1% /run
/dev/sda2      ext4      20G   5.0G   14G  27% /
tmpfs          tmpfs      16G     0   16G   0% /dev/shm
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs      16G     0   16G   0% /sys/fs/cgroup
/dev/loop1     squashfs   56M   56M     0 100% /snap/core18/1988
/dev/loop2     squashfs   70M   70M     0 100% /snap/lxd/19188
/dev/loop4     squashfs   33M   33M     0 100% /snap/snapd/11107
/dev/loop5     squashfs   56M   56M     0 100% /snap/core18/2246
/dev/loop6     squashfs   33M   33M     0 100% /snap/snapd/13640
/dev/loop0     squashfs   62M   62M     0 100% /snap/core20/1169
/dev/loop3     squashfs   68M   68M     0 100% /snap/lxd/21835
tmpfs          tmpfs     3.2G     0  3.2G   0% /run/user/0
  • Untuk extend partisi harus install tool cloud utils dan menggunakan growpart.
  • Install cloud utils pada linux ubuntu
sudo apt -y install cloud-guest-utils gdisk
  • Install cloud utils pada linux centos
sudo yum -y install cloud-utils-growpart gdisk
  • Gunakan growpart untuk extend partisi root sda2, angka 2 merupakan sub-partisi nomor 2 yang berarti sda2.
root@lacak-mobil:~# growpart /dev/sda 2
CHANGED: partition=2 start=4096 old: size=41936896 end=41940992 new: size=1258287071 end=1258291167
  • Resize partisi root dengan resize2fs, jika file system menggunakan xfs maka gunakan xfs_growfs -d
root@lacak-mobil:~# resize2fs /dev/sda2
resize2fs 1.45.5 (07-Jan-2020)
Filesystem at /dev/sda2 is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 75
The filesystem on /dev/sda2 is now 157285883 (4k) blocks long.
  • Cek kembali partisi linux, maka size partisi root sudah berubah menjadi 600GB
root@lacak-mobil:~# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
fd0      2:0    1    4K  0 disk
loop0    7:0    0 61.9M  1 loop /snap/core20/1169
loop1    7:1    0 55.5M  1 loop /snap/core18/1988
loop2    7:2    0 69.9M  1 loop /snap/lxd/19188
loop3    7:3    0 67.2M  1 loop /snap/lxd/21835
loop4    7:4    0 32.3M  1 loop /snap/snapd/11107
loop5    7:5    0 55.5M  1 loop /snap/core18/2246
loop6    7:6    0 32.5M  1 loop /snap/snapd/13640
sda      8:0    0  600G  0 disk
├─sda1   8:1    0    1M  0 part
└─sda2   8:2    0  600G  0 part /
sr0     11:0    1 1024M  0 rom

root@lacak-mobil:~# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
udev           devtmpfs   16G     0   16G   0% /dev
tmpfs          tmpfs     3.2G  1.2M  3.2G   1% /run
/dev/sda2      ext4      591G  5.1G  562G   1% /
tmpfs          tmpfs      16G     0   16G   0% /dev/shm
tmpfs          tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs          tmpfs      16G     0   16G   0% /sys/fs/cgroup
/dev/loop1     squashfs   56M   56M     0 100% /snap/core18/1988
/dev/loop2     squashfs   70M   70M     0 100% /snap/lxd/19188
/dev/loop4     squashfs   33M   33M     0 100% /snap/snapd/11107
/dev/loop5     squashfs   56M   56M     0 100% /snap/core18/2246
/dev/loop6     squashfs   33M   33M     0 100% /snap/snapd/13640
/dev/loop0     squashfs   62M   62M     0 100% /snap/core20/1169
/dev/loop3     squashfs   68M   68M     0 100% /snap/lxd/21835
tmpfs          tmpfs     3.2G     0  3.2G   0% /run/user/0

herdiana3389

A system administrator with skills in system administration, virtualization, linux, windows, networking, cloud computing, container, etc.