LVM
(Logical volume manager)
How to create LVM
Step
by step:-
Fdisk -cu
/dev/sda ----press Enter key
First Create a
Extended partition
Next-- press P
(to check partition table)
Next—press n
(to create a new partition table)
Next –press E
(to create Extended partition)
After that, here
create two more partition for creating a pv.
Fdisk –cu
/dev/sda
Then… press n
for create a new partition
Then …put
partition size what ever you want to give. Ex. ….+1G
Then …press t
(to change partition id code)
Then..put the
partition no. like (1-8):8 & press Enter key .
Then ..type LVM
hex id code : 8e
Then …press W
(to write a partition table. Save & exit)
Then…give a
command partx -a /dev/sda (to inform the kernel about new
partition tables)
Now,
create a pv
Pvcreate
/dev/sda5 /dev/sda6 (cross check command pvs or pvdisplay)
Now,
create a vg
Vgcreate IT
/dev/sda5 /dev/sda6 (cross check command vg or vgdisplay)
(IT :- give a
volume groupname or u can give any name)
Now,create
a LVM
lvcreate -L 1G
–n LV IT ( logical volume created)(corss check lvs or lvdisplay)
Now,
Format to lvm partition:-
Mkfs.ext4
/dev/IT/LV
Then ..create a
mount point directory mkdir /lv
Now, mount to the
partition mount /dev/IT/LV /lv/
df- hT (to
check LVM partition)
now put permanent
entries in /etc/fstab like that,
vim /etc/fstab
/dev/IT/LV
/lv ext4 defaults 0 0
Mount -a (to
check mounted or not , if not proper mount then it’s show some
errors)
Then…lvs (for
check mounting partition on lvm).
#
how to Extend LVM.
- Lvextend -L 1.5G /dev/IT/LV
- Resize2fs /dev/IT/LV
- Lvs ( to check extend LVM)
# how to reduce LVM
- 1st umount /lv
- E2fsck -f /dev/IT/LV (for scanning bad sector in hard disk)
- Resize2fs /dev/IT/LV 1G (mention lvm size how much space should I reduce)
- Lvreduce -L /dev/IT/LV then press “yes”
- Lvs (to check the lvm reduce command)
- Now, mount the directory again … mount /lv
# how to extend VG size
(volume group)
- Fdisk -cu /dev/sda
- N (to create a new partition table)
- T(to change LVM partition id code 8e)
- W (write the partition tabled, save & exit)
- Partx –a /dev /sda (to inform the kernel)
- Now, pvcreate /dev/sda7 or some else
- Vgextend IT /dev/sda7 (IT stands for groupname)
- Vgdisplay (cross check vg extend or note)
-----------------------------------------------------------------------------------------------------------------------------------
Incrypted partition
(password protected partion)
# First entry
- Fdisk –cu /dev/sda
- P (print a partition table)
- N (create a new partition table)
- E (to create extend partition )
- Again create a new partition table
- W (to write table save & exit)
- Partx –a /dev/sda (to inform the kernel)
- Crypt setup luks Format /dev/sda5
- Then type “YES” put in uppercase letter.
- Asked for passwd phrase: ------(give passwd)
- Verify passwd phrase : ……….(again enter same passwd)
- Crypt setup luksOpen /dev/sda5 secure (“secure” stands for levels)
- Enter passwd phrase for /dev/sda5 : …… (passwd enter)
- Now, format the partition. mkfs.ext4 /dev/mapper/secure
- Then, create a mount point directory mkdir crypt or Parmendra
- Now, mount /dev/mapper/secure/crypt
- Then, put entries in vim /etc/fstab
- /dev/mapper/secure /crypt ext4 defaults 0 0
# now, Second entry
- Vim /etc/crypt
Secure /dev/sda5 (Actual device & level entries)
# Normal using LUKS
- Umount /crypt
- Cryptsetup luksClose /dev/mapper/sercure
- Then, Format the drive mkfs.ext4 /dev/sda5
- Vim /etc/crypttab
/dev/sda5 /crypt ext4 defaults 0 0
- Then , mount -a (to check the mount point)
No comments:
Post a Comment