Storage & LVM

Types of Storage

  • Local Storage
  • SAN (Storage Area Network)
  • NAS (Network Attached Storage)

 

Basic Commands

fdisk -l

disk partition utility (displays disk system names)
-l list disks

lsblk -f

list block devices (displays UUID)
-f forest (tree) hierarchy

df -h

filesystem capacity (displays mounted disks)

-h human readable

 

Add a New Disk

insert a new 2GB disk

fdisk /dev/sdb

enter fdisk utility for the new disk

n

new partition

enter (default)

new standalone disk

enter (default)

first sector 2048 last sector 67108863
(whole disk = 1 partition)

enter (default)

w

write (apply)

mkfs.xfs /dev/sdb1

create xfs filesystem for the disk

mkdir /data

create directory to mount the disk to

lsblk -f

retrieve UUID

mount /dev/sdb1 /data

mount the disk to the directory

nano /etc/fstab

add the below line to mount during boot (spaces = tab)
/dev/sdb1    /data    xfs    defaults    0 0

UUID=4461ddd4-6c2c-4078-ab90-d4514368dd09    /data    xfs    defaults    0 0

reboot

verify successful boot

umount /data

to unmount

mount -a

mount disks again according to /etc/fstab

 

LVM (Logical Volume Management)

  • Allows disks to be combined together via software
  • Volume groups can be extended by adding additional disks

Physical Volume

Volume Group

Logical Volume

Mounted On

Disk 1

rootvg

system

/

home

/home

swap

 

Disk 2

datavg

data1

/data1

Disk 3

data2

/data2

Disk 4

data3

/data3

data4

/data4

 

Add Disk and Create LVM Partition

File system

datafs

Logical Volume(s)

datalv

Volume Group

datavg

Physical Volume

/dev/sda1

/dev/sdb1

/dev/sdc1

Partitions

/dev/sda1

/dev/sdb1

/dev/sdc1

Hard Disks

/dev/sda

/dev/sdb

/dev/sdc

 

Basic Commands

pvdisplay

display phsyical volumes

pvs

summary physical volumes

vgdisplay

display volume groups

vgs

summary volume groups

lvdisplay

display logical volumes

lvs

summary logical volumes

 

Creating this Structure

insert a new 1GB disk

fdisk /dev/sdc

enter fdisk utility for the new disk

n

new partition

enter (default)

new standalone disk

enter (default)

first sector 2048 last sector 67108863
(whole disk = 1 partition)

enter (default)

p

show partitions

t

change partition type

L

show LVM hex codes

8e

Linux LVM

w

write (apply)

pvcreate /dev/sdc1

create physical volume

vgcreate vg_app /dev/sdc1

create volume group

lvcreate -n lv_app --size 1020M vg_app

create logical volume (allowing overhead)

mkfs.xfs /dev/vg_app/lv_app

create filesystem

blkid /dec/vg_app/lv_app

retrieve UUID

mkdir app

create directory

mount /dev/vg_app/lv_app /app

mount

nano /etc/fstab

UUID=12345678-abcd-1234-efgh-123456789abc  /app  xfs  defaults  0 0

 

Extending this Space (this can only be done with LVM)

insert a new 1GB disk

fdisk /dev/sdd

enter fdisk utility for the new disk

n

new partition

enter (default)

new standalone disk

enter (default)

first sector 2048 last sector 67108863
(whole disk = 1 partition)

enter (default)

p

show partitions

t

change partition type

8e

Linux LVM

w

write (apply)

pvcreate /dev/sdd1

create phsyical volume

vgextend vg_app /dev/sdd1

extend vg_app to new disk

lvextend -L+1020M /dev/mapper/vg_app-lv_app

extend by 1020MB lv_app

xfs_growfs /dev/mapper/vg_app-lv_app

extend filesystem for lv_app

 


Revision #1
Created 2026-07-05 06:24:13 UTC by Admin
Updated 2026-07-05 06:24:20 UTC by Admin