6

「LVM」- 创建分区

 2 years ago
source link: https://blog.k4nz.com/021746d45ad5629cf93456ee10dff289/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

「LVM」- 创建分区

 2022-04-05   CREATED BY JENKINSBOT

该笔记将记录:在 Linux 中,如何使用 LVM 创建逻辑卷,以及常见问题解决方法。

磁盘:两块磁盘,各 2T,共 4T,分别为 /dev/sdb 和 /dev/sdc;
系统:ClearOS(是RHEL的衍生版);

第一步、创建物理磁盘

(1)使用fdisk命令处理磁盘,创建分区,(2)并将「磁盘类型」设置为 8e 类型(Linux LVM)

fdisk /dev/sdb
# 详细过程略过……

fdisk /dev/sdc
# 详细过程略过……

创建完后,分别为/dev/sdb1和/dev/sdc1

第二步、创建物理卷(PV)

# 创建PV:
pvcreate /dev/sdb1 /dev/sdc1

# 查看PV信息
pvs
pvdisplay

第三步、创建卷组(VG)

# 创建VG:
vgcreate lvm00 /dev/sdb1 /dev/sdc1

# 查看VG信息
vgs
vgdisplay

第四步、创建逻辑卷(LV)

# 创建 LV:
# lvcreate -n kvmimg -l 12.5%FREE lvm00
# lvcreate -n kvmimg -l  100%FREE lvm00 # 使用所有空闲空间
lvcreate -n kvmimg -L 500G lvm00

# 查看 LG 信息
lvs
lvdisplay

# 重命名逻辑卷
# https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/logical_volume_manager_administration/lv_rename
lvrename /dev/vg02/lvold /dev/vg02/lvnew
lvrename vg02 lvold lvnew

第五步、格式化磁盘(创建文件系统)

# 找到磁盘格式化即可
mkfs.ext4 /dev/lvm00/kvmimg

LFCS: How to Manage and Create LVM Using vgcreate, lvcreate and lvextend Commands – Part 11
Linux: How to Create Logical Volume Using Maximum Available Free Space in Volume Group
“fdisk -l” like list of partitions and their types for LVM logical volumes?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK