Lvm: Difference between revisions

From Halfface
Jump to navigation Jump to search
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Create partition.==
==Create partition.==
  fdisk /dev/sda1
  fdisk /dev/sda1
n
t
Partition type 8e


==Create physiscal volume.==
==Create physiscal volume.==
Line 10: Line 13:
  vgdisplay
  vgdisplay


==Create logical volume. Create a logic volume spanning 3 disks, each stripe 256kb, 1,5TB, called home, in Volume Group 00==
==create logical volume==
The logical volume is being created under /dev/VolGroup00/LogVol00
Create logical volume. Create a logic volume spanning 3 disks, each stripe 256kb, 1,5TB, called LogVol00 in VolGroup00
  lvcreate i3 -I 256 L1500000 -n LOgVol00 VolGroup00
  lvcreate -i3 -I 256 -L1500000 -n LogVol00 VolGroup00
  lvcreate  -L 5.12G -n LogVol02 VolGroup00 # Create logical volume of 5.12G on Volume group VolGroup00.
  lvcreate  -L 5.12G -n LogVol02 VolGroup00 # Create logical volume of 5.12G on Volume group VolGroup00.
lvcreate --name apps --size 30G vg0
==list volume groups==
  lvdisplay
  lvdisplay


Line 23: Line 28:
  resize_reiserfs -f /dev/VolGroup00/LogVol00
  resize_reiserfs -f /dev/VolGroup00/LogVol00


==Extent a ext3 partition.==
==Extend a ext3 partition.==
  lvextend -L +6g /dev/vgroot/root.fs
  lvextend -L +6g /dev/vgroot/root.fs
  resize2fs /dev/vgroot/root.fs
  resize2fs /dev/vgroot/root.fs
Line 38: Line 43:
  resize_reiserfs -s 10G /dev/VolGroup00/LogVol00 # Resize file system to 10GB.
  resize_reiserfs -s 10G /dev/VolGroup00/LogVol00 # Resize file system to 10GB.
  lvreduce -L 10G /dev/VolGroup00/LogVol00 # Resize logical volume to 1GB.
  lvreduce -L 10G /dev/VolGroup00/LogVol00 # Resize logical volume to 1GB.
vgreduce vg0 /dev/vdb1
  mount -t reiserfs /data
  mount -t reiserfs /data


Line 95: Line 101:
  pvscan
  pvscan
  pvremove /dev/xvdg
  pvremove /dev/xvdg
==remove logical volume and volume group when disk has been removed==
dmsetup info
dmsetup remove vg04-vz
==vgs==
Look to see if there is any available space.
vgs


==lvs==
Display information about logical volumes
lvs
Type and stripes
lvs -o+lv_layout,stripes
lvs -a -o+lv_layout,lv_role,stripes,devices
==add snapshot volume==
lvcreate -n root_SNAP -s vg0/root -L 1500M
==remove snapshot volume==
lvremove -f  /dev/vg0/root_SNAP
=pvresize=
Increase size of pv.
pvresize /dev/sdc
=pvs=
List usage of pv
[[Category:Applications]]
[[Category:Applications]]
[[Category:Unix]]
[[Category:Unix]]
[[Category:Storage]]
[[Category:Storage]]

Latest revision as of 15:34, 27 April 2022

Create partition.

fdisk /dev/sda1
n
t
Partition type 8e

Create physiscal volume.

pvcreate /dev/sda3
pvdisplay

Create volume group.

vgcreate VolGroup00 /dev/sda1
vgdisplay

create logical volume

Create logical volume. Create a logic volume spanning 3 disks, each stripe 256kb, 1,5TB, called LogVol00 in VolGroup00

lvcreate -i3 -I 256 -L1500000 -n LogVol00 VolGroup00
lvcreate  -L 5.12G -n LogVol02 VolGroup00 # Create logical volume of 5.12G on Volume group VolGroup00.
lvcreate --name apps --size 30G vg0

