Linux 如何创建逻辑卷并使用
一、逻辑卷的介绍
生成环境中逻辑卷使用率很高
逻辑卷的诞生:如果对磁盘直接使用fdisk分区,那么这中分区,我们叫做Linux的标准分区,Linux的标准分区格式化成文件系统之后,挂载使用,那么一旦文件系统的空间满了,是无法进行扩容的。如果一定要进行扩容,需要将数据备份出来,再换一个更大的文件系统,再将数据还原回去。这种方法效果特别低。
逻辑卷的
pv(plysical volume)物理卷
vg(volume group) 卷组
lv(logical volume) 逻辑卷
pv的创建,pv的删除(向pv里面加入新的块设备就相当于扩容pv,从pv里边删除块设备,就相当于缩容pv)
vg的创建,vg的删除,vg的扩容,vg的缩容(不包含)
lv的创建,lv对的删除,lv的扩容,lv的缩容(不包含)
逻辑卷创建顺序:
- pvcreate创建物理卷
- vgcreate 创建卷组
- lvcreate 创建逻辑卷
- 格式化逻辑卷(mkfs)
- 挂载逻辑卷(mount)
逻辑卷删除顺序:
- 卸载逻辑卷(umount)
- lvremove 删除逻辑卷
- vgreduce 从卷组中移除物理卷
- vgremove 删除卷组
- pvremove 删除物理卷
二、创建物理卷(PV)
1、pvcreate创建物理卷
# 需要先进行分区
[server root ~] # fdisk /dev/sdc -l
Disk /dev/sdc: 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: 0xc1c4f2ab
Device Boot Start End Blocks Id System
/dev/sdc1 2048 2099199 1048576 83 Linux
/dev/sdc2 2099200 6293503 2097152 83 Linux
[server root ~] #
#创建和删除
[server root ~] # pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created.
[server root ~] # pvcreate /dev/sdc2
Physical volume "/dev/sdc2" successfully created.
[server root ~] # pvs
PV VG Fmt Attr PSize PFree
/dev/sdc1 lvm2 --- 1.00g 1.00g
/dev/sdc2 lvm2 --- 2.00g 2.00g
# PV:物理卷
/dev/sdc1:第一个物理卷,在 /dev/sdc 磁盘上的第一个分区
/dev/sdc2:第二个物理卷,在 /dev/sdc 磁盘上的第二个分区
# VG:卷组
# Fmt:格式。lvm2 是当前LVM的版本,表示这是一个LVM2格式的物理卷(LVM的第二版格式)
# Attr:属性。 --- 表示该物理卷没有特殊的属性标记
# PSize:物理卷大小
/dev/sdc1 的大小是 1.00GB
/dev/sdc2 的大小是 2.00GB
# PFree:物理卷空虚空间
/dev/sdc1 上有 1.00GB 的空闲空间
/dev/sdc2 上有 2.00GB 的空闲空间
2、如果pv已经被某个vg使用,那么无法被删除
[server root ~] # pvcreate /dev/sdc{1..2}
Physical volume "/dev/sdc1" successfully created.
Physical volume "/dev/sdc2" successfully created.
[server root ~] # pvs
PV VG Fmt Attr PSize PFree
/dev/sdc1 lvm2 --- 1.00g 1.00g
/dev/sdc2 lvm2 --- 2.00g 2.00g
[server root ~] # pvdisplay /dev/sdc1
"/dev/sdc1" is a new physical volume of "1.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdc1
VG Name
PV Size 1.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 5GMmBz-KjXz-iXOS-12lx-fBaF-W2db-3LRzXY
pvcreate也可以直接创建一整个磁盘
# 前提是磁盘没有进行分区,如果进行分区了需要删除分区,然后进行创建
[server root ~] # pvcreate /dev/sdb
Device /dev/sdb excluded by a filter.
[server root ~] # lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 40G 0 disk
├─sda1 8:1 0 512M 0 part /boot
├─sda2 8:2 0 4G 0 part [SWAP]
└─sda3 8:3 0 35.5G 0 part /
sdb 8:16 0 20G 0 disk
├─sdb1 8:17 0 5G 0 part /mount-point1
├─sdb2 8:18 0 1K 0 part
├─sdb5 8:21 0 5G 0 part /mount-point2
└─sdb6 8:22 0 6G 0 part /mount-point3
sdc 8:32 0 10G 0 disk
├─sdc1 8:33 0 1G 0 part
└─sdc2 8:34 0 2G 0 part
sr0 11:0 1 4.4G 0 rom
[server root ~] # fdisk /dev/sdc
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.
Command (m for help): d
Partition number (1,2, default 2):
Partition 2 is deleted
Command (m for help): d
Selected partition 1
Partition 1 is deleted
Command (m for help): d
No partition is defined yet!
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[server root ~] #
[server root ~] # lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 40G 0 disk
├─sda1 8:1 0 512M 0 part /boot
├─sda2 8:2 0 4G 0 part [SWAP]
└─sda3 8:3 0 35.5G 0 part /
sdb 8:16 0 20G 0 disk
├─sdb1 8:17 0 5G 0 part /mount-point1
├─sdb2 8:18 0 1K 0 part
├─sdb5 8:21 0 5G 0 part /mount-point2
└─sdb6 8:22 0 6G 0 part /mount-point3
sdc 8:32 0 10G 0 disk
sr0 11:0 1 4.4G 0 rom
[server root ~] # pvcreate /dev/sdc
WARNING: dos signature detected on /dev/sdc at offset 510. Wipe it? [y/n]: y
Wiping dos signature on /dev/sdc.
Physical volume "/dev/sdc" successfully created.
[server root ~] # pvs
PV VG Fmt Attr PSize PFree
/dev/sdc lvm2 --- 10.00g 10.00g
二、创建卷组(VG)
1、vgcreate创建 卷组
[server root ~] # fdisk /dev/sdc -l
Disk /dev/sdc: 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: 0x9c82f447
Device Boot Start End Blocks Id System
/dev/sdc1 2048 2099199 1048576 83 Linux
/dev/sdc2 2099200 6293503 2097152 83 Linux
[server root ~] # pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created.
[server root ~] # pvcreate /dev/sdc2
Physical volume "/dev/sdc2" successfully created.
[server root ~] # pvs
PV VG Fmt Attr PSize PFree
/dev/sdc1 lvm2 --- 1.00g 1.00g
/dev/sdc2 lvm2 --- 2.00g 2.00g
[server root ~] # vgcreate vg1 /dev/sdc1
Volume group "vg1" successfully created
[server root ~] # vgcreate vg2 /dev/sdc2
Volume group "vg2" successfully created
[server root ~] #
[server root ~] # vgs
VG #PV #LV #SN Attr VSize VFree
vg1 1 0 0 wz--n- 1020.00m 1020.00m
vg2 1 0 0 wz--n- <2.00g <2.00g
[server root ~] # pvs
PV VG Fmt Attr PSize PFree
/dev/sdc1 vg1 lvm2 a-- 1020.00m 1020.00m
/dev/sdc2 vg2 lvm2 a-- <2.00g <2.00g
vg卷组的删除(如果vg上有逻辑卷在使用,那么vg无法删除)
[server root ~] # vgs
VG #PV #LV #SN Attr VSize VFree
vg1 1 0 0 wz--n- 1020.00m 1020.00m
vg2 1 0 0 wz--n- <2.00g <2.00g
[server root ~] # vgremove vg1
Volume group "vg1" successfully removed
[server root ~] # vgs
VG #PV #LV #SN Attr VSize VFree
vg2 1 0 0 wz--n- <2.00g <2.00g
[server root ~] # vgremove vg2
Volume group "vg2" successfully removed
[server root ~] # vgs
[server root ~] #
2、vg卷组的扩容
# 在 /dev/sdc3 物理卷(PV)上创建了一个名为 vg2 的卷组(VG)
[server root ~] # vgcreate vg2 /dev/sdc3
Physical volume "/dev/sdc3" successfully created.
Volume group "vg2" successfully created
# pvs查看物理卷,vgs查看卷组信息
[server root ~] # pvs
PV VG Fmt Attr PSize PFree
/dev/sdc1 lvm2 --- 1.00g 1.00g
/dev/sdc2 lvm2 --- 2.00g 2.00g
/dev/sdc3 vg2 lvm2 a-- <3.00g <3.00g
[server root ~] # vgs
VG #PV #LV #SN Attr VSize VFree
vg2 1 0 0 wz--n- <3.00g <3.00g
# VG:卷组名称
# #PV:物理卷数量
# #LV:逻辑卷数量
# #SN:快照数量
# Attr:属性
wz--n-:这是卷组的属性,表示该卷组的状态和特性:
w:表示该卷组是可写的(writable)。
z:表示该卷组处于正常状态,没有错误。
--:表示没有设置其他特别的标志。
n:表示该卷组是可扩展的(可以添加更多物理卷)。
-:表示没有设置其他标志。
# VSize:卷组的总大小
# VFree:卷组的剩余空间
# 将 /dev/sdc1 扩展到卷组 vg2,即把 /dev/sdc1 纳入 vg2 卷组进行管理
[server root ~] # vgextend vg2 /dev/sdc1
Volume group "vg2" successfully extended
[server root ~] # vgs
VG #PV #LV #SN Attr VSize VFree
vg2 2 0 0 wz--n- 3.99g 3.99g
[server root ~] #
# 删除旧的卷组,创建新的卷组 vg2,并将 /dev/sdc1 作为物理卷(PV)添加进这个卷组。
# -s 8M 参数指定了物理扩展(PE)的大小为 8MB
[server root ~] # vgremove vg2
Volume group "vg2" successfully removed
[server root ~] #
[server root ~] # vgs
[server root ~] # vgcreate vg2 /dev/sdc1 -s 8M
Volume group "vg2" successfully created
[server root ~] # vgdisplay vg2
--- Volume group ---
VG Name vg2
System ID
Format lvm2
Metadata Areas 1
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 1
Act PV 1
VG Size 1016.00 MiB
PE Size 8.00 MiB
Total PE 127
Alloc PE / Size 0 / 0
Free PE / Size 127 / 1016.00 MiB
VG UUID 2l9GEi-6Kiw-RdcQ-vF9G-zKMx-B2y2-Pt8RnB
三、创建逻辑卷(LV)
1、lvcreate 命令创建语法
lvcreate -n 逻辑卷名字 -L 大小为多少 卷组名
-n 表示逻辑卷的名字
-L 表示逻辑卷的大小
vg2 表示使用卷组vg2创建该逻辑卷
# 现在卷组只有一个,大小是1016M,没有相关逻辑卷的信息
[server root ~] # vgs
VG #PV #LV #SN Attr VSize VFree
vg2 1 0 0 wz--n- 1016.00m 1016.00m
[server root ~] # lvs
# 创建一个逻辑卷lv1,大小为300M
[server root ~] # lvcreate -n lv1 -L 300M vg2
Rounding up size to full physical extent 304.00 MiB
Logical volume "lv1" created.
[server root ~] # lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv1 vg2 -wi-a----- 304.00m
[server root ~] # lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv1 vg2 -wi-a----- 304.00m
[server root ~] # vgs
VG #PV #LV #SN Attr VSize VFree
vg2 1 1 0 wz--n- 1016.00m 712.00m
# 创建lv2逻辑卷,大小为800M
[server root ~] # lvcreate -n lv2 -L 800M vg2
Volume group "vg2" has insufficient free space (89 extents): 100 required.
# 卷组总大小只有1016M,剩余712M,所有创建报错了,需要扩容vg2卷组
[server root ~] # vgextend vg2 /dev/sdc3
Volume group "vg2" successfully extended
# #PV变为2,表示现在卷组vg2包含了2个物理卷
# VSize增加为3.98GB,VFree也增加为大约3.69GB。
[server root ~] # vgs
VG #PV #LV #SN Attr VSize VFree
vg2 2 1 0 wz--n- 3.98g <3.69g
# 再次创建逻辑卷lv2,大小为800MB
[server root ~] # lvcreate -n lv2 -L 800M vg2
Logical volume "lv2" created.
[server root ~] # lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv1 vg2 -wi-a----- 304.00m
lv2 vg2 -wi-a----- 800.00m
[server root ~] #
2、逻辑卷格式化
逻辑卷创建完成之后,可以直接格式化成为文件系统使用
如果卷组下面创建了一个新的逻辑卷,那么该逻辑卷就会自动的在设备文件路径出现/dev/vgname/lvname
[server root ~] # ls /dev/vgs2
ls: cannot access /dev/vgs2: No such file or directory
[server root ~] # ls /dev/vg2
lv1 lv2
[server root ~] # ls /dev/vg2/ -l
total 0
lrwxrwxrwx 1 root root 7 Nov 26 16:18 lv1 -> ../dm-0
lrwxrwxrwx 1 root root 7 Nov 27 08:33 lv2 -> ../dm-1
[server root ~] # ls -l /dev/dm-1 /dev/dm-1
brw-rw---- 1 root disk 253, 1 Nov 27 08:33 /dev/dm-1
brw-rw---- 1 root disk 253, 1 Nov 27 08:33 /dev/dm-1
# dm设备就表示逻辑卷的本尊。dm全拼是device mapper
[server root ~] # ls /dev/mapper/ -l
total 0
crw------- 1 root root 10, 236 Nov 26 16:18 control
lrwxrwxrwx 1 root root 7 Nov 26 16:18 vg2-lv1 -> ../dm-0
lrwxrwxrwx 1 root root 7 Nov 27 08:33 vg2-lv2 -> ../dm-1
# 列出了通过 UUID(通用唯一标识符)标识的磁盘分区和设备的符号链接
# /dev/disk/by-uuid/ 是一个符号链接目录,它包含了每个磁盘分区(包括硬盘、固态硬盘、光驱等)的 UUID 与设备节点之间的映射。UUID 是一种唯一标识符,用于标识磁盘分区,而不是基于设备名称(如 /dev/sda1)来识别分区
[server root ~] # ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 9 Nov 26 10:57 2022-07-26-15-09-17-00 -> ../../sr0
lrwxrwxrwx 1 root root 10 Nov 26 10:57 48826076-975a-4d59-bf1a-5b1004e96f29 -> ../../sda2
lrwxrwxrwx 1 root root 10 Nov 26 10:57 4f4fe896-0d9e-4298-a6db-e0e314775bf0 -> ../../sdb6
lrwxrwxrwx 1 root root 10 Nov 26 10:57 51cbea6f-e37d-4ef5-a3f9-28a726c74085 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Nov 26 10:57 60a32a39-bdf6-4467-8893-3fc68045171b -> ../../sdb5
lrwxrwxrwx 1 root root 10 Nov 26 10:57 7f5b46d3-e0da-430a-97f2-2e6a19f9e4ff -> ../../sda3
lrwxrwxrwx 1 root root 10 Nov 26 10:57 ebaf11a7-f84f-4429-8df8-0ee0111e76e5 -> ../../sda1
# mkfs.ext4格式化逻辑卷lv1
[server root ~] # mkfs.
mkfs.btrfs mkfs.cramfs mkfs.ext2 mkfs.ext3 mkfs.ext4 mkfs.minix mkfs.xfs
[server root ~] # mkfs.ext4 /dev/mapper/vg2-lv1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
77824 inodes, 311296 blocks
15564 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33947648
38 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729, 204801, 221185
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
[server root ~] # ls -l /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 9 Nov 26 10:57 2022-07-26-15-09-17-00 -> ../../sr0
lrwxrwxrwx 1 root root 10 Nov 26 10:57 48826076-975a-4d59-bf1a-5b1004e96f29 -> ../../sda2
lrwxrwxrwx 1 root root 10 Nov 26 10:57 4f4fe896-0d9e-4298-a6db-e0e314775bf0 -> ../../sdb6
lrwxrwxrwx 1 root root 10 Nov 26 10:57 51cbea6f-e37d-4ef5-a3f9-28a726c74085 -> ../../sdb1
lrwxrwxrwx 1 root root 10 Nov 26 10:57 60a32a39-bdf6-4467-8893-3fc68045171b -> ../../sdb5
lrwxrwxrwx 1 root root 10 Nov 26 10:57 7f5b46d3-e0da-430a-97f2-2e6a19f9e4ff -> ../../sda3
lrwxrwxrwx 1 root root 10 Nov 27 10:17 8aea89c0-606d-4942-adb6-0a8263d32515 -> ../../dm-0
lrwxrwxrwx 1 root root 10 Nov 26 10:57 ebaf11a7-f84f-4429-8df8-0ee0111e76e5 -> ../../sda1
3、逻辑卷的删除
[server root ~] # lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv1 vg2 -wi-a----- 304.00m
lv2 vg2 -wi-a----- 800.00m
[server root ~] # lvremove lv2
Volume group "lv2" not found
Cannot process volume group lv2
[server root ~] # lvremove /dev/vg2/lv2
Do you really want to remove active logical volume vg2/lv2? [y/n]: y
Logical volume "lv2" successfully removed
[server root ~] # lvremove /dev/vg2/lv1
Do you really want to remove active logical volume vg2/lv1? [y/n]: y
Logical volume "lv1" successfully removed
[server root ~] # lvs
[server root ~] #
4、逻辑卷的扩容
# 创建大小为200M的lv1-ext4逻辑卷
[server root ~] # lvcreate -n lv1-ext4 vg2 -L 200M
WARNING: ext4 signature detected on /dev/vg2/lv1-ext4 at offset 1080. Wipe it? [y/n]: Y
Wiping ext4 signature on /dev/vg2/lv1-ext4.
Logical volume "lv1-ext4" created.
[server root ~] # lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv1-ext4 vg2 -wi-a----- 200.00m
# 创建大小为500M的lv2-xfs 逻辑卷
[server root ~] # lvcreate -n lv2-xfs vg2 -L 500M
Rounding up size to full physical extent 504.00 MiB
Logical volume "lv2-xfs" created.
[server root ~] # lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv1-ext4 vg2 -wi-a----- 200.00m
lv2-xfs vg2 -wi-a----- 504.00m
# 格式化lv1-ext4的逻辑卷
[server root ~] # mkfs.ext4 /dev/vg2/lv1-ext4
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
51200 inodes, 204800 blocks
10240 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33816576
25 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
# 格式化lv2-xfs的逻辑卷
[server root ~] # mkfs.xfs /dev/vg2/lv2-xfs
meta-data=/dev/vg2/lv2-xfs isize=512 agcount=4, agsize=32256 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=129024, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
# 创建目录并挂载
[server root ~] # mkdir /ext4-test /xfs-test
[server root ~] # mount -t ext4 /dev/vg2/lv1-ext4 /ext4-test/
[server root ~] # mount /dev/vg2/lv2-xfs /xfs-test/
[server root ~] #
[server root ~] # df -Th /xfs-test/ /ext4-test/
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg2-lv2--xfs xfs 501M 26M 476M 6% /xfs-test
/dev/mapper/vg2-lv1--ext4 ext4 190M 1.6M 175M 1% /ext4-test
# 通过dd命令写入数据
[server root ~] # dd if=/dev/zero of=/xfs-test/file
dd: writing to ‘/xfs-test/file’: No space left on device
973257+0 records in
973256+0 records out
498307072 bytes (498 MB) copied, 6.33404 s, 78.7 MB/s
[server root ~] # dd if=/dev/zero of=/ext4-test/file
dd: writing to ‘/ext4-test/file’: No space left on device
377177+0 records in
377176+0 records out
193114112 bytes (193 MB) copied, 3.09574 s, 62.4 MB/s
# 查看磁盘空间直接写满了,此时无法在对应目录下创建文件相关操作
[server root ~] # df -Th /xfs-test/ /ext4-test/
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg2-lv2--xfs xfs 501M 501M 20K 100% /xfs-test
/dev/mapper/vg2-lv1--ext4 ext4 190M 186M 0 100% /ext4-test
[server root ~] #
在线扩容,在线扩容是指的文件系统不能卸载文件.
# 将lv1-ext4扩容到300M
# 将lv2-xfs扩容到700M
[server root ~] # lvextend /dev/vg2/lv1-ext4 -L 300M
Rounding size to boundary between physical extents: 304.00 MiB.
Size of logical volume vg2/lv1-ext4 changed from 200.00 MiB (25 extents) to 304.00 MiB (38 extents).
Logical volume vg2/lv1-ext4 successfully resized.
[server root ~] # lvextend /dev/vg2/lv2-xfs -L 700M
Rounding size to boundary between physical extents: 704.00 MiB.
Size of logical volume vg2/lv2-xfs changed from 504.00 MiB (63 extents) to 704.00 MiB (88 extents).
Logical volume vg2/lv2-xfs successfully resized.
[server root ~] # lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lv1-ext4 vg2 -wi-ao---- 304.00m
lv2-xfs vg2 -wi-ao---- 704.00m
[server root ~] # df -Th /ext4-test /xfs-test
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg2-lv1--ext4 ext4 190M 186M 0 100% /ext4-test
/dev/mapper/vg2-lv2--xfs xfs 501M 501M 20K 100% /xfs-test
#因为扩容的部分没有格式化,所以文件系统没有检测不到
# ext4将文件系统加入到系统操作
[server root ~] # resize2fs /dev/vg2/lv1-ext4
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vg2/lv1-ext4 is mounted on /ext4-test; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 3
The filesystem on /dev/vg2/lv1-ext4 is now 311296 blocks long.
[server root ~] # df -Th /ext4-test/
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg2-lv1--ext4 ext4 291M 187M 87M 69% /ext4-test
# xfs将文件系统加入到系统操作
[server root ~] # xfs_
xfs_admin xfs_db xfs_fsr xfs_io xfs_metadump xfs_quota
xfs_bmap xfs_estimate xfs_growfs xfs_logprint xfs_mkfile xfs_repair
xfs_copy xfs_freeze xfs_info xfs_mdrestore xfs_ncheck xfs_rtcp
[server root ~] # xfs_growfs /dev/vg2/lv2-xfs
meta-data=/dev/mapper/vg2-lv2--xfs isize=512 agcount=4, agsize=32256 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=129024, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=855, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 129024 to 180224
[server root ~] # df -Th /xfs-test/
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg2-lv2--xfs xfs 701M 501M 200M 72% /xfs-test
提示:我建议多操作几遍,加深对逻辑卷如何创建以及使用的理解!
好了下一篇文章见😁😁😁
原文地址:https://blog.csdn.net/qq_51688785/article/details/144030655
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!