14
Logical Volume Manager | XFS Redhat Enterprise Linux 6.x Presented by Sarwar Javaid

Logical volume manager xfs

Embed Size (px)

Citation preview

Page 1: Logical volume manager xfs

Logical Volume Manager | XFS

Redhat Enterprise Linux 6.x

Presented by Sarwar Javaid

Page 2: Logical volume manager xfs
Page 3: Logical volume manager xfs

LVM Structure

LVM consists of the following components:

Physical Volumes: these are the “real” disk devices.

Volume Group: a physical volume group (or just volume group for short) is a group of physical disks

Logical Volume: the logical volume is the top of the LVM pyramid.

LVM Configuration

[root@lvm-test ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda3 18G 8.1G 8.3G 50% /

tempfs 940M 0 940M 0% /dev/shm

/dev/sda1 504M 44M 435M 10% /boot

/dev/sdb1 5G 2M 4.9G 1% /Data

Change Partition ID '8e'{ Linux LVM } on both Secoundry Hard Drives {'/dev/sdb'}

[root@lvm-test ~]# fdisk /dev/sdb

Command (m for help): p

Device Boot Start End Blocks Id System

/dev/sdb1 1 1448 5241740 83 Linux

Page 4: Logical volume manager xfs

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): 8e

Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

/dev/sdb1 1 1448 5241740 8e Linux LVM

Physical Volume::Create

Syntax: pvcreate <physicaldeviceName>

[root@lvm-test ~]# pvcreate /dev/sdb1

Physical volume "/dev/sdb1" successfully created

Report information about physical volumes

Physical Volume::Report Information

[root@lvm-test ~]# pvs

PV VG Fmt Attr PSize PFree

/dev/sdb1 lvm2 a-- 5.00g 5.00g

Page 5: Logical volume manager xfs

Physical Volume::Display information Attribute

[root@lvm-test ~]# pvdisplay

"/dev/sdb1" is a new physical volume of "5.00 GiB"

--- NEW Physical volume ---

PV Name /dev/sdb1

VG Name

PV Size 5.00 GiB

Allocatable NO

PE Size 0

Total PE 0

Free PE 0

Allocated PE 0

PV UUID bvqsXU-NHcR-ARpa-U5RB-NM7b-4Pb5-1bX3ZS

Physical Volume::Group Creation

Syntaxvgcreate -s <blockSize> VOLUMEGROUPNAME PHYSICALVOLPATH [PHYSICALVOLPATH] …

[root@lvm-test ~]# vgcreate -s 4MB Primary_Group /dev/sdb1

Volume Group “Primary_Group” successfully created

Page 6: Logical volume manager xfs

Logical Volume::Creation

Syntax: lvcreate -l {extents “+LogicalExtentsNumber%SPACE”> -n VGNAME

[root@lvm-test ~]# lvcreate -l 100%FREE -n volgroup_01 Primary_Group

Logical volume "volgroup_01" created

Logical Volume::Display information Attribute

[root@lvm-test ~]# lvs

LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert

volgroup_01 Primary_Group -wi-a---- 5.00g

Page 7: Logical volume manager xfs

Filesystem::Create [XFS]

Syntax: mkfs.xfs <device name>

[root@lvm-test ~]# mkfs.xfs /dev/primary_group/volgroup_01

meta-data=/dev/primary_group/volgroup_01 isize=256 agcount=4, agsize=654848 blks

= sectsz=512 attr=2, projid32bit=0

data = bsize=4096 blocks=2619392, imaxpct=25

= sunit=0 swidth=0 blks

naming =version 2 bsize=4096 ascii-ci=0

log =internal log bsize=4096 blocks=2560, version=2

= sectsz=512 sunit=0 blks, lazy-count=1

realtime =none extsz=4096 blocks=0, rtextents=0

Filesystem::Mount point Creation

A) Label

Syntax: xfs_admin -L <Labe name> <device name>

[root@lvm-test ~]# mkdir /Data && xfs_admin -L “/Data” /dev/primary_group/volgroup_01

writing all SBs

new label = "/Data"

Page 8: Logical volume manager xfs

B) UUID “Universally Unique Identifier”

Syntax: blkid | grep <filesystem>

[root@lvm-test ~]# blkid | grep xfs

/dev/mapper/Primary Group-volgroup_01: UUID="06ad9ff2-4cca-4b14-a336-f6bffc351db0" TYPE="xfs"

C) Bootable

[root@lvm-test ~]# vi /etc/fstab → {add following line in file}

UUID=06ad9ff2-4cca-4b14-a336-f6bffc351db0 /Data xfs defaults 1 2

