查看磁盘状态
执行df -Th
查看磁盘情况
[root@iotdbtest1 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs tmpfs 7.7G 456K 7.7G 1% /run
tmpfs tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/sda1 ext4 20G 2.4G 17G 13% /
tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/0
可以看到系统磁盘/dev/sda1只有20G,实际这个磁盘有500G
!!!需要注意本教程不适用于lvm磁盘,系统盘的挂载磁盘只能是类似/dev/sdax
、/dev/vdax
、/dev/sdcx
这样的形式,不能是lvm磁盘,比如类似/dev/mapper/centos-root
这样的挂载磁盘是不能使用本教程的方法扩容的
根目录扩充
如果查看到的系统盘是/dev/sda1,则执行fdisk /dev/sda
对磁盘sda进行操作
如果查看到的系统盘是/dev/vda1,则执行fdisk /dev/vda
对磁盘vda进行操作
[root@iotdbtest1 ~]# fdisk /dev/sdaWelcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.# 删除分区
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.
# 新建分区
Command (m for help): n
Partition typep primary (0 primary, 0 extended, 4 free)e extended (container for logical partitions)
# 选择分区类型,回车默认主分区
Select (default p): Using default response p.
# 分区编号,回车默认
Partition number (1-4, default 1):
# 起始位置,回车默认
First sector (2048-1048575999, default 2048):
# 终止位置,回车默认
Last sector, +sectors or +size{K,M,G,T,P} (2048-1048575999, default 1048575999): Created a new partition 1 of type 'Linux' and of size 500 GiB.
Partition #1 contains a ext4 signature.# 是否移除签名,选择N否
Do you want to remove the signature? [Y]es/[N]o: N# w保存
Command (m for help): wThe partition table has been altered.
Syncing disks.
同步容量
如果系统挂载的磁盘是sda1,则执行下面的命令
resize2fs /dev/sda1
执行结果类似下面:
[root@iotdbtest1 ~]# resize2fs /dev/sda1
resize2fs 1.46.0 (29-Jan-2020)
Filesystem at /dev/sda1 is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 32
The filesystem on /dev/sda1 is now 131071744 (4k) blocks long.
验证容量
执行df -Th
查看磁盘实际分配
[root@iotdbtest1 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 7.7G 0 7.7G 0% /dev
tmpfs tmpfs 7.7G 0 7.7G 0% /dev/shm
tmpfs tmpfs 7.7G 456K 7.7G 1% /run
tmpfs tmpfs 7.7G 0 7.7G 0% /sys/fs/cgroup
/dev/sda1 ext4 492G 2.4G 470G 1% /
tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/0