Resize disk root (/) VM linux in proxmox, vmware, or openstack

Step :

1. Shutdown VM
2. Add harddisk, example : 60 GB
3. Start VM

jalankan command berikut :

[root@hris hris]# fdisk -l

Disk /dev/sdb: 64.4 GB, 64424509440 bytes, 125829120 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 34.4 GB, 34359738368 bytes, 67108864 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0002985b

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    67108863    32504832   8e  Linux LVM

Note : disk /dev/sdb adalah disk yang baru kita tambahkan.

Buat physical volume.
[root@hris html]pvcreate /dev/sdb

cek volume group yang sudah ada (/dev/sda)
[root@hris html]# vgdisplay
  --- Volume group ---
  VG Name               cl
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  
Extend disk /dev/sdb ke volume group "cl" dengan command berikut : 
[root@hris html]# vgextend cl /dev/sdb
[root@hris html]# vgdisplay
[root@hris html]# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/cl-root   89G  3.6G   86G   4% /
devtmpfs             886M     0  886M   0% /dev
tmpfs                896M  8.0K  896M   1% /dev/shm
tmpfs                896M  8.5M  888M   1% /run
tmpfs                896M     0  896M   0% /sys/fs/cgroup
/dev/sda1           1014M  184M  831M  19% /boot
tmpfs                180M     0  180M   0% /run/user/0
note : Disk size sudah bertambah menjadi 86GB.

Langkah selanjutnya adalah extending logical volume.
Lakukan command berikut dan lakukan extending logical volume ke LV path yang di mounting ke disk / (root).

[root@hris html]# lvextend -L +60G /dev/mapper/cl-root

Untuk mengalokasikan disk yang baru kita tambah, maka kita perlu melakukan perintah dibawah ini.

[root@hris html]# xfs_growfs /dev/mapper/cl-root
[root@hris html]# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/cl-root   89G  3.6G   86G   4% /
devtmpfs             886M     0  886M   0% /dev
tmpfs                896M  8.0K  896M   1% /dev/shm
tmpfs                896M  8.5M  888M   1% /run
tmpfs                896M     0  896M   0% /sys/fs/cgroup
/dev/sda1           1014M  184M  831M  19% /boot
tmpfs                180M     0  180M   0% /run/user/0

Selesai, disk root sudah bertambah dari 30 GB menjadi 90 GB.

Comments