Centos 7 – LVM + Fdisk + Mount New Disk

Mount New Disk to /var/lib

First off all add new disk.

No LVM

To mount disk to folder without LVM partition
1. Add disk to VM machine
2. Reboot
3. Prepare disk with command fdisk

fdisk -l
fdisk /dev/sdb
n
p
1
default ----Press Enter----
t
8e ----This LVM Type----
w

Reboot!!!

Format Disk

mkfs.ext4 /dev/sdb1

This command to Mount New disk to your /Your_Folder_To_Mount

mount /dev/sdb1 /Your_Folder_To_Mount

Permanent mount:

nano /etc/fstab

/dev/sdb1 /var/Your_Folder_To_Mount ext4 defaults 0 0

LVM Partition

——SDB1——

fdisk /dev/sdb
n
p
1
default ----Press Enter----
+85G
t
8e ----This LVM Type----
w
reboot

vgcreate vol-grp1-lib /dev/sdb1 --50GB
lvcreate -n lib -L +45G vol-grp1-lib
/sbin/mkfs.ext4 -L +45G /dev/vol-grp1-lib/lib

mount:

nano /etc/fstab

/dev/vol-grp1-lib/lib /var/lib ext4 defaults 0 0
reboot

df -hk —-To check mounted LVM

/dev/mapper/vol-grp3-moodledata-moodledata 86567008 57368 82089240 1% /var/www/moodledata

———————-End sdb1——————

—————Start sdb2———————-

fdisk /dev/sdb
n
p
default ------enter------
+11G
t
8e -----LVM------
w
reboot
vgcreate vol-grp2-html /dev/sdb2
lvcreate -n html -L +10G vol-grp2-html
/sbin/mkfs.ext4 -L +10G /dev/vol-grp2-html/html

nano /etc/fstab

/dev/vol-grp2-html/html /var/www/html ext4 defaults 0 0

reboot

———————-End sdb2——————

—————Start sdb3———————-

fdisk /dev/sdb
n
p
default ------enter------
+86G
t
8e -----LVM------
w
reboot
vgcreate vol-grp3-moodledata /dev/sdb3 --85GB
lvcreate -n moodledata -L +85G vol-grp3-moodledata
/sbin/mkfs.ext4 -L +85G /dev/vol-grp3-moodledata/moodledata

mount:

nano /etc/fstab

/dev/vol-grp3-moodledata/moodledata /var/www/moodledata ext4 defaults 0 0

reboot

df -hk —-To check mounted LVM
——————Example———————

/dev/mapper/vol-grp3-moodledata-moodledata 86567008 57368 82089240 1% /var/www/moodledata

———————-End sdb3——————

/sbin/mkfs.ext4 -L +85G /LIB-50GB /dev/vol-grp1-lib/lib

lvextend -L +49G vol-grp1-lib /dev/vol-grp1-lib/lib

/sbin/mkfs.ext4 -L +49G /LIB-50GB /dev/vol-grp1-lib/lib

/dev/vol-grp1-lib/lib
lvdisplay | more

To activate lvm volume

lvchange -a y mylv

pvs
lvdisplay

For Unmount

umount /mnt/volume-nyc1-01