list volume groups

lvdisplay

Format logical volume.

mkfs.reiserfs /dev/VolGroup00/LogVol02

Extend a resizerfs logical volume.

lvextend -L+70G /dev/VolGroup00/LogVol00
resize_reiserfs -f /dev/VolGroup00/LogVol00

Extend a ext3 partition.

lvextend -L +6g /dev/vgroot/root.fs
resize2fs /dev/vgroot/root.fs

Shrink ext2/3 partition.

umount /data # umount /data
resize2fs /dev/VolGroup00/LogVol00 10G # Resize file system to 10GB.
lvreduce -L 10G /dev/VolGroup00/LogVol00 # Resize logical volume to 1GB.
e2fsck -f /dev/VolGroup00/LogVol00 # Check filesystem.
mount /data # mount /data

Shrink reizerfs volume. (not tested yet)

umount /data # unmount /data
resize_reiserfs -s 10G /dev/VolGroup00/LogVol00 # Resize file system to 10GB.
lvreduce -L 10G /dev/VolGroup00/LogVol00 # Resize logical volume to 1GB.
vgreduce vg0 /dev/vdb1
mount -t reiserfs /data
resize_reiserfs -s-150M /dev/VolGroup/LogVol00
lvreduce -L-150M /dev/VolGroup00/LogVol00

Create device-mapper in /proc/misc

modprobe dm-mod

Activate Volume Group.

lvm vgchange -a y VolGroup00

Create a snapshot volume.

modprobe dm-snapshot
lvcreate --snapshot --size 128M --name LogVol02snap /dev/VolGroup00/LogVol02

Create device maps from partition tables

kpartx -av /dev/VolGroup00/LogVol02

Copy logical volume.

dd if=/dev/VolGroup00/LogVol02 of=/dev/VolGroup00/LogVol03 bs=64M

Extend logical volume with disk.

vgextend vgroot /dev/sdb

Check for Free PE / Size. First we need to enlarge the logical volume.

vgdisplay

Now we enlarged the volume but not the filesystem.

lvextend -l +<number of extents> /dev/<volume group>/<logical volume>

This will grow the filesystem on-line.

resize2fs /dev/<volume group>/<logical volume>

When extending partition by deleting and adding partition.

pvchange -x /dec/sda

Logical volume information

lvs

You should see more than the standard disks.

 LV        VG        Attr   LSize   Origin Snap%  Move Log Copy%  Convert
 lvdata287 vgdata287 -wi--- 500.00G                                    
 lvdata306 vgdata306 -wi---  50.00G                                    
 lvdata370 vgdata370 -wi---  20.00G                                    
 lvdata371 vgdata371 -wi--- 600.00G                                    
 lvlog287  vglog287  -wi--- 100.00G                                    
 lvlog306  vglog306  -wi---  20.00G                                    
 lvlog370  vglog370  -wi---  10.00G                                    
 lvlog371  vglog371  -wi---  20.00G                                    
 opt.fs    vgroot    -wi-ao  12.00G                                    
 root.fs   vgroot    -wi-ao   4.00G                                    
 swap.vol  vgroot    -wi-ao   2.00G                                    
 var.fs    vgroot    -wi-ao   8.00G

remove a pv

lvremove vg2
vgremove vg2
pvscan
pvremove /dev/xvdg

remove logical volume and volume group when disk has been removed

dmsetup info
dmsetup remove vg04-vz

vgs

Look to see if there is any available space.

vgs

lvs

Display information about logical volumes

lvs

Type and stripes

lvs -o+lv_layout,stripes
lvs -a -o+lv_layout,lv_role,stripes,devices

add snapshot volume

lvcreate -n root_SNAP -s vg0/root -L 1500M

remove snapshot volume

lvremove -f  /dev/vg0/root_SNAP

pvresize

Increase size of pv.

pvresize /dev/sdc

pvs

List usage of pv