虚拟机创建逻辑卷

发布时间:2026/7/12 7:29:28
虚拟机创建逻辑卷 1. 添加硬盘2.制作物理卷#物理卷是LVM 的底层存储载体可以是整个硬盘、硬盘分区或类似 RAID 的设备#用硬盘分区制作1.查看添加的硬盘设备文件名[rootA ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 10G 0 disk2.分区[rootA ~]# 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.制作逻辑卷[rootA ~]# pvcreate /dev/sda1 /dev/sda2 Physical volume /dev/sda1 successfully created. Physical volume /dev/sda2 successfully created.3.制作卷组[rootA ~]# vgcreate -s 10M VG1 /dev/sda1 /dev/sda2 Volume group VG1 successfully created# -s 定义PE 大小 # VG1是卷组名4.创建逻辑卷[rootA ~]# lvcreate -n lv1 -L 500M VG1 Logical volume lv1 created.# -n 定义逻辑卷名称 -L 逻辑卷大小5.格式化挂载#创建挂载点空目录文件----格式化xfs格式-----挂载临时挂载[rootA ~]# mkdir /LV [rootA ~]# 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 [rootA ~]# mkfs.xfs /dev/VG1/lv1 meta-data/dev/VG1/lv1 isize512 agcount4, agsize32000 blks sectsz512 attr2, projid32bit1 crc1 finobt1, sparse1, rmapbt1 reflink1 bigtime1 inobtcount1 nrext641 exchange0 data bsize4096 blocks128000, imaxpct25 sunit0 swidth0 blks naming version 2 bsize4096 ascii-ci0, ftype1, parent0 log internal log bsize4096 blocks16384, version2 sectsz512 sunit0 blks, lazy-count1 realtime none extsz4096 blocks0, rtextents0 [rootA ~]# mount /dev/VG1/lv1 /LV#永久挂载[rootA ~]# blkid /dev/VG1/lv1 /dev/VG1/lv1: UUID7c2f6d8c-d282-44fd-91f6-c59ad6d2b119 BLOCK_SIZE512 TYPExfs [rootA ~]# 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. # UUIDd9b0fcff-ad6c-4dbf-9072-cbb7e6712d61 / xfs defaults 0 0 UUID8194ed1b-7db5-449e-aca6-b01c6c9bd38b /boot xfs defaults 0 0 UUID3C81-9935 /boot/efi vfat umask0077,shortnamewinnt 0 2 UUID0ed9943d-0dec-4f79-876d-b38fdbd8bc47 none swap defaults 0 0 UUID7c2f6d8c-d282-44fd-91f6-c59ad6d2b119 /LV xfs defaults 0 0 ~ ~ [rootA ~]# mount -a