linux数据盘分区,百度云磁盘CDS Linux数据盘扩展分区

百度云磁盘CDS Linux数据盘扩展分区

随着Web业务的持续增加,原先400G的Web服务器数据磁盘已经不能满足使用,为满足Web业务的需要,决定扩容数据磁盘到1000G。

在百度云磁盘CDS扩容只是将磁盘的存储容量扩大,不会扩展分区和文件系统。

ee5745066b833f0b888dcc5f26fb7874.png

实战记录百度云磁盘CDS Linux数据盘扩展分区,Web 服务器为CentOS release 6.10 (Final)系统,数据磁盘的格式为EXT4。

1、查看Web服务器数据磁盘挂载信息

#mount | grep "/dev/vdb"

/dev/vdb1 on /data type ext4 (rw)

2、查看是否有程序在Web服务器数据磁盘正在运行

fuser -m /dev/vdb1

/dev/vdb1: 5115

如果有的话,查找并结束掉进程

ps aux | grep 5115

#ps aux | grep 5115

apache 5115 0.2 0.1 449060 29048 ? S 10:56 0:03 /usr/sbin/httpd

3、关闭正在使用Web服务器数据磁盘的服务或者进程

service httpd stop 或者 kill -9 5115

4、编辑fstab,取消Web服务器数据磁盘自动挂载

vi /etc/fstab

#/dev/vdb1 /data ext4 defaults 0 0

5、卸载Web服务器数据磁盘

#umount /dev/vdb1

#umount /dev/vdb1 如果有程序正在运行,则会这样提示

umount: /data: target is busy.

(In some cases useful info about processes that use

the device is found by lsof(8) or fuser(1))

取消正在运行的程序 比如webserver mysql

6、调整分区大小

(1)查看分区表

fdisk /dev/vdb

p print the partition table

p

Command (m for help): p

Disk /dev/vdb: 1073.7 GB, 1073741824000 bytes

16 heads, 63 sectors/track, 2080507 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

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

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

Disk identifier: 0x2c594bf0

Device Boot Start End Blocks Id System

/dev/vdb1 1 2080507 1048575496+ 83 Linux

(2) 删除当前分区。当屏幕显示"已选择分区 1

d delete a partition

d

(3)新建分区

n add a new partition

n

(4)保存修改并退出

w write table to disk and exit

w

The partition table has been altered!

----------------------------

如果fstab有自动挂载则会出现这样的提示,需要提前执行第4步。

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 at

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

Syncing disks.

---------------------------

8、执行命令 lsblk /dev/vdb 查看当前文件系统是否已增加分区表

lsblk /dev/vdb

#lsblk /dev/vdb

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

vdb 252:16 0 1000G 0 disk

└─vdb1 252:17 0 1000G 0 part /data

9、执行命令 e2fsck -n /dev/vdb1 查看当前文件系统的状态是否为 clean

e2fsck -n /dev/vdb1

如果有异常则会提示

/dev/vdb1 contains a file system with errors, check forced.

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/vdb1: 5641753/26214400 files (2.5% non-contiguous), 97404495/104857570 blocks

修复

fsck.ext4 -C0 /dev/vdb1

10、通知内核更新分区表 通知内核需同步数据盘的分区表信息。

yum -y install parted

partprobe /dev/vdb

11、完成文件系统扩展

resize2fs /dev/vdb1

resize2fs 1.41.12 (17-May-2010)

Resizing the filesystem on /dev/vdb1 to 262142637 (4k) blocks.

The filesystem on /dev/vdb1 is now 262142637 blocks long.

Web服务器数据磁盘采用 ext4 文件系统,可以执行 resize2fs /dev/vdb1 命令以扩展文件系统大小。

对于 xfs 文件系统,需要先运行 mount /dev/vdb1 /data/ 命令,再运行xfs_growfs /dev/vdb1 以完成文件系统拓展。

12、编辑fstab,启用Web服务器数据磁盘自动挂载

vi /etc/fstab

/dev/vdb1 /data ext4 defaults 0 0

13、挂载全部

mount -a

14、确认文件系统扩展完毕

df -hT

Filesystem Type Size Used Avail Use% Mounted on

/dev/vda1 ext4 20G 8.3G 11G 45% /

tmpfs tmpfs 12G 0 12G 0% /dev/shm

/dev/vdb1 ext4 985G 366G 569G 40% /data

/dev/vdc1 ext4 394G 270G 105G 73% /backup

ded6dc55ceb0ad6c45309f55b96fbd6e.png

---------------------------

https://cloud.baidu.com/doc/CDS/s/Lk0629a17

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值