第一步要手动加硬盘(我的操作是在20G的基础上加了30G)
[reliable@hadoop102 ~]$ su root
密码:
查看当前磁盘挂载情况:
[root@hadoop102 reliable]# fdisk -l
磁盘 /dev/sda:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000cef83
设备 Boot Start End Blocks Id System
系统目前有的分区:
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
磁盘 /dev/mapper/centos-root:18.2 GB, 18249416704 字节,35643392 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/mapper/centos-swap:2147 MB, 2147483648 字节,4194304 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
[root@hadoop102 reliable]# pvcreate /dev/sda
Device /dev/sda excluded by a filter.
选择操作的磁盘:
[root@hadoop102 reliable]# fdisk /dev/sda
欢迎使用 fdisk (util-linux 2.23.2)。
更改将一直保留在内存中,直到您决定将其写入磁盘。
[En]
The changes remain in memory until you decide to write them to disk.
使用写入命令前请三思。
查看磁盘分区情况:(当前未分区)
命令(输入 m 获取帮助):p
磁盘 /dev/sda:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000cef83
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
重新分区:
命令(输入 m 获取帮助):n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
分区号 (3,4,默认 3):3
起始 扇区 (41943040-104857599,默认为 41943040):41943040
Last 扇区, +扇区 or +size{K,M,G} (41943040-104857599,默认为 104857599):104857599
分区 3 已设置为 Linux 类型,大小设为 30 GiB
命令(输入 m 获取帮助):p
磁盘 /dev/sda:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000cef83
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
/dev/sda3 41943040 104857599 31457280 83 Linux
更改分区id:
命令(输入 m 获取帮助):t
分区号 (1-3,默认 3):3
Hex 代码(输入 L 列出所有代码):L
0 空 24 NEC DOS 81 Minix / 旧 Linu bf Solaris
1 FAT12 27 隐藏的 NTFS Win 82 Linux 交换 / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 隐藏的 C: c6 DRDOS/sec (FAT-
4 FAT16
Hex 代码(输入 L 列出所有代码):8e
已将分区”Linux”的类型更改为”Linux LVM”
命令(输入 m 获取帮助):p
磁盘 /dev/sda:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000cef83
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 41943039 19921920 8e Linux LVM
/dev/sda3 41943040 104857599 31457280 8e Linux LVM
保存退出:
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
正在同步磁盘。
[root@hadoop102 reliable]# pvcreate /dev/sda3
Device /dev/sda3 not found.
[root@hadoop102 reliable]# pvcreate /dev/sda3
Device /dev/sda3 not found.
[root@hadoop102 reliable]# reboot
Connection closing…Socket close.
Connection closed by foreign host.
Disconnected from remote host(hadoop102) at 23:01:54.
Type `help’ to learn how to use Xshell prompt.
[d:\~]$
Connecting to 192.168.10.102:22…
Connection established.
To escape to local shell, press ‘Ctrl+Alt+]’.
Last login: Sun Oct 10 22:47:45 2021 from 192.168.10.1
[reliable@hadoop102 ~]$ su root
密码:
创建物理卷:
[root@hadoop102 reliable]# pvcreate /dev/sda3
Physical volume “/dev/sda3” successfully created.
查看物理卷信息:(vgdisplay也是查看物理卷信息)
[root@hadoop102 reliable]# pvdisplay
Original: https://www.cnblogs.com/rainbow-1/p/15391407.html
Author: 靠谱杨
Title: 【已解决】linux centos7系统磁盘扩容
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/524461/
转载文章受原作者版权保护。转载请注明原作者出处!