Saat melakukan instalasi Centos 7 di saat tahap partisi hardisk dipilih auto, maka oleh sistem akan di create kan dua partisi yaitu root dan home seperti ini :
# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 136G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi ├─sda2 8:2 0 1G 0 part /boot └─sda3 8:3 0 134.8G 0 part ├─centos-root 253:0 0 50G 0 lvm / ├─centos-swap 253:1 0 3.9G 0 lvm [SWAP] └─centos-home 253:2 0 80.9G 0 lvm /home sr0 11:0 1 1024M 0 rom
Note : diatas saya menggunakan hardisk dengan ukuran 146GB dengan model LVM yang dibagi menjadi partisi root sebesar 50GB dan partisi home sebesar 81GB
Pada posting kali ini saya ingin menghilangkan partisi home dan memindahkan ukuran yang ada di home ke ukuran partisi root.
Jadi, berikut langkah-langkah yang saya lakukan :
- Backup semua data yang ada di partisi /home
Nantinya jika selesai tinggal di restore kembali - Unmount partisi /home
# umount /home/
- Cek logical volume
# lvdisplay --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID VMCdPi-f8Ul-P68T-4sHw-ZKHj-0tTu-k3Thpw LV Write Access read/write LV Creation host, time docker-bm, 2018-08-20 09:34:56 +0700 LV Status available # open 2 LV Size <3.88 GiB Current LE 992 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 --- Logical volume --- LV Path /dev/centos/home LV Name home VG Name centos LV UUID JLydcy-INAk-hzOq-BM7Z-EuCD-apjA-0GYiDB LV Write Access read/write LV Creation host, time docker-bm, 2018-08-20 09:34:56 +0700 LV Status available # open 0 LV Size 80.89 GiB Current LE 20709 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:2 --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID fusVxI-RmSL-PHj6-6TiH-58P8-aYpf-SedcI2 LV Write Access read/write LV Creation host, time docker-bm, 2018-08-20 09:34:57 +0700 LV Status available # open 1 LV Size 50.00 GiB Current LE 12800 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
- Sekarang remove logical volume dari partisi home
[root@hosting-docker ~]# lvremove /dev/centos/home Do you really want to remove active logical volume centos/home? [y/n]: y Logical volume "home" successfully removed
- Dengan menggunakan perintah vgs, sekarang seharusnya ada ruang bebas yang tersedia di bagian VFree
# vgs VG #PV #LV #SN Attr VSize VFree centos 1 2 0 wz--n- 134.77g <80.90g
- Sekarang resize partisi root
# lvextend --size +80.80GB -r /dev/mapper/centos-root Rounding size to boundary between physical extents: 80.80 GiB. Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 130.80 GiB (33485 extents). Logical volume centos/root successfully resized. meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=3276800 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=13107200, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=6400, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 13107200 to 34288640
Note : Ukuran partisi yang akan dipindahkan isikan kurang dari ruang yang tersedia, ini untuk mencegah terjadinya error pada ruang yang tersedia
- Cek ukuran partisi root yang baru
# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 136G 0 disk ├─sda1 8:1 0 200M 0 part /boot/efi ├─sda2 8:2 0 1G 0 part /boot └─sda3 8:3 0 134.8G 0 part ├─centos-root 253:0 0 130.8G 0 lvm / └─centos-swap 253:1 0 3.9G 0 lvm [SWAP] sr0 11:0 1 1024M 0 rom
- Hapus mount dari partisi home yang ada di file fstab
# sed -i '/centos-home/d' /etc/fstab
- Terakhir, reboot server dan selesai
# reboot
Terima kasih sangat membantu, ijin bertanya kalo mount partisi yang ada di direktori /etc/fstab cukup di disable apa direkomendasikan?
kalo ada perlu ditambahkan, cukup ditambahkan di baris berikutnya kemudia di load ulang konfigurasi fstab yang baru