恒美微站
首页
关于我们
建站服务
主题模板
案例展示
资讯中心
联系我们
虚拟机分配硬盘
首页
资讯中心
/
虚拟机分配硬盘
虚拟机分配硬盘
发布时间:2026/8/4 14:36:09
先在虚拟机增加硬盘。分配新加的硬盘[rootlocalhost ~]# fdisk /dev/sdaWelcome to fdisk (util-linux 2.23.2).Command (m for help): p ← 你输入 pDevice Boot Start End Blocks Id System/dev/sda1 * 2048 2099199 1048576 83 Linux/dev/sda2 2099200 33554431 15727616 8e Linux LVMCommand (m for help): d ← 你输入 dPartition number (1,2, default 2): 2 ← 你输入 2Partition 2 is deletedCommand (m for help): n ← 你输入 nPartition type:p primary (1 primary, 0 extended, 3 free)e extendedSelect (default p): p ← 你输入 pPartition number (1-4, default 2): 2 ← 你输入 2First sector (2048-167772159, default 2048): 2099200 ← 你输入起始扇区你之前记下的数字Last sector, sectors or size{K,M,G} (2099200-167772159, default 167772159): ← 直接回车Command (m for help): t ← 你输入 tPartition number (1,2, default 2): 2 ← 你输入 2Hex code (type L to list all codes): 8e ← 你输入 8eChanged type of partition Linux to Linux LVMCommand (m for help): w ← 你输入 wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.识别挂在硬盘[rootlocalhost ~]# pvresize /dev/sda2Physical volume /dev/sda2 changed1 physical volume(s) resized / 0 physical volume(s) not resized[rootlocalhost ~]# pvdisplay--- Physical volume ---PV Name /dev/sda2VG Name centosPV Size 80.00 GiB / not usable 2.00 MiBAllocatable yesPE Size 4.00 MiBTotal PE 20479Free PE 16640Allocated PE 3839PV UUID vHeZCZ-Gxfs-wb1z-Wejc-6hBo-BStr-EvbOHd[rootlocalhost ~]# lvextend -l 100%FREE /dev/centos/rootSize of logical volume centos/root changed from 13.39 GiB (3429 extents) to 79.99 GiB (20479 extents).Logical volume centos/root successfully resized.[rootlocalhost ~]# xfs_growfs /meta-data/dev/mapper/centos-root isize512 agcount4, agsize877824 blks sectsz512 attr2, projid32bit1 crc1 finobt0 spinodes0data bsize4096 blocks3511296, imaxpct25 sunit0 swidth0 blksnaming version 2 bsize4096 ascii-ci0 ftype1log internal bsize4096 blocks2560, version2 sectsz512 sunit0 blks, lazy-count1realtime none extsz4096 blocks0, rtextents0data blocks changed from 3511296 to 20970496[rootlocalhost ~]# df -h /文件系统 容量 已用 可用 已用% 挂载点/dev/mapper/centos-root 80G 5.0G 75G 7% /