1. Create and delete Step
1) create: Linux Partition -> pv -> VG -> lv -> FS -> Mount
2) Delete: umount -> lv -> vg -> pv- -> linux partition
Partition 2.Linux
Linux, we used fdisk partition on the disk. But for more than 2T disk, starting parted command partition.
. 1) GPT disks and MBR disk
GUID partition table of GPT disks usually referred to as a disk, unlike the original disk MBR, GPT disks no limitation to four primary partitions, the partitions can be set up to 128, usually parted command with GPT disk partition.
2) Operation
- View disk partition
[root] # fdisk -l
- on sda partition
[root] # parted / dev / sda
- Rescan partition
[root] # partprobe
- Reviewing the partition
[root] # fdisk -l
3 PV management
1) Create the PV (the pvcreate)
[the root] # the pvcreate / dev / sda3
2) Check PV (pvs or the pvscan)
[the root] # PVS
[the root] # the pvscan
3) See details PV (pvdiskplay)
[the root] # the pvdisplay / dev / sda3
4) Remove the PV (the pvremove)
[the root] # the pvremove / dev / sda3
Management 4.VG
1) Create VG (vgcreate)
Syntax: the vgcreate [-s <8M | 16M | ...>] VG0 / dev / SDB ... {l, 2,3}
- where:
-s: Specifies spreading block size (PE), the default is 4MB; may be 8M, 16M, 32M, 64M, ..., 16G, but can have a maximum of 65,532 LV extension block.
vg0: VG name of the newly created.
/ dev / sdb {1,2,3 ...} : a plurality of write PV, separated by spaces between the PV;
[root]# vgcreate -s 16M testvg /dev/sda3
2) See VG (vgs or the vgscan)
[the root] # Vgs
[the root] # the vgscan
3) View VG For more information (the vgdisplay)
[root] # testvg the vgdisplay
4) vg extension (the vgextend)
- with the new plan fdisk Partition
[the root] # fdisk / dev / SDA
Command (m for help): n
Select (default e): e
Selected partition 4
First sector (117187501-209715199, default 117188608):
Last sector, +sectors or +size{K,M,G} (117188608-209715199, default 209715199):
Command (m for help): p
Command (m for help): n
All primary partitions are in use
Adding logical partition 5
First sector (117190656-209715199, default 117190656):
Using default value 117190656
Last sector, +sectors or +size{K,M,G} (117190656-209715199, default 209715199): +20G
--改分区类型为lvm
Command (m for help): t
Partition number (1-5, default 5):
Hex code (type L to list all codes): 8e
Command (m for help): w
- Check again Partition
[root] # fdisk the -l
- Core zoning change notification system
[root] # partprobe
- Create the PV
[root] # the pvcreate / dev / sda5
- Extended VG
[root] # vgextend testvg / dev / sda5
5) vg reduction
[root] # vgreduce testvg / dev / sda5
6) vg delete
[root] # vgremove testvg
LV management. 5
. 1) LV created (the lvcreate)
Syntax. 1: 512M the lvcreate -L -L 512M -n Data testvg,
- wherein
set of LV size 512M.
-n data: Set LV name is data.
[root] # lvcreate -L 510M -n date testvg
Syntax 2: Data testvg, the lvcreate -l -l -n 32 32
- wherein
the generated extended block 32 using LV, LV size = 32 * PE (default 4M) was 128M.
-n data: LV name. vg0: Set the LV VG is generated.
vg0: Set the LV VG is generated.
[root] # lvcreate -l 10 -n data testvg
2) See LV (lvs or the lvscan)
[the root] # LVS
3) Check LV detailed information (the lvdisplay)
[root] # testvg the lvdisplay
4) formatting the LV (the mkfs.ext3)
[the root] # the mkfs.ext3 / dev / testvg, / Data
5) increase in the LV (the lvextend)
[the root] -L #lvextend + 160M / dev / testvg, / Data
- which
is required for immediate effect resize2fs (Centos7 above with: xfs_growfs)
[the root] # resize2fs / dev / testvg, / data
[root]# xfs_growfs /dev/centos/root
6) reducing the size of the LV (the lvreduce)
[the root] # the lvreduce -L 160M / dev / testvg, / Data
[the root] # resize2fs / dev / testvg, / Data
[root]# xfs_growfs /dev/centos/root
7) Delete LV (lvremove / vg / lv)
[root]# lvremove /dev/testvg/date
6) to mount the file system
[the root] # the mkfs.ext3 / dev / testvg, / Data
[the root] # mkdir / Data
[the root] # Mount / dev / testvg, / Data / Data
7 lvm snapshots
1) Create snapshot
Syntax: 64 -s -n databackup the lvcreate -l / dev / testvg, / Data
- where
-l 64: 64 specified snapshot extension block.
Total = 64 * block size of the extended single
-n databackup: the name of the generated snapshot.
/ dev / testvg / data: source LV name.
[root] # lvcreate -L 160M -s -n databackup / dev / testvg / data
2) View LVM snapshots (lvscan)
[root] # lvscan
3) For more information see the snapshot (the lvdisplay)
[the root] # the lvdisplay / dev / testvg, / Data
4) Delete (lvremove) snapshot
[root] # lvremove / dev / testvg / databackup