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/cat1/p/15206370.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步