Panduan kali ini akan mencoba mengelola LVM. Ini melanjutkan postingan yang sebelumnya dibuat pada laman Cara membuat Logical Volume. Lalu pada Case kali ini akan mencoba menambahkan sebuah disk ke Volume Group dan terakhir resize partisi XFS
Buat Partisi LVM #
fdisk /dev/vdb
Setting disk label ke GPT
root@aws-cli:~# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x753e2243.
Command (m for help): g
Created a new GPT disklabel (GUID: F25BC283-7CF4-7646-B1AD-0A0763666708).
Sesuaikan dengan disk yang lain. misal disk lain memakai msdos maka setting dengan msdos
Buat partisi
Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-41943006, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943006, default 41943006):
Created a new partition 1 of type 'Linux filesystem' and of size 20 GiB.
Setting type partisi menjadi Linux LVM
Command (m for help): t
Selected partition 1
Partition type or alias (type L to list all): L
29 Linux RAID A19D880F-05FC-4D3B-A006-743F0F84911E
30 Linux LVM E6D6D379-F507-44C2-A23C-238F2A3DF928
31 Linux variable data 4D21B016-B534-45C2-A9FB-5C16E091FD2D
Partition type or alias (type L to list all): 30
Changed type of partition 'Linux filesystem' to 'Linux LVM'.
Cek info partisi
Command (m for help): p
Disk /dev/vdb: 20 GiB, 21474836480 bytes, 41943040 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
Disklabel type: gpt
Disk identifier: F25BC283-7CF4-7646-B1AD-0A0763666708
Device Start End Sectors Size Type
/dev/vdb1 2048 41943006 41940959 20G Linux LVM
Jika sudah sesuai. Selanjutnya save agar partisi table tersimpan
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
Add disk ke volume group #
Setup physical volume agar dapat digunakan oleh LVM
root@aws-cli:~# pvcreate /dev/vdb1
Physical volume "/dev/vdb1" successfully created.
Add pyhsical volume ke volume group
root@aws-cli:~# vgextend -Ay vg_root /dev/vdb1
Volume group "vg_root" successfully extended
Atur space logical volume
root@aws-cli:~# lvextend -l +100%FREE vg_root/root
Size of logical volume vg_root/root changed from <2.89 GiB (739 extents) to 22.88 GiB (5858 extents).
Logical volume vg_root/root successfully resized.
Resize Logical Volume #
Cek disk usage
root@aws-cli:~# df -hT
Filesystem Type Size Used Avail Use% Mounted on
tmpfs tmpfs 198M 1.1M 197M 1% /run
/dev/mapper/vg_root-root xfs 2.9G 2.7G 234M 93% /
tmpfs tmpfs 988M 0 988M 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/vda15 vfat 105M 5.3M 100M 5% /boot/efi
tmpfs tmpfs 198M 4.0K 198M 1% /run/user/0
Untuk resize partisi root (/) gunakan perintah
xfs_growfs /
Cek kembali disk usage
root@aws-cli:~# df -hT
Filesystem Type Size Used Avail Use% Mounted on
tmpfs tmpfs 198M 1.1M 197M 1% /run
/dev/mapper/vg_root-root xfs 23G 2.8G 21G 13% /
tmpfs tmpfs 988M 0 988M 0% /dev/shm
tmpfs tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/vda15 vfat 105M 5.3M 100M 5% /boot/efi
tmpfs tmpfs 198M 4.0K 198M 1% /run/user/0