虚拟机LVM卷扩展实操

您所在的位置:网站首页 虚拟机扩展磁盘容量后如何再分区 虚拟机LVM卷扩展实操

虚拟机LVM卷扩展实操

2024-07-14 03:48| 来源: 网络整理| 查看: 265

虚拟机LVM卷扩展实际操作

文章目录 虚拟机LVM卷扩展实际操作一、LVM二、实际操作1.vmware为虚拟机增加存储空间2.创建分区3.创建物理卷4.扩展卷组5.逻辑卷扩展6.动态格式化扩容磁盘7.验证(成功) 三、汇总

一、LVM

LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分区管理的灵活性。LVM是在磁盘分区和文件系统之间添加的一个逻辑层,来为文件系统屏蔽下层磁盘分区布局,提供一个抽象的盘卷,在盘卷上建立文件系统。物理卷(physical volume)物理卷就是指硬盘分区或从逻辑上与磁盘分区具有同样功能的设备(如RAID),是LVM的基本存储逻辑块,但和基本的物理存储介质(如分区、磁盘等)比较,却包含有与LVM相关的管理参数。 结构:在整个LVM结构当中以此分为:“物理卷、物理卷分区、卷组、逻辑卷”,下面我详细解释一下这四种结构:

物理卷:Physical Volume,简称PV,一个物理卷只不过是一个有LVM管理数据添加在里面的物理存储介质。要使用LVM系统,首先对要用于LVM的磁盘进行初始化,初始化的目的就是将磁盘或分区标识为LVM 的物理卷。使用pvcreate 命令可以将一个磁盘标记为 LVM 物理卷。 物理分区:Physical Extents,简称PE,LVM将每个物理卷分别叫做物理分区的可寻址存储单元,存储单元的大小通常为几MB。磁盘的开头部分为LVM元数据,之后从索引为零开始,每个物理分区的索引依次递增一,按顺序进行分配。 卷组:Volume Group,简称VG,物理卷可以组织为卷组。卷组可以由一个或多个物理卷组成,同时系统中可以有多个卷组。创建了卷组之后,该卷组(而不是磁盘)便是表示数据存储的实体。因此,尽管以前是将磁盘从一个系统移动到另一个系统,使用了 LVM 之后,会将卷组从一个系统移动到另一个系统。出于这种原因,通常在一个系统上创建多个卷组会比较方便。 逻辑分区:Logical Extents,简称LE,逻辑卷的基本分配单元称为逻辑分区。逻辑分区映射到物理分区,因此,如果物理分区的尺寸小为4MB,那么逻辑分区的尺寸也将为4MB。逻辑卷的大小取决于所分配的逻辑分区数量。

二、实际操作

场景:扩展虚拟机已有磁盘空间。

[root@localhost ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core) 1.vmware为虚拟机增加存储空间

扩展前

[root@localhost ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/centos-root xfs 47G 2.0G 45G 5% / devtmpfs devtmpfs 903M 0 903M 0% /dev tmpfs tmpfs 915M 0 915M 0% /dev/shm tmpfs tmpfs 915M 9.4M 906M 2% /run tmpfs tmpfs 915M 0 915M 0% /sys/fs/cgroup /dev/sda1 xfs 1014M 146M 869M 15% /boot tmpfs tmpfs 183M 0 183M 0% /run/user/0 [root@localhost ~]# fdisk -l Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000ad192 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 104857599 51379200 8e Linux LVM Disk /dev/mapper/centos-root: 50.5 GB, 50457477120 bytes, 98549760 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 /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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 扩展操作

关闭虚拟机-设置-硬盘(SCSI)-扩展即可!

扩展后(增加10G) 注意:fdisk -l 执行结果,空间增加约10G,但此时df -hT看不出变化。

[root@localhost ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/mapper/centos-root xfs 47G 2.1G 45G 5% / devtmpfs devtmpfs 903M 0 903M 0% /dev tmpfs tmpfs 915M 0 915M 0% /dev/shm tmpfs tmpfs 915M 9.3M 906M 2% /run tmpfs tmpfs 915M 0 915M 0% /sys/fs/cgroup /dev/sda1 xfs 1014M 146M 869M 15% /boot tmpfs tmpfs 183M 0 183M 0% /run/user/0 [root@localhost ~]# fdisk -l Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 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: 0x000ad192 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 104857599 51379200 8e Linux LVM Disk /dev/mapper/centos-root: 50.5 GB, 50457477120 bytes, 98549760 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 /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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 2.创建分区

说明: m-帮助 n-新建分区 t-修改分区类型(与原先保持一致,都是8e,代表Linux LVM) w-保存 q-退出

[root@localhost ~]# fdisk /dev/sda 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): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition g create a new empty GPT partition table G create an IRIX (SGI) partition table l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only) Command (m for help): p Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 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: 0x000ad192 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 104857599 51379200 8e Linux LVM Command (m for help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): Using default response p Partition number (3,4, default 3): First sector (104857600-125829119, default 104857600): Using default value 104857600 Last sector, +sectors or +size{K,M,G} (104857600-125829119, default 125829119): Using default value 125829119 Partition 3 of type Linux and of size 10 GiB is set Command (m for help): p Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 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: 0x000ad192 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 104857599 51379200 8e Linux LVM /dev/sda3 104857600 125829119 10485760 83 Linux Command (m for help): t Partition number (1-3, default 3): 3 Hex code (type L to list all codes): L 0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris 1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT- 4 FAT16


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3