阿里云 扩容数据盘_Linux

1.控制台扩容 重启服务器(一定要在控制台停机 然后启动,不能偷懒执行命令完成)
2.查看磁盘空间 df -hl
3.停止网站 nginx -s stop
4.创建快照
5.卸载分区 umount /dev/vdb1
  (如果出现 umount: /data: target is busy.)
  5.1 检查分区有哪个程序占用(然后kill pid) lsof /dev/vdb1
  5.2 如果没有安装lsof yum install lsof
  5.3 kill完进程后 重新执行 卸载分区 umount /dev/vdb1
6.查看磁盘空间,查看/dev/vdb1是否被成功卸载 df -hl
7.查看分区 fdisk -l
8.进入分区操作 fdisk /dev/vdb (这里没有错,这里是指的整个盘 vdb1 是其中的一个区)
9.依次输入:d n p 1 回车 回车 wq 并按回车键,开始分区(是否分区成功 观察 Partition 1 of type Linux and of size [分区后新容量] GiB is set )
10.再次卸载分区 umount /dev/vdb1
11.检查修复文件系统 e2fsck -f /dev/vdb1
12.变更文件系统大小 resize2fs /dev/vdb1
13.挂载分区 mount /dev/vdb1 /data
14.查看分区 df -h
15.重启服务器 shutdown -r now

[root@iZwz95wvlhb3mr6g0d69wqZ ~]# fdisk -l

Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x635e6c7d

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1            2048    83886079    41942016   83  Linux

Disk /dev/vdb: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x8f986be8

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048   209715199   104856576   83  Linux
[root@iZwz95wvlhb3mr6g0d69wqZ ~]# fdisk /dev/vdb
Welcome 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): d
Selected partition 1
Partition 1 is deleted

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-419430399, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399): 
Using default value 419430399
Partition 1 of type Linux and of size 200 GiB is set

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@iZwz95wvlhb3mr6g0d69wqZ ~]# umount /dev/vdb1
[root@iZwz95wvlhb3mr6g0d69wqZ ~]# e2fsck -f /dev/vdb1
e2fsck 1.42.9 (28-Dec-2013)
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: 1340418/6553600 files (31.5% non-contiguous), 21356900/26214144 blocks
[root@iZwz95wvlhb3mr6g0d69wqZ ~]# resize2fs /dev/vdb1
resize2fs 1.42.9 (28-Dec-2013)
Resizing the filesystem on /dev/vdb1 to 52428544 (4k) blocks.
The filesystem on /dev/vdb1 is now 52428544 blocks long.

[root@iZwz95wvlhb3mr6g0d69wqZ ~]# mount /dev/vdb1 /data
[root@iZwz95wvlhb3mr6g0d69wqZ ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G   17G   21G  46% /
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           3.9G  268K  3.9G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs           783M     0  783M   0% /run/user/0
/dev/vdb1       197G   80G  108G  43% /data

猜你喜欢

转载自www.cnblogs.com/yangtutu/p/10367843.html