Linux系统之创建逻辑卷
Posted jks212454
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux系统之创建逻辑卷相关的知识,希望对你有一定的参考价值。
一、磁盘分区
[root@node1 ~]# fdisk /dev/sda
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039): +2G
Created a new partition 1 of type 'Linux' and of size 2 GiB.
Partition #1 contains a xfs signature.
Do you want to remove the signature? [Y]es/[N]o: YES^H^H^H^H^H^H^H^H^H
The signature will be removed by a write command.
Command (m for help): Print
P: unknown command
Command (m for help): print
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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
Disklabel type: dos
Disk identifier: 0x962ab0e1
Device Boot Start End Sectors Size Id Type
/dev/sda1 2048 4196351 4194304 2G 83 Linux
Filesystem/RAID signature on partition 1 will be wiped.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2):
First sector (4196352-41943039, default 4196352):
Last sector, +sectors or +size{K,M,G,T,P} (4196352-41943039, default 41943039): +3G
Created a new partition 2 of type 'Linux' and of size 3 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
二、创建PV物理卷
[root@node1 ~]# pvcreate /dev/sda1 /dev/sda2
Physical volume "/dev/sda1" successfully created.
Physical volume "/dev/sda2" successfully created.
[root@node1 ~]#
三、创建卷组,指定PE大小为12M
[root@node1 ~]# vgcreate -s 12M vg02 /dev/sda1 /dev/sda2
Volume group "vg02" successfully created
[root@node1 ~]#
四、创建逻辑卷,大小50个PE
[root@node1 ~]# lvcreate -l 50 -n lv02 vg02
Logical volume "lv02" created.
[root@node1 ~]#
五、格式化逻辑卷,并挂载
1.格式化逻辑卷
[root@node1 ~]# mkfs.ext4 /dev/vg02/lv02
mke2fs 1.44.3 (10-July-2018)
Creating filesystem with 153600 4k blocks and 38400 inodes
Filesystem UUID: f6b201b7-6674-4a31-ba7a-1e97cf2ed35c
Superblock backups stored on blocks:
32768, 98304
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
[root@node1 ~]#
2.永久挂载
#
# /etc/fstab
# Created by anaconda on Fri Mar 19 22:21:55 2021
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=b7190d80-906f-4b9d-9ab4-5a503ecaea2c / xfs defaults 0 0
UUID=525a30a7-d484-4ed5-9f38-f827f54e29ff /boot xfs defaults 0 0
UUID=e6cf8733-5eec-4942-9429-c3e9087b6ff0 swap swap defaults 0 0
UUID="deff8218-3389-4245-a6bf-1716010fd6d4" /mnt/lv01 xfs defaults 0 0
UUID=7b7937af-408b-4370-9bd9-baa0cb5d1c6b swap swap defaults 0 0
UUID="c4477c1b-5ce7-4257-a44f-5e43e1d2a18e" /mnt/vdb3 xfs defaults 0 0
UUID="f6b201b7-6674-4a31-ba7a-1e97cf2ed35c" /mnt/lv02 ext4 defaults 0 0
[root@node1 ~]# mount -a
[root@node1 ~]# df -h /dev/vg02/lv02
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg02-lv02 575M 912K 532M 1% /mnt/lv02
[root@node1 ~]#
以上是关于Linux系统之创建逻辑卷的主要内容,如果未能解决你的问题,请参考以下文章
Linux系统KVM虚拟机实战LVM逻辑卷之扩展Swap交换分区
Linux下非逻辑卷扩容之创建逻辑卷pvcreate是否会损坏原数据测试
Linux下非逻辑卷扩容之创建逻辑卷pvcreate是否会损坏原数据测试