Pada tutorial sebelumnya kita telah melihat partisi LVM yang dibuat secara otomatis oleh Ubuntu Server 14.04. Nah, kali ini kita akan belajar membuat partisi LVM sendiri pada 2 hardisk yang baru. Disini kita masih menggunakan Virtualbox untuk melakukan simulasinya. Untuk memulai, pertama-tama dalam kondisi PC off, tambahkan 2 hardisk baru bertipe sata.
Kemudian nyalakan PC Ubuntu Server 14.04. Setelah memasukkan username dan password, pada terminal ketikkan perintah berikut :
lvm@ubuntu-lvm:~$ sudo fdisk -l Disk /dev/sda: 6442 MB, 6442450944 bytes 255 heads, 63 sectors/track, 783 cylinders, total 12582912 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 identifier: 0x0006732d Device Boot Start End Blocks Id System /dev/sda1 * 2048 499711 248832 83 Linux /dev/sda2 501758 12580863 6039553 5 Extended /dev/sda5 501760 12580863 6039552 8e Linux LVM Disk /dev/sdb: 6442 MB, 6442450944 bytes 255 heads, 63 sectors/track, 783 cylinders, total 12582912 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 identifier: 0x26cb0a60 Device Boot Start End Blocks Id System Disk /dev/sdc: 4294 MB, 4294967296 bytes 255 heads, 63 sectors/track, 522 cylinders, total 8388608 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 identifier: 0x00000000 Disk /dev/sdc doesn't contain a valid partition table
Dari output perintah yang dihasilkan diatas sudah terdapat hardisk baru yang dikenal dengan “/dev/sdb” dan "/dev/sdc", masing-masing memiliki kapasitas 6 GB dan 4 GB. Sekarang kita akan mencoba membuat partisi LVM dengan Volume Group Name yang berbeda.
lvm@ubuntu-lvm:~$ sudo fdisk /dev/sdb Command (m for help): m <--- "m" untuk melihat daftar menud Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) n Command (m for help): n <--- "n" untuk membuat partisi baru Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p <--- "p" untuk membuat partisi primary Partition number (1-4, default 1): Enter <--- Gunakan default value = nomor partisi 1 Using default value 1 First sector (2048-12582911, default 2048): Enter <--- Gunakan default value = Sektor pertama 2048 Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-12582911, default 12582911): Enter <--- Gunakan default Value Using default value 12582911 Command (m for help): t <--- Ganti id partisi system yang akan digunakan Selected partition 1 Hex code (type L to list codes): l <--- "l" untuk melihat daftar id partisi system 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 codes): 8e <--- id "8e" = jenis partisi LVM Changed system type of partition 1 to 8e (Linux LVM) Command (m for help): w <--- "w" untuk meng-apply semua konfigurasi ke hardisk The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
Lakukan hal yang sama pada hardisk "/dev/sdc", kemudian cek hasilnya :
lvm@ubuntu-lvm:~$ sudo fdisk -l Disk /dev/sda: 6442 MB, 6442450944 bytes 255 heads, 63 sectors/track, 783 cylinders, total 12582912 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 identifier: 0x0006732d Device Boot Start End Blocks Id System /dev/sda1 * 2048 499711 248832 83 Linux /dev/sda2 501758 12580863 6039553 5 Extended /dev/sda5 501760 12580863 6039552 8e Linux LVM Disk /dev/sdb: 6442 MB, 6442450944 bytes 64 heads, 48 sectors/track, 4096 cylinders, total 12582912 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 identifier: 0x26cb0a60 Device Boot Start End Blocks Id System /dev/sdb1 2048 12582911 6290432 8e Linux LVM Disk /dev/sdc: 4294 MB, 4294967296 bytes 43 heads, 32 sectors/track, 6096 cylinders, total 8388608 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 identifier: 0xfc4f9909 Device Boot Start End Blocks Id System /dev/sdc1 2048 8388607 4193280 8e Linux LVM . . .
Sudah terdapat 2 hardisk yaitu "/dev/sdb1" dan "/dev/sdc1" yang masing-masing memiliki id "8e" (id dari file system LVM). Walaupun sudah memiliki id sebagai partisi system LVM (8e), namun kedua hardisk tersebut belum menjadi sebuah Physical Volume. Silahkan cek menggunakan perintah berikut :
lvm@ubuntu-lvm:~$ sudo pvscan PV /dev/sda5 VG ubuntu-lvm-vg lvm2 [5.76 GiB / 0 free] Total: 1 [5.76 GiB] / in use: 1 [5.76 GiB] / in no VG: 0 [0 ]
Kemudian mari kita persiapkan kedua hardisk tersebut untuk menjadi partisi LVM. Pertama-tama jadikan keduanya sebagai Physical Volume (PV). Berikut perintah untuk membuat dan menghapus PV :
lvm@ubuntu-lvm:~$ sudo pvscan PV /dev/sda5 VG ubuntu-lvm-vg lvm2 [5.76 GiB / 0 free] Total: 1 [5.76 GiB] / in use: 1 [5.76 GiB] / in no VG: 0 [0 ]
lvm@ubuntu-lvm:~$ sudo pvcreate /dev/sdb1 /dev/sdc1 Physical volume "/dev/sdb1" successfully created Physical volume "/dev/sdc1" successfully created
lvm@ubuntu-lvm:~$ sudo pvscan PV /dev/sda5 VG ubuntu-lvm-vg lvm2 [5.76 GiB / 0 free] PV /dev/sdb1 lvm2 [6.00 GiB] PV /dev/sdc1 lvm2 [4.00 GiB] Total: 3 [15.76 GiB] / in use: 1 [5.76 GiB] / in no VG: 2 [10.00 GiB]
lvm@ubuntu-lvm:~$ sudo pvremove /dev/sdb1 /dev/sdc1 Labels on physical volume "/dev/sdb1" successfully wiped Labels on physical volume "/dev/sdc1" successfully wiped
lvm@ubuntu-lvm:~$ sudo pvscan PV /dev/sda5 VG ubuntu-lvm-vg lvm2 [5.76 GiB / 0 free] Total: 1 [5.76 GiB] / in use: 1 [5.76 GiB] / in no VG: 0 [0 ]
lvm@ubuntu-lvm:~$ sudo pvcreate /dev/sdb1 /dev/sdc1 Physical volume "/dev/sdb1" successfully created Physical volume "/dev/sdc1" successfully created
lvm@ubuntu-lvm:~$ sudo pvscan PV /dev/sda5 VG ubuntu-lvm-vg lvm2 [5.76 GiB / 0 free] PV /dev/sdb1 lvm2 [6.00 GiB] PV /dev/sdc1 lvm2 [4.00 GiB] Total: 3 [15.76 GiB] / in use: 1 [5.76 GiB] / in no VG: 2 [10.00 GiB]
lvm@ubuntu-lvm:~$
Sekarang sudah ada 3 PV yang total kapasitas = 15,76 GB. Untuk melihat secara detail Physical Volume yang ada, ketikkan perintah di bawah ini :
lvm@ubuntu-lvm:~$ sudo pvdisplay --- Physical volume --- PV Name /dev/sda5 VG Name ubuntu-lvm-vg PV Size 5.76 GiB / not usable 2.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 1474 Free PE 0 Allocated PE 1474 PV UUID 5uOxww-NXSq-AhSz-FcRB-pu8w-dEVZ-FkYvBf "/dev/sdb1" is a new physical volume of "6.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb1 VG Name PV Size 6.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID RNo6oD-iMLq-VlWD-1mZ5-Bmns-Qruh-o3j90f "/dev/sdc1" is a new physical volume of "4.00 GiB" --- NEW Physical volume --- PV Name /dev/sdc1 VG Name PV Size 4.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID dqDGxc-rh2T-SA4K-FFux-Y4o0-NOUb-sg1FiP lvm@ubuntu-lvm:~$
Setelah partisi / hardisk "/dev/sdb1" & "/dev/sdc1" menjadi sebuah Physical Volume barulah kita dapat membuat Volume Group di dalamnya. Di sini kita akan membuat VG dengan nama "ShareLVM". Untuk membuat Volume Group (VG) ikuti langkah di bawah ini :
lvm@ubuntu-lvm:~$ sudo vgcreate ShareLVM /dev/sdb1 /dev/sdc1 Volume group "ShareLVM" successfully created
lvm@ubuntu-lvm:~$ sudo vgscan Reading all physical volumes. This may take a while... Found volume group "ShareLVM" using metadata type lvm2 Found volume group "ubuntu-lvm-vg" using metadata type lvm2
lvm@ubuntu-lvm:~$ sudo vgdisplay --- Volume group --- VG Name ShareLVM System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 2 Act PV 2 VG Size 9.99 GiB PE Size 4.00 MiB Total PE 2558 Alloc PE / Size 0 / 0 Free PE / Size 2558 / 9.99 GiB VG UUID uTZw29-h4fX-2ZIj-Z0f2-piTD-Bg1L-uLO81K --- Volume group --- VG Name ubuntu-lvm-vg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 5.76 GiB PE Size 4.00 MiB Total PE 1474 Alloc PE / Size 1474 / 5.76 GiB Free PE / Size 0 / 0 VG UUID CCdcEv-Qj4r-Ixf2-OfFf-Qsc4-6kj5-g0YBNn lvm@ubuntu-lvm:~$
Tampak bahwa VG "ShareLVM" memiliki kapasitas 9,99 GB. Ini adalah total jumlah kapasitas "/dev/sdb1" + "/dev/sdc1". Sebagai latihan, iseng-iseng kita akan merubah nama VG "ShareLVM" menjadi "DATA", kemudian menghapusnya, kemudian membuatnya kembali :
lvm@ubuntu-lvm:~$ sudo vgrename ShareLVM DATA Volume group "ShareLVM" successfully renamed to "DATA" lvm@ubuntu-lvm:~$ sudo pvscan PV /dev/sdb1 VG DATA lvm2 [6.00 GiB / 6.00 GiB free] PV /dev/sdc1 VG DATA lvm2 [4.00 GiB / 4.00 GiB free] PV /dev/sda5 VG ubuntu-lvm-vg lvm2 [5.76 GiB / 0 free] Total: 3 [15.75 GiB] / in use: 3 [15.75 GiB] / in no VG: 0 [0 ] lvm@ubuntu-lvm:~$ sudo vgscan Reading all physical volumes. This may take a while... Found volume group "DATA" using metadata type lvm2 Found volume group "ubuntu-lvm-vg" using metadata type lvm2
lvm@ubuntu-lvm:~$ sudo vgremove DATA Volume group "DATA" successfully removed lvm@ubuntu-lvm:~$ sudo vgscan Reading all physical volumes. This may take a while... Found volume group "ubuntu-lvm-vg" using metadata type lvm2 lvm@ubuntu-lvm:~$ sudo vgcreate ShareLVM /dev/sdb1 /dev/sdc1 Volume group "ShareLVM" successfully created lvm@ubuntu-lvm:~$ sudo vgscan Reading all physical volumes. This may take a while... Found volume group "ShareLVM" using metadata type lvm2 Found volume group "ubuntu-lvm-vg" using metadata type lvm2
Setelah berhasil membuat VG "ShareLVM" kita akan membuat beberapa Logical Volume (LV) di dalamnya. Kita akan membuat LV Share (4 GB), LV Backup (4 GB), dan LV Media (2 GB) :
lvm@ubuntu-lvm:~$ sudo lvcreate --name Share --size 4G ShareLVM Logical volume "Share" created lvm@ubuntu-lvm:~$ sudo lvcreate --name Backup --size 4G ShareLVM Logical volume "Backup" created lvm@ubuntu-lvm:~$ sudo lvcreate --name Media --size 1.5G ShareLVM Logical volume "Media" created lvm@ubuntu-lvm:~$ sudo lvscan ACTIVE '/dev/ShareLVM/Share' [4.00 GiB] inherit ACTIVE '/dev/ShareLVM/Backup' [4.00 GiB] inherit ACTIVE '/dev/ShareLVM/Media' [1.50 GiB] inherit ACTIVE '/dev/ubuntu-lvm-vg/root' [5.26 GiB] inherit ACTIVE '/dev/ubuntu-lvm-vg/swap_1' [512.00 MiB] inherit
Untuk menampilkan daftar Logical Volume secara detail gunakan perintah berikut :
lvm@ubuntu-lvm:~$ sudo lvdisplay --- Logical volume --- LV Path /dev/ShareLVM/Share LV Name Share VG Name ShareLVM LV UUID 70tmrp-docp-TzvE-Ol3F-eg4Y-ixPc-ojcRqq LV Write Access read/write LV Creation host, time ubuntu-lvm, 2014-08-15 17:23:01 +0700 LV Status available # open 0 LV Size 4.00 GiB Current LE 1024 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:2 --- Logical volume --- LV Path /dev/ShareLVM/Backup LV Name Backup VG Name ShareLVM LV UUID kwpUkV-v3En-kCcA-Ke45-CMgv-xs2B-d32v4M LV Write Access read/write LV Creation host, time ubuntu-lvm, 2014-08-15 17:23:22 +0700 LV Status available # open 0 LV Size 4.00 GiB Current LE 1024 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:3 --- Logical volume --- LV Path /dev/ShareLVM/Media LV Name Media VG Name ShareLVM LV UUID 3jB2sg-flLA-zgv1-SVMD-JuRE-OrvA-1tvzxX LV Write Access read/write LV Creation host, time ubuntu-lvm, 2014-08-15 17:26:33 +0700 LV Status available # open 0 LV Size 1.50 GiB Current LE 384 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:4 --- Logical volume --- LV Path /dev/ubuntu-lvm-vg/root LV Name root VG Name ubuntu-lvm-vg LV UUID Dv32KX-D88P-DNRj-lRES-c7li-fvSC-8ltNOe LV Write Access read/write LV Creation host, time ubuntu-lvm, 2014-08-12 13:58:14 +0700 LV Status available # open 1 LV Size 5.26 GiB Current LE 1346 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:0 --- Logical volume --- LV Path /dev/ubuntu-lvm-vg/swap_1 LV Name swap_1 VG Name ubuntu-lvm-vg LV UUID RfQ4O4-590O-x7pD-JZ1X-8neG-iato-N4d1dt LV Write Access read/write LV Creation host, time ubuntu-lvm, 2014-08-12 13:58:14 +0700 LV Status available # open 2 LV Size 512.00 MiB Current LE 128 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:1 lvm@ubuntu-lvm:~$
Untuk sekedar latihan, kita akan merubah nama LV "Share" menjadi "BagiPakai", kemudian kita akan menghapusnya, kemudian membuatnya kembali. Ikuti tahapan berikut :
lvm@ubuntu-lvm:~$ sudo lvrename ShareLVM Share BagiPakai Renamed "Share" to "BagiPakai" in volume group "ShareLVM" lvm@ubuntu-lvm:~$ sudo lvscan ACTIVE '/dev/ShareLVM/BagiPakai' [4.00 GiB] inherit ACTIVE '/dev/ShareLVM/Backup' [4.00 GiB] inherit ACTIVE '/dev/ShareLVM/Media' [1.50 GiB] inherit ACTIVE '/dev/ubuntu-lvm-vg/root' [5.26 GiB] inherit ACTIVE '/dev/ubuntu-lvm-vg/swap_1' [512.00 MiB] inherit lvm@ubuntu-lvm:~$ sudo lvdisplay --- Logical volume --- LV Path /dev/ShareLVM/BagiPakai LV Name BagiPakai VG Name ShareLVM LV UUID 70tmrp-docp-TzvE-Ol3F-eg4Y-ixPc-ojcRqq LV Write Access read/write LV Creation host, time ubuntu-lvm, 2014-08-15 17:23:01 +0700 LV Status available # open 0 LV Size 4.00 GiB Current LE 1024 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:0 --- Logical volume --- LV Path /dev/ShareLVM/Backup LV Name Backup VG Name ShareLVM LV UUID kwpUkV-v3En-kCcA-Ke45-CMgv-xs2B-d32v4M LV Write Access read/write LV Creation host, time ubuntu-lvm, 2014-08-15 17:23:22 +0700 LV Status available # open 0 LV Size 4.00 GiB Current LE 1024 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:1 --- Logical volume --- LV Path /dev/ShareLVM/Media LV Name Media VG Name ShareLVM LV UUID 3jB2sg-flLA-zgv1-SVMD-JuRE-OrvA-1tvzxX LV Write Access read/write LV Creation host, time ubuntu-lvm, 2014-08-15 17:26:33 +0700 LV Status available # open 0 LV Size 1.50 GiB Current LE 384 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:2 --- Logical volume --- LV Path /dev/ubuntu-lvm-vg/root LV Name root VG Name ubuntu-lvm-vg LV UUID Dv32KX-D88P-DNRj-lRES-c7li-fvSC-8ltNOe LV Write Access read/write LV Creation host, time ubuntu-lvm, 2014-08-12 13:58:14 +0700 LV Status available # open 1 LV Size 5.26 GiB Current LE 1346 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:3 --- Logical volume --- LV Path /dev/ubuntu-lvm-vg/swap_1 LV Name swap_1 VG Name ubuntu-lvm-vg LV UUID RfQ4O4-590O-x7pD-JZ1X-8neG-iato-N4d1dt LV Write Access read/write LV Creation host, time ubuntu-lvm, 2014-08-12 13:58:14 +0700 LV Status available # open 2 LV Size 512.00 MiB Current LE 128 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 252:4 lvm@ubuntu-lvm:~$ sudo lvscan ACTIVE '/dev/ShareLVM/BagiPakai' [4.00 GiB] inherit ACTIVE '/dev/ShareLVM/Backup' [4.00 GiB] inherit ACTIVE '/dev/ShareLVM/Media' [1.50 GiB] inherit ACTIVE '/dev/ubuntu-lvm-vg/root' [5.26 GiB] inherit ACTIVE '/dev/ubuntu-lvm-vg/swap_1' [512.00 MiB] inherit lvm@ubuntu-lvm:~$ sudo lvremove /dev/ShareLVM/BagiPakai Do you really want to remove and DISCARD active logical volume BagiPakai? [y/n]: y Logical volume "BagiPakai" successfully removed lvm@ubuntu-lvm:~$ sudo lvscan ACTIVE '/dev/ShareLVM/Backup' [4.00 GiB] inherit ACTIVE '/dev/ShareLVM/Media' [1.50 GiB] inherit ACTIVE '/dev/ubuntu-lvm-vg/root' [5.26 GiB] inherit ACTIVE '/dev/ubuntu-lvm-vg/swap_1' [512.00 MiB] inherit lvm@ubuntu-lvm:~$ sudo lvcreate --name Share --size 4G ShareLVM Logical volume "Share" created
Sebelum melanjutkan ke tahapan berikutnya, kita akan latihan lagi, yaitu dengan memperkecil dan memperbesar kapasitas LV "Share" :
lvm@ubuntu-lvm:~$ sudo lvreduce -L2.5G /dev/ShareLVM/Share WARNING: Reducing active logical volume to 2.50 GiB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce Share? [y/n]: y Reducing logical volume Share to 2.50 GiB Logical volume Share successfully resized lvm@ubuntu-lvm:~$ sudo lvscan ACTIVE '/dev/ShareLVM/Backup' [4.00 GiB] inherit ACTIVE '/dev/ShareLVM/Media' [1.50 GiB] inherit ACTIVE '/dev/ShareLVM/Share' [2.50 GiB] inherit ACTIVE '/dev/ubuntu-lvm-vg/root' [5.26 GiB] inherit ACTIVE '/dev/ubuntu-lvm-vg/swap_1' [512.00 MiB] inherit lvm@ubuntu-lvm:~$ sudo lvextend -L4G /dev/ShareLVM/Share Extending logical volume Share to 4.00 GiB Logical volume Share successfully resized lvm@ubuntu-lvm:~$ sudo lvscan ACTIVE '/dev/ShareLVM/Backup' [4.00 GiB] inherit ACTIVE '/dev/ShareLVM/Media' [1.50 GiB] inherit ACTIVE '/dev/ShareLVM/Share' [4.00 GiB] inherit ACTIVE '/dev/ubuntu-lvm-vg/root' [5.26 GiB] inherit ACTIVE '/dev/ubuntu-lvm-vg/swap_1' [512.00 MiB] inherit
Baiklah, sampai disini kita telah berhasil membuat 3 Logical Volume di dalam VG "ShareLVM". Namun ke 3 LV tersebut belum memiliki file system (atau kalau di dalam partisi biasa, hardisk / partisi tersebut belum diformat). Sebelum LV tersebut diberikan file system di dalamnya, partisi-partisi logical tersebut belum bisa digunakan untuk menyimpan file. Di sini kita akan membuat file system ext4 pada LV "Share" dan file system ext3 pada LV "Backup" dan LV "Media" :
lvm@ubuntu-lvm:~$ sudo mkfs.ext4 /dev/ShareLVM/Share mke2fs 1.42.9 (4-Feb-2014) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 262144 inodes, 1048576 blocks 52428 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1073741824 32 block groups 32768 blocks per group, 32768 fragments per group 8192 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 (32768 blocks): done Writing superblocks and filesystem accounting information: done lvm@ubuntu-lvm:~$ sudo mkfs.ext3 /dev/ShareLVM/Backup mke2fs 1.42.9 (4-Feb-2014) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 262144 inodes, 1048576 blocks 52428 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=1073741824 32 block groups 32768 blocks per group, 32768 fragments per group 8192 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 (32768 blocks): done Writing superblocks and filesystem accounting information: done lvm@ubuntu-lvm:~$ sudo mkfs.ext3 /dev/ShareLVM/Media mke2fs 1.42.9 (4-Feb-2014) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 98304 inodes, 393216 blocks 19660 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=402653184 12 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Allocating group tables: done Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done
Setelah ke 3 Logical Volume tersebut memiliki file system, kita telah dapat menggunakannya untuk menyimpan file, tentunya dengan terlebih dahulu me-mount LV tersebut ke folder yang ditentukan. Kita akan me-mount LV "Share" ke direktori "/var/LVMMount/Share", LV "Backup" ke direktori "/var/LVMMount/Backup" dan LV "Media" ke direktori "/var/LVMMount/Media" :
Taa...daaa...., sekarang partisi LVM yang baru saja kita buat sudah di-mount dan siap digunakan untuk menyimpan berbagai jenis file.Sampai disini tuntas sudah pekerjaan kita dalam membuat partisi LVM sebagai media penyimpanan file. Namun, ketika komputer di restart, kita harus melakukan mount lagi secara manual agar ke 3 partisi LVM tersebut siap digunakan kembali. Agar partisi-partisi LVM tersebut di-mount otomatis saat komputer reboot, maka kita harus memberikan konfigurasi tambahan pada file /etc/fstab. Ikuti langkah-langkah berikut :
Silahkan reboot komputer Anda untuk menguji bahwa konfigurasi pada file "/etc/fstab" sudah benar. Kalau konfigurasi telah benar, maka komputer akan dapat kembali login setelah proses restart, dan partisi LVM akan ter-mount secara otomatis (buktikan dengan perintah "df -h"). Sedangkan jika konfigurasi pada file fstab gagal maka kemungkinan komputer tidak bisa masuk ke menu login. Kalau ini terjadi maka masuk ke terminal console dan perbaiki kesalahan pada file "etc/fstab". Kalau ingin membatalkan perubahan file fstab, maka hapus file "/etc/fstab" dan kembalikan (rename) file "/etc/fstab.asli" menjadi "/etc/fstab".
Selanjutny mari kita mencoba meng-copy file ke dalam 3 partisi LVM yang telah kita mount. Saya akan terlebih dahulu me-mount folder sharing dari sebuah komputer file server ke direktori lokal, kemudian saya akan meng-copy salah satu folder ke partisi LV "Backup" :
Saya telah berhasil menyalin folder "//mnt/samba/Master" ke partisi LVM yaitu LV "Backup". Terlihat dengan perintah "df -h" bahwa kapasitas LV "Backup" sekarang sudah terpakai sebanyak 27% atau 978MB. Berikutnya saya akan menyalin data masih dari file server tersebut namun kali ini yang di salin adalah folder "absensi" dan "Master", saya akan menyalin kedua folder tersebut ke partisi LV Share. Cara peng-copy-an yang saya gunakan adalah teknik sinkronisasi menggunakan rsync. Ikuti langkah-langkah dibawah ini. Pertama-tama melalui layar console komputer file server cek dulu dimana lokasi folder Master & absensi :
Kemudian mulai sinkronisasi file / folder komputer remote (file server) ke komputer lokal (ubuntu server 14.04) :
Sinkronisasi telah berhasil dan sekaran partisi LV "Share" sudah terpakai sebesar 28% atau 1017 MB.
Sampai disini kita telah menyelesaikan oprek-oprekan partisi LVM bagian 2. Pada tutorial berikutnya, insya Allah kita akan mencoba skenario yang berbeda. Selamat mencoba.
lvm@ubuntu-lvm:~$ sudo df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/ubuntu--lvm--vg-root 5.1G 1.1G 3.8G 22% / none 4.0K 0 4.0K 0% /sys/fs/cgroup udev 235M 4.0K 235M 1% /dev tmpfs 50M 1020K 49M 3% /run none 5.0M 0 5.0M 0% /run/lock none 246M 0 246M 0% /run/shm none 100M 0 100M 0% /run/user /dev/sda1 236M 37M 188M 17% /boot lvm@ubuntu-lvm:~$ sudo mkdir /var/LVMMount lvm@ubuntu-lvm:~$ sudo mkdir /var/LVMMount/Share lvm@ubuntu-lvm:~$ sudo mkdir /var/LVMMount/Backup lvm@ubuntu-lvm:~$ sudo mkdir /var/LVMMount/Media lvm@ubuntu-lvm:~$ sudo mount /dev/ShareLVM/Share /var/LVMMount/Share lvm@ubuntu-lvm:~$ sudo mount /dev/ShareLVM/Backup /var/LVMMount/Backup lvm@ubuntu-lvm:~$ sudo mount /dev/ShareLVM/Media /var/LVMMount/Media lvm@ubuntu-lvm:~$ sudo df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/ubuntu--lvm--vg-root 5.1G 1.1G 3.8G 22% / none 4.0K 0 4.0K 0% /sys/fs/cgroup udev 235M 4.0K 235M 1% /dev tmpfs 50M 1020K 49M 3% /run none 5.0M 0 5.0M 0% /run/lock none 246M 0 246M 0% /run/shm none 100M 0 100M 0% /run/user /dev/sda1 236M 37M 188M 17% /boot /dev/mapper/ShareLVM-Share 3.9G 8.0M 3.6G 1% /var/LVMMount/Share /dev/mapper/ShareLVM-Backup 3.9G 8.2M 3.7G 1% /var/LVMMount/Backup /dev/mapper/ShareLVM-Media 1.5G 2.3M 1.4G 1% /var/LVMMount/Media
Taa...daaa...., sekarang partisi LVM yang baru saja kita buat sudah di-mount dan siap digunakan untuk menyimpan berbagai jenis file.Sampai disini tuntas sudah pekerjaan kita dalam membuat partisi LVM sebagai media penyimpanan file. Namun, ketika komputer di restart, kita harus melakukan mount lagi secara manual agar ke 3 partisi LVM tersebut siap digunakan kembali. Agar partisi-partisi LVM tersebut di-mount otomatis saat komputer reboot, maka kita harus memberikan konfigurasi tambahan pada file /etc/fstab. Ikuti langkah-langkah berikut :
lvm@ubuntu-lvm:~$ sudo cp /etc/fstab /etc/fstab.asli lvm@ubuntu-lvm:~$ ls -l /etc/fsta* -rw-r--r-- 1 root root 630 Aug 12 13:59 /etc/fstab -rw-r--r-- 1 root root 630 Aug 18 11:37 /etc/fstab.asli /etc/fstab.d: total 0 lvm@ubuntu-lvm:~$ sudo vi /etc/fstab
# /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> /dev/mapper/ubuntu--lvm--vg-root / ext4 errors=remount-ro 0 1 # /boot was on /dev/sda1 during installation UUID=d2f4c0db-dfcd-48d1-b69b-3dd1dc42b27b /boot ext2 defaults 0 2 /dev/mapper/ubuntu--lvm--vg-swap_1 none swap sw 0 0 #Mount otomatis partisi LV Share, LV Media dan LV Backup /dev/ShareLVM/Share /var/LVMMount/Share ext4 rw,noatime 0 0 /dev/ShareLVM/Backup /var/LVMMount/Backup ext3 rw,noatime 0 0 /dev/ShareLVM/Media /var/LVMMount/Media ext3 rw,noatime 0 0
Silahkan reboot komputer Anda untuk menguji bahwa konfigurasi pada file "/etc/fstab" sudah benar. Kalau konfigurasi telah benar, maka komputer akan dapat kembali login setelah proses restart, dan partisi LVM akan ter-mount secara otomatis (buktikan dengan perintah "df -h"). Sedangkan jika konfigurasi pada file fstab gagal maka kemungkinan komputer tidak bisa masuk ke menu login. Kalau ini terjadi maka masuk ke terminal console dan perbaiki kesalahan pada file "etc/fstab". Kalau ingin membatalkan perubahan file fstab, maka hapus file "/etc/fstab" dan kembalikan (rename) file "/etc/fstab.asli" menjadi "/etc/fstab".
Selanjutny mari kita mencoba meng-copy file ke dalam 3 partisi LVM yang telah kita mount. Saya akan terlebih dahulu me-mount folder sharing dari sebuah komputer file server ke direktori lokal, kemudian saya akan meng-copy salah satu folder ke partisi LV "Backup" :
lvm@ubuntu-lvm:~$ sudo mkdir /mnt/samba lvm@ubuntu-lvm:~$ sudo mount -t cifs //172.16.16.115/sysadm /mnt/samba -o rw Password for root@//172.16.16.115/sysadm: lvm@ubuntu-lvm:~$ ls -l /mnt/samba total 0 drwxrwxrwx 8 100102 100100 0 Aug 18 09:51 Master drwxrwxrwx 5 100101 100100 0 Jun 26 13:36 absensi d-w------- 5 100103 100100 0 Jul 2 16:05 it lvm@ubuntu-lvm:~$ sudo cp -R /mnt/samba/Master /var/LVMMount/Backup/ lvm@ubuntu-lvm:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/ubuntu--lvm--vg-root 5.1G 1.1G 3.8G 22% / none 4.0K 0 4.0K 0% /sys/fs/cgroup udev 235M 4.0K 235M 1% /dev tmpfs 50M 1012K 49M 3% /run none 5.0M 0 5.0M 0% /run/lock none 246M 0 246M 0% /run/shm none 100M 0 100M 0% /run/user /dev/sda1 236M 37M 188M 17% /boot /dev/mapper/ShareLVM-Share 3.9G 8.0M 3.6G 1% /var/LVMMount/Share /dev/mapper/ShareLVM-Backup 3.9G 978M 2.7G 27% /var/LVMMount/Backup /dev/mapper/ShareLVM-Media 1.5G 2.3M 1.4G 1% /var/LVMMount/Media //172.16.16.115/sysadm 71G 2.1G 65G 4% /mnt/samba lvm@ubuntu-lvm:~$ ls -l /var/LVMMount/Backup/ total 4 drwxr-xr-x 8 root root 4096 Aug 18 13:37 Master
Saya telah berhasil menyalin folder "//mnt/samba/Master" ke partisi LVM yaitu LV "Backup". Terlihat dengan perintah "df -h" bahwa kapasitas LV "Backup" sekarang sudah terpakai sebanyak 27% atau 978MB. Berikutnya saya akan menyalin data masih dari file server tersebut namun kali ini yang di salin adalah folder "absensi" dan "Master", saya akan menyalin kedua folder tersebut ke partisi LV Share. Cara peng-copy-an yang saya gunakan adalah teknik sinkronisasi menggunakan rsync. Ikuti langkah-langkah dibawah ini. Pertama-tama melalui layar console komputer file server cek dulu dimana lokasi folder Master & absensi :
sysadm@fileserver $ pwd /home/sysadm sysadm@fileserver $ ls -l total 12 drwxrwxrwx 8 sysadm sysadm 4096 Aug 18 02:51 Master drwxrwxrwx 5 absensi sysadm 4096 Jun 26 06:36 absensi d-w------- 5 it sysadm 4096 Jul 2 09:05 it
Kemudian mulai sinkronisasi file / folder komputer remote (file server) ke komputer lokal (ubuntu server 14.04) :
lvm@ubuntu-lvm:~$ sudo rsync -avzhe ssh --progress --exclude 'it' sysadm@172.16.16.115:/home/sysadm/ /var/LVMMount/Share/ The authenticity of host '172.16.16.115 (172.16.16.115)' can't be established. ECDSA key fingerprint is db:77:d2:bc:54:ce:5a:c8:cb:67:fc:24:7f:e6:22:65. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '172.16.16.115' (ECDSA) to the list of known hosts. sysadm@172.16.16.115's password: receiving incremental file list rsync: readlink_stat("/home/sysadm/Master/Driver/DC236/fxdc336pcl610111nw2k3ien.exe") failed: Permission denied (13) rsync: readlink_stat("/home/sysadm/Master/Driver/DC236/fxdc336pcl60912nw2k3ien.zip") failed: Permission denied (13) rsync: opendir "/home/sysadm/it" failed: Permission denied (13) ./ Master/ Master/4AA0-4385ENW.pdf 1.30M 100% 9.87MB/s 0:00:00 (xfr#1, to-chk=103/108) Master/Backup DATA User HO/ Master/Driver/ Master/Driver/DC2055/ Master/Driver/DC2055/UNIX_Driver_4-2-0.zip 29.20M 100% 7.73MB/s 0:00:03 (xfr#2, to-chk=92/108) Master/Driver/DC2055/fxdc23005pcl60911nw2k3ien.zip 3.31M 100% 3.29MB/s 0:00:00 (xfr#3, to-chk=91/108) Master/Driver/DC2260/ Master/Driver/DC2260/fxdc4c2260pcl614021nwxp6ien.zip 13.68M 100% 5.09MB/s 0:00:02 (xfr#4, to-chk=90/108) Master/Driver/DC236/ Master/Driver/Epson L210/ Master/Driver/Epson L210/EM_31035.zip 15.07M 100% 6.14MB/s 0:00:02 (xfr#5, to-chk=89/108) Master/Driver/Epson L210/L210_WW_WIN_3791_41.zip 20.67M 100% 7.66MB/s 0:00:02 (xfr#6, to-chk=88/108) . . . . rsync: readlink_stat("/home/sysadm/Master/Driver/DC236/fxdc336pcl610111nw2k3ien.exe") failed: Permission denied (13) rsync: readlink_stat("/home/sysadm/Master/Driver/DC236/fxdc336pcl60912nw2k3ien.zip") failed: Permission denied (13) rsync: opendir "/home/sysadm/it" failed: Permission denied (13) sent 45 bytes received 3.90K bytes 877.78 bytes/sec total size is 1.05G speedup is 266,479.45 rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1655) [generator=3.1.0] lvm@ubuntu-lvm:~$ sudo rsync -avzhe ssh --progress --exclude 'i*' root@172.16.16.115:/home/sysadm/ /var/LVMMount/Share/ root@172.16.16.115's password: receiving incremental file list Master/Driver/DC236/fxdc336pcl60912nw2k3ien.zip 2.03M 100% 10.09MB/s 0:00:00 (xfr#1, to-chk=104/123) Master/Driver/DC236/fxdc336pcl610111nw2k3ien.exe 2.17M 100% 5.49MB/s 0:00:00 (xfr#2, to-chk=103/123) it/.bash_logout 220 100% 0.57kB/s 0:00:00 (xfr#3, to-chk=12/123) it/.bashrc 2.95K 100% 7.61kB/s 0:00:00 (xfr#4, to-chk=11/123) it/.profile 746 100% 1.92kB/s 0:00:00 (xfr#5, to-chk=10/123) it/.bashrc.d/ it/.bashrc.d/bash_completion 89 100% 0.23kB/s 0:00:00 (xfr#6, to-chk=6/123) it/.bashrc.d/bashmarks 5.06K 100% 12.93kB/s 0:00:00 (xfr#7, to-chk=5/123) it/.bashrc.d/defaults 47 100% 0.12kB/s 0:00:00 (xfr#8, to-chk=4/123) it/.bashrc.d/git 832 100% 2.12kB/s 0:00:00 (xfr#9, to-chk=3/123) it/.bashrc.d/penv 702 100% 1.79kB/s 0:00:00 (xfr#10, to-chk=2/123) it/.bashrc.d/user-path 117 100% 0.30kB/s 0:00:00 (xfr#11, to-chk=1/123) it/.profile.d/ it/.profile.d/.anchor 0 100% 0.00kB/s 0:00:00 (xfr#12, to-chk=0/123) it/folder1/ sent 285 bytes received 4.22M bytes 767.76K bytes/sec total size is 1.06G speedup is 250.27 lvm@ubuntu-lvm:~$ ls -l /var/LVMMount/Share/total 8 drwxrwxrwx 8 100102 100100 4096 Aug 18 09:51 Master drwxrwxrwx 5 100101 100100 4096 Jun 26 13:36 absensi lvm@ubuntu-lvm:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/ubuntu--lvm--vg-root 5.1G 1.1G 3.8G 22% / none 4.0K 0 4.0K 0% /sys/fs/cgroup udev 235M 4.0K 235M 1% /dev tmpfs 50M 1016K 49M 3% /run none 5.0M 0 5.0M 0% /run/lock none 246M 0 246M 0% /run/shm none 100M 0 100M 0% /run/user /dev/sda1 236M 37M 188M 17% /boot /dev/mapper/ShareLVM-Share 3.9G 1017M 2.7G 28% /var/LVMMount/Share /dev/mapper/ShareLVM-Backup 3.9G 978M 2.7G 27% /var/LVMMount/Backup /dev/mapper/ShareLVM-Media 1.5G 2.3M 1.4G 1% /var/LVMMount/Media
Sinkronisasi telah berhasil dan sekaran partisi LV "Share" sudah terpakai sebesar 28% atau 1017 MB.
Sampai disini kita telah menyelesaikan oprek-oprekan partisi LVM bagian 2. Pada tutorial berikutnya, insya Allah kita akan mencoba skenario yang berbeda. Selamat mencoba.
Sumber :
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/4/html/Cluster_Logical_Volume_Manager/LVM_CLI.html
http://www.microhowto.info/howto/reduce_the_size_of_an_ext2_ext3_or_ext4_filesystem.html
http://www.computers-it.com/linux/linux_lvm_resize_filesystem.php
http://tldp.org/HOWTO/LVM-HOWTO/extendlv.html
Tidak ada komentar:
Posting Komentar