虚拟机创建逻辑卷

📅 2026/7/12 7:32:49 👁️ 阅读次数 📝 编程学习
虚拟机创建逻辑卷

1. 添加硬盘

2.制作物理卷

#物理卷是LVM 的底层存储载体,可以是整个硬盘、硬盘分区或类似 RAID 的设备

#用硬盘分区制作

1.查看添加的硬盘设备文件名

[root@A ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 10G 0 disk

2.分区

[root@A ~]# fdisk /dev/sda Welcome to fdisk (util-linux 2.40.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. Created a new DOS (MBR) disklabel with disk identifier 0x5398f8ea. Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (1-4, default 1): First sector (2048-20971519, default 2048): Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-20971519, default 20971519) Created a new partition 1 of type 'Linux' and of size 5 GiB. Command (m for help): n Partition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (2-4, default 2): First sector (10487808-20971519, default 10487808): Last sector, +/-sectors or +/-size{K,M,G,T,P} (10487808-20971519, default 20971 Created a new partition 2 of type 'Linux' and of size 5 GiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.

3.制作逻辑卷

[root@A ~]# pvcreate /dev/sda1 /dev/sda2 Physical volume "/dev/sda1" successfully created. Physical volume "/dev/sda2" successfully created.

3.制作卷组

[root@A ~]# vgcreate -s 10M VG1 /dev/sda1 /dev/sda2 Volume group "VG1" successfully created

# -s 定义PE 大小 # VG1是卷组名

4.创建逻辑卷

[root@A ~]# lvcreate -n lv1 -L 500M VG1 Logical volume "lv1" created.

# -n 定义逻辑卷名称 -L 逻辑卷大小

5.格式化,挂载

#创建挂载点(空目录文件)----格式化(xfs格式)-----挂载(临时挂载)

[root@A ~]# mkdir /LV [root@A ~]# mkfs.xfs /dev/v vcs vcs4 vcsa1 vcsa5 vcsu2 vcsu6 vhost-net vcs1 vcs5 vcsa2 vcsa6 vcsu3 vfio/ vhost-vsock vcs2 vcs6 vcsa3 vcsu vcsu4 vga_arbiter vmci vcs3 vcsa vcsa4 vcsu1 vcsu5 vhci vsock [root@A ~]# mkfs.xfs /dev/VG1/lv1 meta-data=/dev/VG1/lv1 isize=512 agcount=4, agsize=32000 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=1 = reflink=1 bigtime=1 inobtcount=1 nrext64=1 = exchange=0 data = bsize=4096 blocks=128000, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1, parent=0 log =internal log bsize=4096 blocks=16384, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 [root@A ~]# mount /dev/VG1/lv1 /LV

#永久挂载

[root@A ~]# blkid /dev/VG1/lv1 /dev/VG1/lv1: UUID="7c2f6d8c-d282-44fd-91f6-c59ad6d2b119" BLOCK_SIZE="512" TYPE="xfs" [root@A ~]# vim /etc/fstab # # /etc/fstab # Created by anaconda on Mon May 18 12:19:22 2026 # # 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=d9b0fcff-ad6c-4dbf-9072-cbb7e6712d61 / xfs defaults 0 0 UUID=8194ed1b-7db5-449e-aca6-b01c6c9bd38b /boot xfs defaults 0 0 UUID=3C81-9935 /boot/efi vfat umask=0077,shortname=winnt 0 2 UUID=0ed9943d-0dec-4f79-876d-b38fdbd8bc47 none swap defaults 0 0 UUID=7c2f6d8c-d282-44fd-91f6-c59ad6d2b119 /LV xfs defaults 0 0 ~ ~ [root@A ~]# mount -a