1000字范文,内容丰富有趣,学习的好帮手!
1000字范文 > VMWare虚拟机扩展磁盘空间(扩充root根目录空间)

VMWare虚拟机扩展磁盘空间(扩充root根目录空间)

时间:2021-11-18 02:18:28

相关推荐

VMWare虚拟机扩展磁盘空间(扩充root根目录空间)

1. 扩展虚拟机磁盘空间

Vm虚拟机下Linux扩展原有磁盘空间,10G

10G的基础上不能满足需求,只好进行磁盘扩展。

调整到合适的磁盘空间

需注意以下几点: linux只能扩展磁盘容量而不能减小, 所填写的容量为总容量,即包含已分区的磁盘。

2.查看、创建系统分区

启动虚假机,查看磁盘分区

[root@node1 ~]# fdisk -l

总磁盘大小32.2GB,其中磁盘分了sda1,sda2两个分区。Linux LVM为虚拟机分区约有9GB磁盘空间。

创建新分区

[root@node1 ~]# fdisk /dev/sda#输入m查看帮助文档Command (m for help): mCommand actiona toggle a bootable flagb edit bsd disklabelc toggle the dos compatibility flagd delete a partitiong create a new empty GPT partition tableG create an IRIX (SGI) partition tablel list known partition typesm print this menun add a new partition #创建新分区o create a new empty DOS partition tablep print the partition tableq quit without saving changess create a new empty Sun disklabelt change a partition's system idu change display/entry unitsv verify the partition tablew write table to disk and exitx extra functionality (experts only)

3.执行分区创建

Command (m for help): nPartition type:p primary (2 primary, 0 extended, 2 free) #创建主分区e extended #创建扩展分区Select (default p): pPartition number (3,4, default 3): #由前面已有2个分区,所有从3开始First sector (20971520-62914559, default 20971520): #一路回车即可Using default value 20971520Last sector, +sectors or +size{K,M,G} (20971520-62914559, default 62914559): Using default value 62914559Partition 3 of type Linux and of size 20 GiB is setCommand (m for help): w #保存退出The partition table has been altered!

4.重新查看分区

我们的新建分区/dev/sda3

[root@node1 ~]# fdisk -lDisk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x00009cb6Device BootStart EndBlocks Id System/dev/sda1 * 204820991991048576 83 Linux/dev/sda2 2099200 209715199436160 8e Linux LVM#sda3为新创建的分区/dev/sda3 20971520 62914559 20971520 83 LinuxDisk /dev/mapper/centos-root: 8585 MB, 8585740288 bytes, 16769024 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/centos-swap: 1073 MB, 1073741824 bytes, 2097152 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes

4.查看文件系统格式、分区格式化

#查看文件系统格式df -T -h#分区格式化mkfs.xfs /dev/sda3 #格式化为xfs格式

#进入lvm管理lvmlvm> pvcreate /dev/sda3 #这是初始化刚才的分区3WARNING: ext4 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: yWiping ext4 signature on /dev/sda3.Physical volume "/dev/sda3" successfully created.lvm> vgdisplay -v #卷和卷组的命令可以通过 vgdisplay查看--- Volume group ---VG NamecentosSystem ID Formatlvm2Metadata Areas 1Metadata Sequence No 3VG Access read/writeVG Status resizableMAX LV0Cur LV2Open LV2Max PV0Cur PV1Act PV1VG Size<9.00 GiBPE Size4.00 MiBTotal PE 2303Alloc PE / Size 2303 / <9.00 GiBFree PE / Size 0 / 0 VG UUIDzy2221-18Zz-hNix-Xa40-fn2S-ymfs-QfifRi--- Logical volume ---LV Path/dev/centos/swapLV NameswapVG NamecentosLV UUIDypW1dW-fdTc-qCso-7Wck-L1gH-hsOp-v4ZBeyLV Write Access read/writeLV Creation host, time localhost, -06-25 13:10:00 +0800LV Status available# open 2LV Size1.00 GiBCurrent LE 256Segments1Allocation inheritRead ahead sectorsauto- currently set to8192Block device 253:1--- Logical volume ---LV Path/dev/centos/rootLV NamerootVG NamecentosLV UUID2IDcZo-HeDY-VzTg-FIAP-YhvQ-qU0K-cxyuBrLV Write Access read/writeLV Creation host, time localhost, -06-25 13:10:00 +0800LV Status available# open 1LV Size<8.00 GiBCurrent LE 2047Segments1Allocation inheritRead ahead sectorsauto- currently set to8192Block device 253:0--- Physical volumes ---PV Name/dev/sda2PV UUIDkb7rhp-Lcow-6z3W-RBYx-fJxo-pHUc-cLxYTNPV Status allocatableTotal PE / Free PE 2303 / 0lvm> vgextend centos /dev/sda3 #将初始化过的分区加入到虚拟卷组centosVolume group "centos" successfully extended

