Linux磁盘空间扩容
VMware虚拟机中配置
(1)进入虚拟机设置界面,选择扩展磁盘容量。
(2) 本次是在原来30G的基础上扩展为50G。
成功后发现提示,必须从客户机操作系统内部对磁盘重新进行分区和扩展文件系统,因此需要进入linux系统继续进行配置,这里配置是不会生效的。
Linux中设置
进入Linux系统,使用命令fdisk -l查看,发现实际大小为50G,但是系统已挂载的加起来是修改之前的30G。
(1) 可以看出sda3是根分区,下面按照博客提示,先删除sda3根分区,然后重新创建sda3根分区,具体参考注释。
[root@node03 ~]# 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 command.Command (m for help): mCommand 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): d ##删除分区Partition number (1-3, default 3): 3 ##临时先删除sda3分区Partition 3 is deletedCommand (m for help): n #添加一个新的分区Partition type: p primary (2 primary, 0 extended, 2 free) e extendedSelect (default p): p #添加主分区Partition number (3,4, default 3): 3 #指定分区号3,重新创建sda3分区First sector (17303552-104857599, default 17303552): #回车Using default value 17303552Last sector, +sectors or +size{K,M,G} (17303552-104857599, default 104857599): #回车Using default value 104857599Partition 3 of type Linux and of size 41.8 GiB is set #提示OKCommand (m for help): w #按w保存退出The partition table has been altered! #提示OK
(2)重启系统
重启当前系统,可以选择systemctl reboot或者init 6来执行。
(3)扩容文件系统
使用命令 xfs_growfs /dev/sda3
,可以看到成功扩展分区,根分区已扩容20G。
[root@node03 ~]# xfs_growfs /dev/sda3meta-data=/dev/sda3 isize=512 agcount=8, agsize=769984 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0data = bsize=4096 blocks=5701376, imaxpct=25 = sunit=0 swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype=1log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0data blocks changed from 5701376 to 10944256查看结果[root@node03 ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/sda3 42G 11G 32G 25% /devtmpfs 2.9G 0 2.9G 0% /devtmpfs 3.0G 0 3.0G 0% /dev/shmtmpfs 3.0G 13M 2.9G 1% /runtmpfs 3.0G 0 3.0G 0% /sys/fs/cgroup/dev/sda1 253M 153M 101M 61% /boottmpfs 595M 8.0K 595M 1% /run/user/990tmpfs 595M 0 595M 0% /run/user/0You have new mail in /var/spool/mail/root
扩容结果展示。
以上为参考博文执行的结果,且当前执行成功的系统为Centos7.6,根分区文件类型为xfs,并且系统不是LVM分区,可作为参考。
来源地址:https://blog.csdn.net/qq_37279783/article/details/130743162