700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > VMware内CentOS7虚拟机硬盘扩容

VMware内CentOS7虚拟机硬盘扩容

时间:2023-06-28 23:45:11

相关推荐

VMware内CentOS7虚拟机硬盘扩容

简介

CentOS7虚拟机原硬盘空间只分配了10GB,需要扩容到20GB。

环境:VMware 10

VMware分配空间

选中虚拟机->虚拟机设置->硬盘->实用工具->扩展->设置最大磁盘大小->点击扩展

CentOS7内部分配

可以参考:/article/54b6b9c0fc8b0b2d583b47c6.html

查看当前磁盘空间,/dev/mapper/cl-root硬盘空间只有8GB,打算扩容:

# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/cl-root 8.0G 3.8G 4.3G 47% /devtmpfs 482M0 482M 0% /devtmpfs493M0 493M 0% /dev/shmtmpfs493M 6.7M 486M 2% /runtmpfs493M0 493M 0% /sys/fs/cgroup/dev/sda1 1014M 184M 831M 19% /boottmpfs 99M0 99M 0% /run/user/0

对新增的硬盘空间做新增分区(硬盘数没有增加,增加的是空间)

# fdisk /dev/sdaWelcome 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 mand (m for help): nPartition type:p primary (2 primary, 0 extended, 2 free)e extendedSelect (default p): pPartition number (3,4, default 3): 3First sector (20971520-41943039, default 20971520): Using default value 20971520Last sector, +sectors or +size{K,M,G} (20971520-41943039, default 41943039): Using default value 41943039Partition 3 of type Linux and of size 10 GiB is setCommand (m for help): tPartition number (1-3, default 3): 3Hex code (type L to list all codes): 8eChanged type of partition 'Linux' to 'Linux LVM'Command (m for help): pDisk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 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: 0x000bc924Device BootStart EndBlocks Id System/dev/sda1 * 204820991991048576 83 Linux/dev/sda2 2099200 209715199436160 8e Linux LVM/dev/sda3 20971520 41943039 10485760 8e Linux LVMCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.WARNING: Re-reading the partition table failed with error 16: Device or resource busy.The kernel still uses the old table. The new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)Syncing disks.

重启系统 reboot查看当前分区类型,本例类型为xfs

# df -T /dev/sda1FilesystemType 1K-blocks Used Available Use% Mounted on/dev/sda1xfs 1038336 188240 850096 19% /boot

在新磁盘上创建xfs文件系统

# mkfs.xfs /dev/sda3meta-data=/dev/sda3 isize=512 agcount=4, agsize=655360 blks= sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0data= bsize=4096 blocks=2621440, imaxpct=25= sunit=0swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype=1log=internal log bsize=4096 blocks=2560, version=2= sectsz=512 sunit=0 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0

创建PV

# pvcreate /dev/sda3WARNING: xfs signature detected on /dev/sda3 at offset 0. Wipe it? [y/n]: yWiping xfs signature on /dev/sda3.Physical volume "/dev/sda3" successfully created.# pvdisplay--- Physical volume ---PV Name/dev/sda2VG NameclPV Size9.00 GiB / not usable 3.00 MiBAllocatable yes (but full)PE Size4.00 MiBTotal PE 2303Free PE0Allocated PE2303PV UUIDMlRwjY-TmVF-H8PV-heSz-ALGL-Q7sp-jFU6Al"/dev/sda3" is a new physical volume of "10.00 GiB"--- NEW Physical volume ---PV Name/dev/sda3VG NamePV Size10.00 GiBAllocatable NOPE Size0 Total PE 0Free PE0Allocated PE0PV UUID0hmgH0-0wVg-jWUW-65WX-1TYb-sUGH-6jF1qm

PV加入VG,vgextend后接VG Name,本例中为cl

# vgdisplay--- Volume group ---VG NameclSystem ID Formatlvm2Metadata Areas 1Metadata Sequence No 3VG Access read/writeVG Status resizableMAX LV0Cur LV2Open LV2Max PV0Cur PV1Act PV1VG Size9.00 GiBPE Size4.00 MiBTotal PE 2303Alloc PE / Size 2303 / 9.00 GiBFree PE / Size 0 / 0 VG UUIDdYdb4l-wMUh-e2xv-WiaJ-Oa52-NvdF-s5ICJC# vgextend cl /dev/sda3

VG加入LV

# lvextend -l +2559 /dev/cl/rootSize of logical volume cl/root changed from 8.00 GiB (2047 extents) to 17.99 GiB (4606 extents).Logical volume cl/root successfully resized.

后两个参数“+2559”和“/dev/cl/root”来源详解:

“+2559”来自于vgdisplay命令的Free PE/Size字段

# vgdisplay--- Volume group ---VG Namecl...VG Size18.99 GiBPE Size4.00 MiBTotal PE 4862Alloc PE / Size 2303 / 9.00 GiBFree PE / Size 2559 / 10.00 GiBVG UUIDdYdb4l-wMUh-e2xv-WiaJ-Oa52-NvdF-s5ICJC

“/dev/cl/root”来自于lvdisplay命令的LV Path字段。

# lvdisplay...--- Logical volume ---LV Path/dev/cl/root...

调整文件系统大小,本例中是xfs文件系统使用xfs_growfs命令调整,若其他文件系统,如ext4使用resize2fs命令,注意区分。

# xfs_growfs /dev/cl/rootmeta-data=/dev/mapper/cl-root isize=512 agcount=4, agsize=524032 blks= sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0data= bsize=4096 blocks=2096128, imaxpct=25= sunit=0swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype=1log=internalbsize=4096 blocks=2560, version=2= sectsz=512 sunit=0 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0data blocks changed from 2096128 to 4716544

结果

/dev/mapper/cl-root从8G增加到了18G

# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/cl-root 18G 3.8G 15G 21% /devtmpfs 482M0 482M 0% /devtmpfs493M0 493M 0% /dev/shmtmpfs493M 6.7M 486M 2% /runtmpfs493M0 493M 0% /sys/fs/cgroup/dev/sda1 1014M 184M 831M 19% /boottmpfs 99M0 99M 0% /run/user/0

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