可以查看到新加入的物理卷sda3

通过vgdisplay再次查看,可以发现Volume group中多了Free PE / Size 5119 / <20.00 GiB一行记录

lvm> vgdisplay -v--- Volume group ---VG NamecentosSystem ID Formatlvm2Metadata Areas 2Metadata Sequence No 4VG Access read/writeVG Status resizableMAX LV0Cur LV2Open LV2Max PV0Cur PV2Act PV2VG Size28.99 GiBPE Size4.00 MiBTotal PE 7422Alloc PE / Size 2303 / <9.00 GiBFree PE / Size 5119 / <20.00 GiBVG UUIDzy2221-18Zz-hNix-Xa40-fn2S-ymfs-QfifRi--- Logical volume ---LV Path/dev/centos/swapLV NameswapVG NamecentosLV UUIDypW1dW-fdTc-qCso-7Wck-L1gH-hsOp-v4ZBeyLV Write Access read/writeLV Creation host, time localhost, -06-25 13:10:00 +0800LV Status available# open 2LV Size1.00 GiBCurrent LE 256Segments1Allocation inheritRead ahead sectorsauto- currently set to8192Block device 253:1--- Logical volume ---LV Path/dev/centos/rootLV NamerootVG NamecentosLV UUID2IDcZo-HeDY-VzTg-FIAP-YhvQ-qU0K-cxyuBrLV Write Access read/writeLV Creation host, time localhost, -06-25 13:10:00 +0800LV Status available# open 1LV Size<8.00 GiBCurrent LE 2047Segments1Allocation inheritRead ahead sectorsauto- currently set to8192Block device 253:0--- Physical volumes ---PV Name/dev/sda2PV UUIDkb7rhp-Lcow-6z3W-RBYx-fJxo-pHUc-cLxYTNPV Status allocatableTotal PE / Free PE 2303 / 0PV Name/dev/sda3PV UUIDV708hY-OO5p-IH3v-ZRlU-Torj-tXOC-ERvLr1PV Status allocatableTotal PE / Free PE 5119 / 5119#/dev/mapper/centos-root 为根路径挂载点lvm> lvextend -l+5119 /dev/mapper/centos-root ##扩展已有卷的容量(5119 是通过vgdisplay查看Free PE / Size的大小)Size of logical volume centos/root changed from <8.00 GiB (2047 extents) to 27.99 GiB (7166 extents).Logical volume centos/root successfully resized.lvm> pvdisplay--- Physical volume ---PV Name/dev/sda2VG NamecentosPV Size<9.00 GiB / not usable 3.00 MiBAllocatable yes (but full)PE Size4.00 MiBTotal PE 2303Free PE0Allocated PE2303PV UUIDkb7rhp-Lcow-6z3W-RBYx-fJxo-pHUc-cLxYTN--- Physical volume ---PV Name/dev/sda3VG NamecentosPV Size20.00 GiB / not usable 4.00 MiBAllocatable yes (but full)PE Size4.00 MiBTotal PE 5119Free PE0Allocated PE5119PV UUIDV708hY-OO5p-IH3v-ZRlU-Torj-tXOC-ERvLr1lvm>quit #退出

3.文件系统的扩容

以上只是做成了卷扩容,接下来做文件系统的真正扩容

#执行df -h时根目录的挂载点df -h

centos7执行执行扩容

xfs_growfs /dev/mapper/centos-root

再次查看磁盘使用情况

df -h

可以看见根目录下的磁盘空间已经扩展为28G了

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。