久久青草精品A片狠狠,日韩欧美视频一区二区,亚洲国码AV日韩,国产精品黄在

幫助中心 >  技術知識庫 >  云服務器 >  服務器教程 >  GPT分區擴容——以ext4文件系統為例

GPT分區擴容——以ext4文件系統為例

2024-11-25 16:01:43 3897

GPT分區擴容——以ext4文件系統為例

歡迎來到藍隊云技術小課堂,每天分享一個技術小知識。今天主要介紹gpt分區如何擴容


擴容已有GPT分區

parted命令主要用于 GPT分區表的操作

? GPT:GPT 分區表支持更大的硬盤容量。它使用64位的邏輯塊地址,因此可以支持超過2 TB的硬盤容量

分區后擴容

以ext4文件系統為例

/dev/sdf1有10G。將數據盤容量擴大至20G,將新增的10G劃分至已有的/dev/sdf1內

df -Th


parted /dev/sdf

(parted) print

Error: The backup GPT table is not at the end of the disk, as it should be.  This might mean that another operating system believes the

disk is smaller.  Fix, by moving the backup to the end (and removing the old backup)?

Fix/Ignore/Cancel? Fix   #若界面提示Fix/Ignore/Cancel?和Fix/Ignore?,均輸入Fix即可

Warning: Not all of the space available to /dev/sdf appears to be used, you can fix the GPT to use all of the space (an extra 20971520

blocks) or continue with the current setting?

Fix/Ignore? Fix

Model: VMware Virtual disk (scsi)

Disk /dev/sdf: 21.5GB

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

Partition Table: gpt

Disk Flags:

 

Number  Start   End     Size    File system  Name     Flags

 1      1049kB  10.7GB  10.7GB  ext4         primary

 

(parted) rm 1  #刪除1分區

(parted) mkpart primary 1049kB 100%   #原分區的起始扇區為1049kB,且要將擴容后的總容量全部分配給該分區

(parted) print 

Model: VMware Virtual disk (scsi)

Disk /dev/sdf: 21.5GB

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

Partition Table: gpt

Disk Flags:

 

Number  Start   End     Size    File system  Name     Flags

 1      1049kB  21.5GB  21.5GB  ext4         primary

(parted) quit #退出

Information: You may need to update /etc/fstab.

 

[root@localhost ~]# resize2fs /dev/sdf1

resize2fs 1.42.9 (28-Dec-2013)

Please run 'e2fsck -f /dev/sdf1' first.

 

[root@localhost ~]# e2fsck -f /dev/sdf1  #檢測磁盤

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/sdf1: 11/655360 files (0.0% non-contiguous), 83137/2620928 blocks

[root@localhost ~]# resize2fs /dev/sdf1

resize2fs 1.42.9 (28-Dec-2013)

Resizing the filesystem on /dev/sdf1 to 5242368 (4k) blocks.

The filesystem on /dev/sdf1 is now 5242368 blocks long.

 

[root@localhost ~]# mount /dev/sdf1  /aaa

[root@localhost ~]# df -Th

Filesystem                Type      Size  Used Avail Use% Mounted on

devtmpfs                  devtmpfs  1.9G     0  1.9G   0% /dev

tmpfs                     tmpfs     1.9G     0  1.9G   0% /dev/shm

tmpfs                     tmpfs     1.9G   20M  1.9G   2% /run

tmpfs                     tmpfs     1.9G     0  1.9G   0% /sys/fs/cgroup

/dev/mapper/centos-root   xfs        53G  3.2G   50G   6% /

/dev/sda1                 xfs       797M  151M  647M  19% /boot

tmpfs                     tmpfs     378M     0  378M   0% /run/user/0

/dev/mapper/vgdata-lvdata ext4      689G   69M  658G   1% /data

/dev/sdf1                 ext4       20G   44M   19G   1% /aaa

 

藍隊云是專業的云計算及網絡安全服務商,提供云服務器、域名注冊、負載均衡、SSL證書等專業的產品及服務。官網上擁有完善的技術支持庫可供參考,大家可自行查閱,更多技術問題,可以直接咨詢。同時,藍隊云整理了運維必備的工具包免費分享給大家使用,需要的朋友可以直接咨詢。

更多技術知識,藍隊云期待與你一起探索。


提交成功!非常感謝您的反饋,我們會繼續努力做到更好!

這條文檔是否有幫助解決問題?

非常抱歉未能幫助到您。為了給您提供更好的服務,我們很需要您進一步的反饋信息:

在文檔使用中是否遇到以下問題: