如何在Hicloud CentOS7擴充某磁區

原本Hicloud系統硬碟為30GB,在網頁將其擴充至60GB後如下面所示

[root@xxx ~]# fdisk -l
Disk /dev/sda: 64.4 GB, 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
Disk label type: dos
Disk identifier: 0x00000000
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1    62914559    31457279+  ee  GPT

但用df -h查看/dev/sda3卻沒有變化還是27GB,這邊總容量還是30Gb

[root@xxx ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        4.3G     0  4.3G   0% /dev
tmpfs           4.4G     0  4.4G   0% /dev/shm
tmpfs           4.4G   12M  4.3G   1% /run
tmpfs           4.4G     0  4.4G   0% /sys/fs/cgroup
/dev/sda3        27G   16G   11G  60% /
/dev/sda1       512M   12M  501M   3% /boot/efi
tmpfs           882M     0  882M   0% /run/user/0

因此用lsblk查看如下,sda已經為60Gb但sda3為27.5G,沒吃到剩於空間

[root@xxx ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   60G  0 disk
├─sda1   8:1    0  512M  0 part /boot/efi
├─sda2   8:2    0    2G  0 part [SWAP]
└─sda3   8:3    0 27.5G  0 part /
sr0     11:0    1 1024M  0 rom

工具growpart將sda裡的sda3擴充剩下的空間

[root@xxx ~]# growpart /dev/sda 3
CHANGED: partition=3 start=5244928 old: size=57667584 end=62912512 new: size=12
[root@xxx ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0   60G  0 disk
├─sda1   8:1    0  512M  0 part /boot/efi
├─sda2   8:2    0    2G  0 part [SWAP]
└─sda3   8:3    0 57.5G  0 part /
sr0     11:0    1 1024M  0 rom

sda裡的sda3空間已為57.5Gb,並用df -h查看/dev/sda3,但還是為27Gb

[root@xxx ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        4.3G     0  4.3G   0% /dev
tmpfs           4.4G     0  4.4G   0% /dev/shm
tmpfs           4.4G   12M  4.3G   1% /run
tmpfs           4.4G     0  4.4G   0% /sys/fs/cgroup
/dev/sda3        27G   16G   11G  60% /
/dev/sda1       512M   12M  501M   3% /boot/efi
tmpfs           882M     0  882M   0% /run/user/0

最後需要在用一個工具resize2fs,來自動分配空間給/dev/sda3

[root@xxx ~]# resize2fs /dev/sda3
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/sda3 is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 8
The filesystem on /dev/sda3 is now 15073019 blocks long.
[root@xxx ~]# df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
devtmpfs       devtmpfs  4.3G     0  4.3G   0% /dev
tmpfs          tmpfs     4.4G     0  4.4G   0% /dev/shm
tmpfs          tmpfs     4.4G   12M  4.3G   1% /run
tmpfs          tmpfs     4.4G     0  4.4G   0% /sys/fs/cgroup
/dev/sda3      ext4       57G   16G   39G  29% /
/dev/sda1      vfat      512M   12M  501M   3% /boot/efi
tmpfs          tmpfs     882M     0  882M   0% /run/user/0

Leave a Comment

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *