Linux-创建LVM
2018-03-26 19:11
260 查看
1:LVM组件
物理分区(fdisk)------》物理卷-----》之后将物理卷组合成物理卷组(卷组可以由多个物理的卷组成)-------》逻辑卷
物理卷是由多个物理分区组成,在使用的时候使用逻辑卷。使用逻辑卷和使用普通的分区是一样的。
命令:
以物理卷开头的就是pv,物理分区是fdisk来划分的分区,物理卷都是以pv开头的,卷组都是以vg开头的,逻辑卷是lv开头的。
创建一个卷组就是vg create,删除就是remove,逻辑卷扩展就是lv
extend。
查看就是display,scan。
创建两个物理卷(/dev/vdb1(1G),/dev/vdb2(2G)),之后创建一个卷组(vg01),之后创建一个逻辑卷(lv01)。
[kiosk@foundation0 ~]$ rht-vmctl start server
先将几台机器全部起来
[kiosk@foundation0 ~]$ rht-vmctl reset server
因为之前做过实验,将之前机子恢复一下
第一步:创建物理分区,改变分区的类型为8e(LVM)
[root@server0 ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x9707d65d.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519):
+1G
Partition 1 of type Linux and of size 1 GiB is set
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2099200-20971519, default 2099200):
Using default value 2099200
Last sector, +sectors or +size{K,M,G} (2099200-20971519, default 20971519):
+2G
Partition 2 of type Linux and of size 2 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
分区分好之后
Command (m for help): t
Partition number (1,2, default 2): 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x9707d65d
Device Boot Start End Blocks Id System
/dev/vdb1 2048 2099199 1048576 8e Linux LVM
/dev/vdb2 2099200 6293503 2097152 8e Linux LVM
2:创建物理的卷
[root@server0 ~]# pvcreate /dev/vdb{1,2}
Physical volume "/dev/vdb1" successfully created
Physical volume "/dev/vdb2" successfully created
[root@server0 ~]# pvscan 用这个命令查看
PV /dev/vdb1 lvm2 [1.00 GiB]
PV /dev/vdb2 lvm2 [2.00 GiB]
Total: 2 [3.00 GiB] / in use: 0 [0 ] / in no VG: 2 [3.00 GiB]
3:创建卷组
如果忘记了格式使用--help来查看
[root@server0 ~]# vgcreate vg01 /dev/vdb{1,2}
Volume group "vg01" successfully created
[root@server0 ~]# vgdisplay 查看vg的详细信息
--- Volume group ---
VG Name vg01
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 2.99 GiB
PE Size 4.00 MiB
可以看到卷组是由pe组成的,卷组由pe组成,每个pe默认是4m。可以看到由766个pe组成。
Total PE 766
Alloc PE / Size 0 / 0
Free PE / Size 766 / 2.99 GiB
VG UUID NkvnEf-aKlQ-eLbm-ooQy-dUHn-RIXr-g5KNeP
4:创建逻辑卷,逻辑卷最后才能被我们使用。使用逻辑卷就像使用普通的分区一样。
如果忘记了格式可以使用--help
[-n|--name LogicalVolumeName]
{-l|--extents LogicalExtentsNumber[%{VG|PVS|FREE}] |
-L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}这个选项是使用多少m,g,t。
[root@server0 ~]# lvcreate -n lv01 -L 1500M vg01
Logical volume "lv01" created
逻辑卷lv01是在vg01这个卷组里面创建的。
[root@server0 ~]# lvscan
ACTIVE '/dev/vg01/lv01' [1.46 GiB] inherit
b769
[root@server0 ~]# lvdisplay /dev/vg01/lv01 通过lvdisplay可以查看到详细的信息
--- Logical volume ---
LV Path /dev/vg01/lv01
LV Name lv01
VG Name vg01
LV UUID I7luVr-0d4q-c6xi-q2HT-JAz7-KNUK-w0x0Qf
LV Write Access read/write
LV Creation host, time server0.example.com, 2018-03-18 13:43:33 +0800
LV Status available
# open 0
LV Size 1.46 GiB
Current LE 375
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 252:0
通过fdisk也可以查看到详细信息
Disk /dev/mapper/vg01-lv01: 1572 MB, 1572864000 bytes, 3072000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
5:逻辑卷就像普通的分区一样,要将逻辑卷格式化。将逻辑卷制作为ext4的文件系统。
[root@server0 ~]# mkfs.ext4 /dev/mapper/vg01-lv01
6:格式化完了之后就是挂载了。
[root@server0 ~]# mkdir -p /u01
[root@server0 ~]# mount /dev/vg01/lv01 /u01
[root@server0 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 10G 3.0G 7.1G 30% /
devtmpfs 906M 0 906M 0% /dev
tmpfs 921M 80K 921M 1% /dev/shm
tmpfs 921M 17M 904M 2% /run[root@server0 ~]# blkid /dev/vg01/lv01
/dev/vg01/lv01: UUID="b425f1e7-fad8-40fe-9ca9-6fb3168588a8" TYPE="ext4"
tmpfs 921M 0 921M 0% /sys/fs/cgroup
/dev/mapper/vg01-lv01 1.5G 4.5M 1.4G 1% /u01
最后写入到/etc/fstab里面去。
[root@server0 ~]# blkid /dev/vg01/lv01
/dev/vg01/lv01: UUID="b425f1e7-fad8-40fe-9ca9-6fb3168588a8" TYPE="ext4"
1:LVM组件
物理分区(fdisk)------》物理卷-----》之后将物理卷组合成物理卷组(卷组可以由多个物理的卷组成)-------》逻辑卷
物理卷是由多个物理分区组成,在使用的时候使用逻辑卷。使用逻辑卷和使用普通的分区是一样的。
命令:
以物理卷开头的就是pv,物理分区是fdisk来划分的分区,物理卷都是以pv开头的,卷组都是以vg开头的,逻辑卷是lv开头的。
创建一个卷组就是vg create,删除就是remove,逻辑卷扩展就是lv
extend。
查看就是display,scan。
创建两个物理卷(/dev/vdb1(1G),/dev/vdb2(2G)),之后创建一个卷组(vg01),之后创建一个逻辑卷(lv01)。
[kiosk@foundation0 ~]$ rht-vmctl start server
先将几台机器全部起来
[kiosk@foundation0 ~]$ rht-vmctl reset server
因为之前做过实验,将之前机子恢复一下
第一步:创建物理分区,改变分区的类型为8e(LVM)
[root@server0 ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x9707d65d.
Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519):
+1G
Partition 1 of type Linux and of size 1 GiB is set
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2099200-20971519, default 2099200):
Using default value 2099200
Last sector, +sectors or +size{K,M,G} (2099200-20971519, default 20971519):
+2G
Partition 2 of type Linux and of size 2 GiB is set
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
分区分好之后
Command (m for help): t
Partition number (1,2, default 2): 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x9707d65d
Device Boot Start End Blocks Id System
/dev/vdb1 2048 2099199 1048576 8e Linux LVM
/dev/vdb2 2099200 6293503 2097152 8e Linux LVM
2:创建物理的卷
[root@server0 ~]# pvcreate /dev/vdb{1,2}
Physical volume "/dev/vdb1" successfully created
Physical volume "/dev/vdb2" successfully created
[root@server0 ~]# pvscan 用这个命令查看
PV /dev/vdb1 lvm2 [1.00 GiB]
PV /dev/vdb2 lvm2 [2.00 GiB]
Total: 2 [3.00 GiB] / in use: 0 [0 ] / in no VG: 2 [3.00 GiB]
3:创建卷组
如果忘记了格式使用--help来查看
[root@server0 ~]# vgcreate vg01 /dev/vdb{1,2}
Volume group "vg01" successfully created
[root@server0 ~]# vgdisplay 查看vg的详细信息
--- Volume group ---
VG Name vg01
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 2.99 GiB
PE Size 4.00 MiB
可以看到卷组是由pe组成的,卷组由pe组成,每个pe默认是4m。可以看到由766个pe组成。
Total PE 766
Alloc PE / Size 0 / 0
Free PE / Size 766 / 2.99 GiB
VG UUID NkvnEf-aKlQ-eLbm-ooQy-dUHn-RIXr-g5KNeP
4:创建逻辑卷,逻辑卷最后才能被我们使用。使用逻辑卷就像使用普通的分区一样。
如果忘记了格式可以使用--help
[-n|--name LogicalVolumeName]
{-l|--extents LogicalExtentsNumber[%{VG|PVS|FREE}] |
-L|--size LogicalVolumeSize[bBsSkKmMgGtTpPeE]}这个选项是使用多少m,g,t。
[root@server0 ~]# lvcreate -n lv01 -L 1500M vg01
Logical volume "lv01" created
逻辑卷lv01是在vg01这个卷组里面创建的。
[root@server0 ~]# lvscan
ACTIVE '/dev/vg01/lv01' [1.46 GiB] inherit
b769
[root@server0 ~]# lvdisplay /dev/vg01/lv01 通过lvdisplay可以查看到详细的信息
--- Logical volume ---
LV Path /dev/vg01/lv01
LV Name lv01
VG Name vg01
LV UUID I7luVr-0d4q-c6xi-q2HT-JAz7-KNUK-w0x0Qf
LV Write Access read/write
LV Creation host, time server0.example.com, 2018-03-18 13:43:33 +0800
LV Status available
# open 0
LV Size 1.46 GiB
Current LE 375
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 252:0
通过fdisk也可以查看到详细信息
Disk /dev/mapper/vg01-lv01: 1572 MB, 1572864000 bytes, 3072000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
5:逻辑卷就像普通的分区一样,要将逻辑卷格式化。将逻辑卷制作为ext4的文件系统。
[root@server0 ~]# mkfs.ext4 /dev/mapper/vg01-lv01
6:格式化完了之后就是挂载了。
[root@server0 ~]# mkdir -p /u01
[root@server0 ~]# mount /dev/vg01/lv01 /u01
[root@server0 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 10G 3.0G 7.1G 30% /
devtmpfs 906M 0 906M 0% /dev
tmpfs 921M 80K 921M 1% /dev/shm
tmpfs 921M 17M 904M 2% /run[root@server0 ~]# blkid /dev/vg01/lv01
/dev/vg01/lv01: UUID="b425f1e7-fad8-40fe-9ca9-6fb3168588a8" TYPE="ext4"
tmpfs 921M 0 921M 0% /sys/fs/cgroup
/dev/mapper/vg01-lv01 1.5G 4.5M 1.4G 1% /u01
最后写入到/etc/fstab里面去。
[root@server0 ~]# blkid /dev/vg01/lv01
/dev/vg01/lv01: UUID="b425f1e7-fad8-40fe-9ca9-6fb3168588a8" TYPE="ext4"
相关文章推荐
- Linux下创建、扩展、移除、管理LVM
- Linux中LVM的逻辑卷创建
- Linux LVM 创建、删除、扩展
- linux创建软raid和lvm的顺序
- 小小寒舍—linux分区,格式化,lvm,软件raid的创建
- Linux下磁盘分区与LVM创建
- linux下,使用lvm 创建、扩充 、缩减 逻辑磁盘大小,以及相应的文件系统大小
- linux下关于LVM的创建方法
- Linux环境下创建、扩展以及缩减LVM
- linux学习之:创建lvm磁盘
- Linux 逻辑卷LVM创建扩展删除实例
- Linux之LVM创建、扩容、缩减-2015082701
- Linux 磁盘分区、永久挂载、创建LVM逻辑卷
- 利用lvm创建及增加linux分区
- LINUX 下创建RAID5以及LVM磁盘配额
- lvcreate命令_Linux lvcreate 命令用法详解:用于创建LVM的逻辑卷
- LVM逻辑卷管理一PV/VG/LV的创建-Linux
- LINUX中LVM的创建过程
- (转)Linux LVM逻辑卷配置过程详解(创建、扩展、缩减、删除、卸载、快照创建)
- LVM逻辑卷管理一PV/VG/LV的创建-Linux