Back

linux - 给aliyun服务器的硬盘做扩容

发布时间: 2019-05-21 03:12:00

参考:https://help.aliyun.com/document_detail/111738.html?spm=a2c4g.11186623.4.6.14a4464cfdZyIM

步骤:
1. apt install cloud-guest-utils
2. fdisk -l  
这个是为了确认磁盘的可用空间是否变大(需要在控制台为磁盘扩容之后,在控制台中重启服务器) ,结果如下:

Disk /dev/vda: 60 GiB, 64424509440 bytes, 125829120 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
Disklabel type: dos
Disk identifier: 0x5b0a964e

Device     Boot Start      End  Sectors Size Id Type
/dev/vda1  *     2048 83886046 83883999  40G 83 Linux

从上面可以看出,   /dev/vda 是60G了。(原来是40G)

3. df -kh
这个是为了查看硬盘的目录的大小。结果如下:(可以看到还没生效)

Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           799M  3.1M  796M   1% /run
/dev/vda1        40G   35G  3.1G  92% /
tmpfs           3.9G  4.0K  3.9G   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs           799M     0  799M   0% /run/user/0

4. 运行 growpart /dev/vda 1

上面命令是直接为某硬盘扩容,  需要注意的是,我们为了给 /dev/vda1 扩容,上面的命令是 .../dev/vda 空格 1

CHANGED: partition=1 start=2048 old: size=83883999 end=83886047 new: size=125827039,end=125829087

5. 运行 resize2fs 命令:

root@test-server:/opt/app/test1.sss.com# resize2fs /dev/vda1 
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 4
The filesystem on /dev/vda1 is now 15728379 (4k) blocks long.

就可以了。
6. df -kh 就可以看到现在,硬盘变大了。 

Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G     0  3.9G   0% /dev
tmpfs           799M  3.1M  796M   1% /run
/dev/vda1        59G   35G   22G  62% /

Back