Tutorial ini akan membahas bagaimana cara membuat partisi LVM pada CentOS 7. Tutorial ini hampir mirip dengan tulisan saya sebelumnya, jika belum baca silahkan baca Cara Membuat Partisi CentOS 7 Via Command Line.
Oke langsung saja kita mulai bagaimana cara membuat partisi LVM pada CentOs 7.
Pertama cek dahulu partisi hardisk yang ada, menggunakan perintah dibawah ini
[root@localhost ~]# fdisk -l Disk /dev/sda: 8589 MB, 8589934592 bytes, 16777216 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: 0x000d82e0 Device Boot Start End Blocks Id System /dev/sda1 * 2048 3246079 1622016 83 Linux /dev/sda2 3246080 8486911 2620416 8e Linux LVM Disk /dev/mapper/rahmat-sistem: 2143 MB, 2143289344 bytes, 4186112 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/mapper/rahmat-swap: 536 MB, 536870912 bytes, 1048576 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
Nah kemudian kita buat partisi baru pada /dev/sda menggunakan sisa space yang ada (yang belum terpartisi) dengan perintah dibawah ini
[root@localhost ~]# fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): n (pilih n, untuk membuat partisi baru) Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p (pilih p untuk pripary) Partition number (3,4, default 3): 3 (pilih 3 untuk default) First sector (8486912-16777215, default 8486912): 8486912 Last sector, +sectors or +size{K,M,G} (8486912-16777215, default 16777215): 16777215 Partition 3 of type Linux and of size 4 GiB is set Command (m for help): p (ketik p untuk print) Disk /dev/sda: 8589 MB, 8589934592 bytes, 16777216 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: 0x000d82e0 Device Boot Start End Blocks Id System /dev/sda1 * 2048 3246079 1622016 83 Linux /dev/sda2 3246080 8486911 2620416 8e Linux LVM /dev/sda3 8486912 16777215 4145152 83 Linux (partisi baru sudah berhasil, selanjutnya ubah ke LVM) Command (m for help): t (ketik t, untuk mengibah partisi) Partition number (1-3, default 3): 3 (3 untuk default) Hex code (type L to list all codes): L (ketik L untuk melihat kode hex) 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx 5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data 6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / . 7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility 8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt 9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi eb BeOS fs e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD ee GPT f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/ 10 OPUS 55 EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b 11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f1 SpeedStor 12 Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor 14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f2 DOS secondary 16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS 17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto 1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fe LANstep 1c Hidden W95 FAT3 75 PC/IX be Solaris boot ff BBT 1e Hidden W95 FAT1 80 Old Minix Hex code (type L to list all codes): 8e (pilih 8e, linux LVM) Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): w (kemudian w, untuk membaca partisinya) The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
Jika sudah selesai jalankan perintah partprobe agar OS bisa membaca tabel partisi yang sudah kita buat.
[root@localhost ~]# partprobe
Kemudian cek apakah setinga partisi sudah berubah ke LVM, dengan perintah berikut
[root@localhost ~]# fdisk -l Disk /dev/sda: 8589 MB, 8589934592 bytes, 16777216 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: 0x000d82e0 Device Boot Start End Blocks Id System /dev/sda1 * 2048 3246079 1622016 83 Linux /dev/sda2 3246080 8486911 2620416 8e Linux LVM /dev/sda3 8486912 16777215 4145152 8e Linux LVM (/dev/sda3 sudah menjadi LVM) Disk /dev/mapper/rahmat-sistem: 2143 MB, 2143289344 bytes, 4186112 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/mapper/rahmat-swap: 536 MB, 536870912 bytes, 1048576 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
Kemudian buat phisical volume untuk /dev/sda3,
[root@localhost ~]# pvcreate /dev/sda3 Physical volume "/dev/sda3" successfully created.
Lalu jika sudah cek apakah phisical volume yang kita buat menggunakan perintah dibawah ini
[root@localhost ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda3 lvm2 a-- <3,95g 0
Untuk cek lebih detail menggunakan perintah berikut
[root@localhost ~]# pvdisplay "/dev/sda3" is a new physical volume of "3,95 GiB" --- NEW Physical volume --- PV Name /dev/sda3 VG Name PV Size 3,95 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID Gd2Fra-IXb2-wpsK-kooZ-7U2r-q8xX-mWKmRP
Selanjutnya buat volume group ‘colo‘ pada phisical volume /dev/sda3
[root@localhost ~]# vgcreate colo /dev/sda3 Volume group "colo" successfully created
Kemudian cek volume group yang sudah kita buat menggunakan perintah berikut
[root@localhost ~]# vgs VG #PV #LV #SN Attr VSize VFree colo 1 1 0 wz--n- <3,95g 0 (volume group)
Jika ingin melihat detilenya ketikan perintah berikut
[root@localhost ~]# vgdisplay --- Volume group --- VG Name colo System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 2 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size <3,95 GiB PE Size 4,00 MiB Total PE 1011 Alloc PE / Size 1011 / <3,95 GiB Free PE / Size 0 / 0 VG UUID 6FZHtu-2F14-5Ohy-pXfG-ysre-rKw9-YitMkt
Kemudian buat logical volume menggunakan perintah berikut
[root@localhost ~]# lvcreate --name tomat -l 100%FREE colo Logical volume "tomat" created.
Kemudian cek menggunakan perintah berikut
[root@localhost ~]# lvdisplay --- Logical volume --- LV Path /dev/colo/tomat LV Name tomat VG Name colo LV UUID OvkzqW-bUYu-xcwl-LPmp-U9QY-QwMF-pwys2B LV Write Access read/write LV Creation host, time localhost.localdomain.aa, 2018-07-21 04:45:46 -0400 LV Status available # open 0 LV Size <3,95 GiB Current LE 1011 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2
Jika sudah kemudian lakukan format untuk /dev/colo/tomat
[root@localhost ~]# mkfs.ext4 /dev/colo/tomat mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 259072 inodes, 1035264 blocks 51763 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1061158912 32 block groups 32768 blocks per group, 32768 fragments per group 8096 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736 Allocating group tables: done Writing inode tables: done Creating journal (16384 blocks): done Writing superblocks and filesystem accounting information: done
Setelah itu buat folder baru /tomatpartisi untuk mount /dev/colo/tomat dengan perintah dibawah ini
[root@localhost ~]# mkdir -p /tomatpartisi [root@localhost ~]# mount /dev/colo/tomat /tomatpartisi
Lalu untuk mengecek apakah sudah ter-mount cek menggunakan perintah dibawah
[root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/rahmat-sistem 2,0G 954M 909M 52% / devtmpfs 484M 0 484M 0% /dev tmpfs 496M 0 496M 0% /dev/shm tmpfs 496M 6,8M 490M 2% /run tmpfs 496M 0 496M 0% /sys/fs/cgroup /dev/sda1 1,6G 130M 1,5G 9% /boot tmpfs 100M 0 100M 0% /run/user/0 /dev/mapper/colo-tomat 3,9G 16M 3,6G 1% /tomatpartisi
Agar setingan mount tidak hilang ketika server dilakukan reboot, silahkan tambahkan pada /etc/fstab. Jika belum paham cara menambahkannya silahkan baca pada artikel sebelumnya.
Selamat mencoba 😀
Thanks how to nya dan penjelasan di setiap step.
sama2, senang bisa membantu 🙂