How to create and mount disk LVM

How to create and mount disk LVM



 [root@lo-01 ~]# lsblk

NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

sda           8:0    0  100G  0 disk

├─sda1        8:1    0    1G  0 part /boot

└─sda2        8:2    0   99G  0 part

  ├─ol-root 252:0    0   50G  0 lvm  /

  ├─ol-swap 252:1    0   24G  0 lvm  [SWAP]

  └─ol-home 252:2    0   25G  0 lvm  /home

sdb           8:16   0   50G  0 disk


[root@lo-01 ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.32.1).

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 0x72dfb201.

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 (2560-104857599, default 2560): [press enter]

Last sector, +sectors or +size{K,M,G,T,P} (2560-104857599, default 104857599): [press enter]


Created a new partition 1 of type 'Linux' and of size 50 GiB.


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: 50 GiB, 53687091200 bytes, 104857600 sectors

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 8192 bytes / 1310720 bytes

Disklabel type: dos

Disk identifier: 0x72dfb201


Device     Boot Start       End   Sectors Size Id Type

/dev/sdb1        2560 104857599 104855040  50G 8e Linux LVM


Command (m for help): w

The partition table has been altered.

Calling ioctl() to re-read partition table.

Syncing disks.


[root@lo-01 ~]# pvcreate /dev/sdb1

[root@lo-01 ~]# vgcreate lo_vg /dev/sdb1

[root@lo-01 ~]# lvcreate -v -l 100%FREE  -n lo_lv lo_vg

[root@lo-01 ~]# lsblk

NAME                MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

sda                   8:0    0  100G  0 disk

├─sda1                8:1    0    1G  0 part /boot

└─sda2                8:2    0   99G  0 part

  ├─ol-root         252:0    0   50G  0 lvm  /

  ├─ol-swap         252:1    0   24G  0 lvm  [SWAP]

  └─ol-home         252:2    0   25G  0 lvm  /home

sdb                   8:16   0   50G  0 disk

└─sdb1                8:17   0   50G  0 part

  └─lo_vg-lo_lv 252:3    0   49G  0 lvm


[root@lo-01 ~]# mkfs.ext4 /dev/lo_vg/lo_lv

[root@lo-01 ~]# mkdir /LOAPP

[root@lo-01 ~]# mount /dev/lo_vg/lo_lv /LOAPP

[root@lo-01 ~]# vi /etc/fstab

/dev/lo_vg/lo_lv /LOAPP ext4 defaults 0 0

[root@lo-01 ~]# systemctl daemon-reload


####################


Test remount 

umount /LOAPP

mount -a


Post a Comment

0 Comments