How to Create and Manage LVM on Parrot OS 3.9
To Create and Manage LVM on Parrot OS 3.9
LVM is a widely-used technique and extremely flexible disk management scheme for deploying logical rather than physical storage. With LVM, system administrator can easily resize and extend the logical drive when it is required. It is so simple to create and manage LVM on Parrot OS 3.9, and this tutorial demonstrates the same process.
Creating Logical Volume Management
It is very essential to add a new hardisk of any size. And for that, you need to check out the hard disks available on your machine. Run the following command for the same purpose. Add the new hard disk.
[root@linuxhelp]?[~]
#fdisk -l
Disk /dev/sdb: 3 GiB, 3221225472 bytes, 6291456 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: 18 GiB, 19327352832 bytes, 37748736 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: dos
Disk identifier: 0x59ef32fc
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 976895 974848 476M 83 Linux
/dev/sda2 976896 4882431 3905536 1.9G 82 Linux swap / Solaris
/dev/sda3 4882432 37746687 32864256 15.7G 83 Linux
And then, you need to create a new Partiton using fdisk tool. Run the following command for the same purpose.
You need to select partition type as LVM .
[root@linuxhelp]?[~]
#fdisk /dev/sdb
Welcome to fdisk (util-linux 2.30.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 0xf6c29730.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-6291455, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-6291455, default 6291455): +1G
Created a new partition 1 of type ' Linux' and of size 1 GiB.
Command (m for help): p
Disk /dev/sdb: 3 GiB, 3221225472 bytes, 6291456 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: dos
Disk identifier: 0xf6c29730
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2099199 2097152 1G 83 Linux
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition ' Linux' to ' Linux LVM' .
Command (m for help): p
Disk /dev/sdb: 3 GiB, 3221225472 bytes, 6291456 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: dos
Disk identifier: 0xf6c29730
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 2099199 2097152 1G 8e Linux LVM
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
And then, you need to initiate the partition /dev/sdb1 as an LVM physical volume . You shall do that by making use of pvcreate.
[root@linuxhelp]?[~] #pvcreate /dev/sdb1 Physical volume " /dev/sdb1" successfully created. [root@linuxhelp]?[~] #pvs PV VG Fmt Attr PSize PFree /dev/sdb1 lvm2 --- 1.00g 1.00g
You can also display and scan the properties of LVM physical volumes by making use of the following command.
[root@linuxhelp]?[~] #pvdisplay " /dev/sdb1" is a new physical volume of " 1.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb1 VG Name PV Size 1.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID CWNuoW-xfe6-A3DY-27oo-fXtL-nV9I-4VlWpx [root@linuxhelp]?[~] #pvscan PV /dev/sdb1 lvm2 [1.00 GiB] Total: 1 [1.00 GiB] / in use: 0 [0 ] / in no VG: 1 [1.00 GiB]
You should also create a volume group with name vg_newlvm and add /dev/sdb1 partition into that group.
[root@linuxhelp]?[~]
#vgcreate vg1 /dev/sdb1
Volume group " vg1" successfully created
After that, you need to create a logical volume. Run the following command for that purpose.
[root@linuxhelp]?[~]
#lvcreate -n lv1 -l 100%FREE vg1
Logical volume " lv1" created.
You shall check the newly created logical volumes by making use of lvdisplay command.
??[root@linuxhelp]?[~]
???? #lvdisplay
--- Logical volume ---
LV Path /dev/vg1/lv1
LV Name lv1
VG Name vg1
LV UUID 3aT3Iz-Ap3n-e22r-XaKT-eU4B-t3kB-BjsEt3
LV Write Access read/write
LV Creation host, time linuxhelp, 2017-12-05 16:49:25 +0530
LV Status available
# open 0
LV Size 1020.00 MiB
Current LE 255
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 254:0
Use the mkfs command to format a newly created LVM.
[root@linuxhelp]?[~] #mkfs.ext4 /dev/vg1/lv1 mke2fs 1.43.7 (16-Oct-2017) Creating filesystem with 261120 4k blocks and 65280 inodes Filesystem UUID: d348b933-25b9-4dc0-aed3-9c15095fc05a Superblock backups stored on blocks: 32768, 98304, 163840, 229376 Allocating group tables: done Writing inode tables: done Creating journal (4096 blocks): done Writing superblocks and filesystem accounting information: done
Later, you need to create the mount point and mount the new LVM as follows.
[root@linuxhelp]?[~] #mkdir -p /data [root@linuxhelp]?[~] #mount /dev/vg1/lv1 /data/
And then, you need to verify the new disk layout in the following manner.
[root@linuxhelp]?[~] #df -h Filesystem Size Used Avail Use% Mounted on udev 441M 0 441M 0% /dev tmpfs 92M 6.6M 85M 8% /run /dev/sda3 16G 12G 3.4G 78% / tmpfs 456M 0 456M 0% /dev/shm tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs 456M 0 456M 0% /sys/fs/cgroup /dev/sda1 453M 48M 378M 12% /boot tmpfs 92M 16K 92M 1% /run/user/1000 /dev/mapper/vg1-lv1 988M 2.6M 919M 1% /data
With this, this tutorial on Logical Volume Management in ParrotOs 3.9 comes to an end.
Comments ( 0 )
No comments available