[x: save and quit]

D) Test

[root@lvm-test ~]# mount /Data

[root@lvm-test ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda3 18G 8.2G 8.2G 50% /

tmpfs 940M 224K 940M 1% /dev/shm

/dev/sda1 504M 44M 435M 10% /boot

/dev/mapper/Primary_Group-volgroup_01

5.0G 33M 5.0G 1% /Data

Page 9: Logical volume manager xfs

Logical Volume::Extend Logical Volume Size [newDisk]

Power off the virtual machine. Edit the virtual machine settings and add new virtual disk [requiured size]. In this

scenario we choose 5GB

Page 10: Logical volume manager xfs

Partition::Create [Linux LVM]

Syntax: fdisk <device name>

[root@lvm-test ~]# fdisk /dev/sdc

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

switch off the mode (command 'c') and change display units to

sectors (command 'u').

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-1018, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-1018, default 1018):

Using default value 1018

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): 8e

Changed system type of partition 1 to 8e (Linux LVM)

Page 11: Logical volume manager xfs

Command (m for help): p

Disk /dev/sdc: 5368 MB, 5368709120 bytes

166 heads, 62 sectors/track, 1018 cylinders

Units = cylinders of 10292 * 512 = 5269504 bytes

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

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000c1964

Device Boot Start End Blocks Id System

/dev/sdc1 1 1018 5238597 8e Linux LVM

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

Physical Volume::Create

[root@lvm-test ~]# pvcreate /dev/sdc1

Physical volume "/dev/sdc1" successfully created

Physical Volume::Report information

[root@lvm-test ~]# pvs

PV VG Fmt Attr PSize PFree

/dev/sdb1 Primary_Group lvm2 a-- 5.00g 0

/dev/sdc1 lvm2 a-- 5.00g 5.00g

Page 12: Logical volume manager xfs

Physical Volume::Display information Attribute

[root@lvm-test ~]# pvdisplay

"/dev/sdb1" is a new physical volume of "5.00 GiB"

--- Physical volume ---

PV Name /dev/sdb1

VG Name Primary_Group

PV Size 5.00 GiB / not usable 2.89 MiB

Allocatable yes (but full)

PE Size 4.00 MiB

Total PE 1279

Free PE 0

Allocated PE 1279

PV UUID LmdgEl-a8Eh-9dt0-HqRw-v13R-gVAl-hgkwaX

"/dev/sdc1" is a new physical volume of "5.00 GiB"

--- NEW Physical volume ---

PV Name /dev/sdc1

VG Name

PV Size 5.00 GiB

Allocatable NO

PE Size 0

Total PE 0

Free PE 0

Allocated PE 0

PV UUID WiMTu0-Iuti-V1f0-e8KX-tri4-zLIX-gd4FWl

Page 13: Logical volume manager xfs

Volume Group ::Device add

Syntax: vgextend {VolumeGroup} <deviceName>

[root@lvm-test ~]# vgextend Primary_Group /dev/sdc1

Volume group "Primary_Group" successfully extended

Volume Volume::Size extend

Syntax: lvextend -l {extents “+LogicalExtentsNumber%SPACE”> <logicalVolumePath>

[root@lvm-test ~]# lvextend -l +100%FREE /dev/mapper/Primary_Group-volgroup_01

Extending logical volume volgroup_01 to 9.99 GiB

Logical volume volgroup_01 successfully resized

Page 14: Logical volume manager xfs

FileSystem::Grow

Syntax: xfs_growfs <logicalVolumePath>

[root@lvm-test ~]# xfs_growfs /dev/Primary_Group/volgroup_01

meta-data=/dev/mapper/Primary_Group-volgroup_01 isize=256 agcount=4, agsize=327424 blks

= sectsz=512 attr=2, projid32bit=0

data = bsize=4096 blocks=1309696, imaxpct=25

= sunit=0 swidth=0 blks

naming =version 2 bsize=4096 ascii-ci=0

log =internal bsize=4096 blocks=2560, version=2

= sectsz=512 sunit=0 blks, lazy-count=1

realtime =none extsz=4096 blocks=0, rtextents=0

data blocks changed from 1309696 to 2618368

Final

[root@lvm-test ~]# df -h

Filesystem Size Used Avail Use% Mounted on

/dev/sda3 18G 8.3G 8.1G 51% /

tempfs 940M 76K 940M 1% /dev/shm

/dev/sda1 504M 67M 412M 14% /boot

/dev/mapper/Primary_Group-volgroup_01

10G 34M 10G 1% /Data