19 November 2016

Working with Logical Volumes

  • Physical Volume = pv
  • Volume Group = vg
  • Logical Volume = lv

 A Physical Volumne is a physical disk.
Volume Groups are made up of Physical Disk.
And Logical Volumes are created using a portion of a Volume Group

LVM is like an abstraction layer for storage, between your OS and the physical drives.

All these commands are "root" commands as we are changing system wide stuff here..

All the following commands can be preceeded with with pv or lv
s
display
create
rename
change
move
extend
reduce
resize
split
merge
convert
import
export
importclone
cfgbackup
cfgrestore
ck
scan
mknodes
remove
dump

E.g.
pvdisplay
pvs

Show Logical Volumes
lvdisplay
lvs


Setting up a new VLM
Setup Physical Disk(s)
fdisk -l
fdisk /dev/sdb

n = create new partition
p = create primary partition
1 = makes partition first on disk
t = change parition type
8e = changes to LVM
p = verify partition setup
w = write changes to disk

Create "LVM Physical Volume" on the new partition
pvcreate /dev/sdb1

Create "Volume Group" named vgroup1 made up of "Physical Volume" /dev/sdb1
vgcreate vgroup1 /dev/sdb1

Create Logical Volume on VG vgroup1, of size 10GB, named lvm1
lvcreate -L 10G -n lvm1 vgroup1

Format the new volume
mkfs -t ext3 /dev/vgroup1/lvm1

Mount it
mkdir /mnt/lvm1
mount -t ext3 /dev/vgroup1/lvm1 /mnt/lvm1


Resizing LVMs

  • resize – can shrink or expand physical volumes and logical volumes but not volume groups
  • extend – can make volume groups and logical volumes bigger but not smaller
  • reduce – can make volume groups and logical volumes smaller but not bigger


Grow Logical Volume
Add new drive to Volume Group to increase the VG free space (disks joined linearly, N-1 redundancy!)
vgextend vgroup1 /dev/sdc1

Extend a Logical Volume within a VG (ensure to use + otherwise will resize)
lvextend -L+100G /dev/vgroup1/lvm1






Extend filesystem within expanded Logical Volume
resize2fs /dev/vgroup1/lvm1

Shrink Logical Volume
Follow the same procedure to increase the size of the VM, in reverse, using vgreduce and lvreduce instead of XXextend.


Backup a Logical Volume Snapshot (online)
First add an additional temporary logical volume using the "-s" flag to the "lvm1" LV, to store all the tracked reads and writes made to the LVM since the snapshot, whilst the snapshot is being backed up. After backed up, you can remove this temp volume.
 lvcreate -L512M -s -n lvbackup /dev/vgroup1/lvm1

Mount Tmp Snapshot
mkdir /mnt/lvbackup
mount /dev/vgroup1/lvbackup /mnt/lvbackup

Copy Snapshot and Delete Temp LVM
  tar -cf /usbpath/lvm1-ss /mnt/lvbackup
Whilst the tar job is running, all the reads/writes that would be written to lvm1 are being tracked in lvbackup.

Clean up
umount /mnt/lvbackup
lvremove /dev/vgroup1/lvbackup 

Delete Logical Volume, Volume Group and Physical Volume
umount /mnt/lvm1
lvremove /dev/vgroup1/lvm
vgremove vgroup1 
pvremove /dev/sdb1 /dev/sdc1
 
  http://www.howtogeek.com/howto/40702/how-to-manage-and-use-lvm-logical-volume-management-in-ubuntu/



(To be finished)

1 comment:

  1. Another area the place Ignition Casino might enhance is to start out|to begin} tracking their sitewide slot RTP scores. After ready 30 minutes to attach with a consultant on reside chat, we were informed that they do not have|they don't have} this info. Therefore, we should rely on third-party audits for 1xbet games like 777 Deluxe and assume that they meet a normal of at least of|no less than} 95%.

    ReplyDelete