1. 程式人生 > 其它 >Linux 資料盤線上擴容

Linux 資料盤線上擴容

1、解除安裝資料盤
[root@localhost ~]# umount /dev/sda1

2、使用fdisk /dev/sda 對資料盤分割槽操作
[root@localhost ~]# fdisk /dev/sda

WARNING: The size of this disk is 3.0 TB (3000034656256 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID
partition table format (GPT).

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): p

Disk /dev/sdb: 3000.0 GB, 3000034656256 bytes, 5859442688 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: 0x000b6f25

Device Boot Start End Blocks Id System
/dev/sdb1 2048 1048578047 524288000 83 Linux

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):
Using default response p
Partition number (1-4, default 1):
First sector (2048-4294967295, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4294967294, default 4294967294): +1300G
Partition 1 of type Linux and of size 1.3 TiB is set

Command (m for help): p

Disk /dev/sdb: 3000.0 GB, 3000034656256 bytes, 5859442688 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: 0x000b6f25

Device Boot Start End Blocks Id System
/dev/sdb1 2048 2726299647 1363148800 83 Linux

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

Calling ioctl() to re-read partition table.
Syncing disks.

3、檢查檔案系統
e2fsck -f /dev/sda1
e2fsck 1.42.9 (28-Dec-2013)
/dev/sda1 is mounted.
e2fsck: Cannot continue, aborting.

4、變更檔案系統大小
resize2fs /dev/sda1
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/sda1 is mounted on /data; on-line resizing required
old_desc_blocks = 13, new_desc_blocks = 63
The filesystem on /dev/sda1 is now 131071744 blocks long.

5.重新掛載
mount -a
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 47G 3.8G 44G 8% /
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 9.2M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/vda1 1014M 145M 870M 15% /boot
tmpfs 781M 0 781M 0% /run/user/0
/dev/sda1 493G 5.7G 466G 2% /data

參考至:https://www.cnblogs.com/chengtai/p/7389284.html