linux根目录扩容方法,Linux系统扩容根目录磁盘空间的操作方法

问题描述

系统的服务无法正常运行,查看磁盘空间,发现根目录已经满了

4d2330710e7b32a67815098eec367bab.png

解决过程

1.添加磁盘空间

2.使用fdisk -l命令查看磁盘信息

3.新建磁盘分区

4.使用fdisk /dev/sda3, 创建新分区。

按照下面Linux操作进行分区。

root@ubuntu14:/opt# fdisk /dev/sda3

命令(输入 m 获取帮助): m

命令操作

a toggle a bootable flag

b edit bsd disklabel

c toggle the dos compatibility flag

d delete a partition

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)

命令(输入 m 获取帮助): n #new 新分区

Partition type:

p primary (1 primary, 1 extended, 2 free)

l logical (numbered from 5)

Select (default p): p #选择主分区

分区号 (1-4,默认为 3): 3 #分区序号

起始 sector (499712-314572799,默认为 499712): #分区开始回车默认

将使用默认值 499712

Last sector, +扇区 or +size{K,M,G} (499712-501757,默认为 501757):

将使用默认值 501757

命令(输入 m 获取帮助): n #new 新分区

Partition type:

p primary (2 primary, 1 extended, 1 free)

l logical (numbered from 5)

Select (default p): p #选择主分区

Selected partition 4 #分区序号

起始 sector (62912512-314572799,默认为 62912512): #分区开始回车默认

将使用默认值 62912512

Last sector, +扇区 or +size{K,M,G} (62912512-314572799,默认为 314572799):

将使用默认值 314572799

命令(输入 m 获取帮助): t #修改分区格式

分区号 (1-5): 4 #修改分区号

Hex code (type L to list codes): 8e #格式选择8e linux LVM

Changed system type of partition 4 to 8e (Linux LVM)

命令(输入 m 获取帮助): p #显示分区信息

Disk /dev/vda: 161.1 GB, 161061273600 bytes

16 heads, 63 sectors/track, 312076 cylinders, total 314572800 sectors

Units = 扇区 of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0001a023

设备 启动 起点 终点 块数 Id 系统

/dev/vda1 * 2048 499711 248832 83 Linux

/dev/vda2 501758 62912511 31205377 5 扩展

/dev/vda3 499712 501757 1023 83 Linux

/dev/vda4 62912512 314572799 125830144 8e Linux LVM

/dev/vda5 501760 62912511 31205376 8e Linux LVM

Partition table entries are not in disk order

命令(输入 m 获取帮助): w #保存信息

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.

The kernel still uses the old table. The new table will be used at

the next reboot or after you run partprobe(8) or kpartx(8)

Syncing disks.

db9b6c875c7b51a57dddfee9fb1ee480.png

5.重启Linux操作系统,使用reboot命令。

6.创建物理卷,使用pvcreate /dev/sda3命令。

fc68fc679d5ba653a3e1b41fb89c9699.png

7.将添加新的物理卷,加载到centos卷组,使用vgextend centos /dev/sda3命令。

eae001ad3cbc9c32151eedad3c7d52d8.png

8.增加/dev/mapper/centos-root大小,增加50G。使用lvresize -L +50G /dev/mapper/centos-root命令。

c1ca6b2636c2de7359461cc42dd4859f.png

9.同步文件系统。

ad0e28215c6987cefdfaaf0b6ad863ea.png

10.查看扩容后的大小 ,使用df -h命令。

e75fef99c8785226773a1a46b6a1415e.png

参考:

  • 2
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值