linux服务器磁盘空间如何扩充
发表于:2026-11-04 作者:千家信息网编辑
千家信息网最后更新 2026年11月04日,这篇文章主要介绍linux服务器磁盘空间如何扩充,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!步骤磁盘原来已经有两个分区了,但是分配的空间都不大。增加磁盘,通过管理端挂载新的磁
千家信息网最后更新 2026年11月04日linux服务器磁盘空间如何扩充
这篇文章主要介绍linux服务器磁盘空间如何扩充,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
步骤
磁盘原来已经有两个分区了,但是分配的空间都不大。
增加磁盘,通过管理端挂载新的磁盘sdc;
使用fdisk /dev/sdc,创建新分区;
[root@localhost indices]# fdisk /dev/sdcDevice contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0x5799aeba.Changes will remain in memory only, until you decide to write them.After that, of course, the previous content won't be recoverable.Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)WARNING: The size of this disk is 2.2 TB (2199023255552 bytes).DOS partition table format can not be used on drives for volumeslarger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID partition table format (GPT).WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u').Command (m for help): n #new 新分区Command action e extended p primary partition (1-4)p #选择主扇区Partition number (1-4): 1 #起始扇区First cylinder (1-267349, default 1): #这里直接回车表示取默认值1Using default value 1Last cylinder, +cylinders or +size{K,M,G} (1-267349, default 267349): #这里由于es需要的存储空间比较大,所以2个T的空间我都加上了,正常可以按照需求修改扇区大小Using default value 267349Command (m for help): w #保存退出The partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.然后创建物理卷,使用pvcreate /dev/sdc1命令;注意:这里很多文章里要求重启系统,这里其实可以不用重启,可直接操作,不影响服务器的正常运行;
[root@localhost indices]# pvcreate /dev/sdc1 Physical volume "/dev/sdc1" successfully created
使用vgscan查看 物理卷组 名称;
[root@localhost indices]# vgscan Reading all physical volumes. This may take a while... Found volume group "VolGroup" using metadata type lvm2 #这里物理卷组名称为VolGroup
将刚才增加的物理扇区加载到卷组中,这里使用 vgextend VolGroup /dev/sdc1;
[root@localhost indices]# vgextend VolGroup /dev/sdc1 Volume group "VolGroup" successfully extended
增加卷组的大小,这里使用lvextend -L +2048G /dev/mapper/VolGroup-lv_root;
[root@localhost indices]# lvextend -L +2048G /dev/mapper/VolGroup-lv_root Size of logical volume VolGroup/lv_root changed from 135.47 GiB (34681 extents) to 2.13 TiB (558848 extents). Logical volume lv_root successfully resized.
使用df -h查看空间扩充情况,发现空间并未扩充,这是因为文件系统还未同步;
[root@localhost indices]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 134G 119G 8.4G 94% /tmpfs 32G 72K 32G 1% /dev/shm/dev/sda1 477M 41M 411M 10% /boot
同步文件系统,使用xfs_growfs或者resize2fs同步文件系统,如下操作;
[root@localhost indices]# resize2fs -f /dev/mapper/VolGroup-lv_rootresize2fs 1.41.12 (17-May-2010)Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing requiredold desc_blocks = 9, new_desc_blocks = 137Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 572260352 (4k) blocks.The filesystem on /dev/mapper/VolGroup-lv_root is now 572260352 blocks long.
再使用df -h 查看空间扩容情况
[root@localhost indices]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 2.1T 125G 1.9T 7% /tmpfs 32G 72K 32G 1% /dev/shm/dev/sda1 477M 41M 411M 10% /boot
由于CentOS6和CentOS7在默认根文件系统的文件系统格式存在差异,需要判断是否为xfs,如果是xfs则应该使用xfs_growfs而不是一味的使用resize2fs。
以上是"linux服务器磁盘空间如何扩充"这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!
空间
系统
磁盘
文件
物理
服务器
服务
同步
内容
名称
大小
情况
篇文章
一味
不大
不用
两个
价值
兴趣
命令
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
广州万易互联网科技有限公司
西安纸贵互联网科技有限公司
为想互联网科技怎么样
互联网和科技技术
互联网科技财经
青岛互联网科技公司
互联网科技ppt模板
润盈互联网科技
兼蜜互联网科技
火传媒上海互联网科技
成都狮子座互联网科技
成都仁贤领冠互联网科技有限公司
科技与互联网哪个更好
互联网科技如何创业
伍佰万互联网科技怎么赚钱
江苏互联网智能科技软件
上海创道互联网络科技有限公司
广州燕处互联网科技有限公司
陕西九四连强互联网科技有限公司
利用互联网等科技手段
手冲咖啡和咖啡机区别
山东特亿宝互联网科技有限公司
科技赋能下的互联网金融
科技互联网政务服务
重庆互联网络科技
互联网高科技企业
农村开互联网科技讲堂
重庆威客帮互联网科技
呼和浩特新华互联网科技学院
互联网在线教育科技创业