Add New Logical Volume
First, you must have a block device available to you. In this example we will use /dev/mapper/data01, but equally well this could be /dev/sdb or /dev/mmcblk0p1.
First, convert it into a Physical Volume:
# pvcreate /dev/mapper/data01
We can see this using pvs:
# pvs
PV VG Fmt Attr PSize PFree /dev/sda2 Vsys lvm2 a-- 99.52g 30.06g /dev/mapper/data01 lvm2 a-- 350.00g 0
Next, we will create a new Volume Group called Vdata to contain this PV:
# vgcreate Vdata01 /dev/mapper/data01
We can see the results of this in pvs and vgs:
# pvs
PV VG Fmt Attr PSize PFree /dev/sda2 Vsys lvm2 a-- 99.52g 30.06g /dev/mapper/data01 Vdata lvm2 a-- 350.00g 0
# vgs
VG #PV #LV #SN Attr VSize VFree Vdata 1 1 0 wz--n- 350.00g 0 Vsys 1 8 0 wz--n- 99.52g 30.06g
Lastly, we will create a simple Logical Volume in this VG called Ldata. It will be the maximum available size.
# lvcreate -n Ldata01 -l 100%FREE Vdata01
This is naturally visible using the command lvs:
# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Ldata Vdata -wi-ao---- 350.00g Lhome Vsys -wi-ao---- 1.91g Llog Vsys -wi-ao---- 7.63g Lopt Vsys -wi-ao---- 8.00g Lroot Vsys -wi-ao---- 3.81g Lswap Vsys -wi-ao---- 32.00g Ltemp Vsys -wi-ao---- 7.63g Lusr Vsys -wi-ao---- 4.67g Lvar Vsys -wi-ao---- 3.81g
Excellent. Format this to your preferred filesystem (here, ext4):
# mkfs.ext4 /dev/Vdata01/Ldata01
Then create a mountpoint for this filesystem:
# mkdir /databases/data01
Set the correct permissions at the mount point:
# chown oracle:dba /databases/data01
# chmod 770 /databases/data01
# chmod +s /databases/data01
Edit /etc/fstab So that the filesystem will be mounted on boot:
# vi /etc/fstab
/dev/Vdata01/Ldata01 /databases/data01 ext4 defaults 1 2
Then you can test (and mount) this with:
# mount -a