首先要关闭虚拟机,否则增加按钮不可见。


9

vm添加磁盘完毕。
2、登录虚拟机挂盘
1、lsblk
查看硬盘挂载情况,sdb为新挂载的磁盘。
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 99G 0 part
├─centos-root 253:0 0 50G 0 lvm /
├─centos-swap 253:1 0 7.9G 0 lvm [SWAP]
└─centos-home 253:2 0 41.1G 0 lvm /home
sdb 8:16 0 40G 0 disk
sr0 11:0 1 1024M 0 rom
2、fdisk -l
查看挂载之前的分区情况
[root@localhost ~]# fdisk -l
磁盘 /dev/sda:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x0000d223
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 209715199 103808000 8e Linux LVM
磁盘 /dev/sdb:42.9 GB, 42949672960 字节,83886080 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/mapper/centos-root:53.7 GB, 53687091200 字节,104857600 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/mapper/centos-swap:8455 MB, 8455716864 字节,16515072 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/mapper/centos-home:44.1 GB, 44149243904 字节,86228992 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

红框内是新添加的磁盘。
3、为新硬盘创建分区 fdisk /dev/sdb
终端会提示:
Command (m for help):输入:n
依次输入p 和 1
接着便会提示卷的起始地址和结束地址,都保持默认按回车的即可(意思是只分一个区)
输入“w”保存并推出。
[root@localhost ~]# fdisk /dev/sdb
欢迎使用 fdisk (util-linux 2.23.2)。
更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。
Device does not contain a recognized partition table
使用磁盘标识符 0x7e4902f0 创建新的 DOS 磁盘标签。
命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):1
起始 扇区 (2048-83886079,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-83886079,默认为 83886079):
将使用默认值 83886079
分区 1 已设置为 Linux 类型,大小设为 40 GiB
命令(输入 m 获取帮助):w
The partition table has been altered!
Calling ioctl() to re-read partition table.
正在同步磁盘。

4、再次使用fdisk -l查看 , 出现了 /dev/sdb1,说明分区工作完成;

5、 mkfs -t ext3 /dev/sdb1
对新区进行格式化

6、sblk
列出所有可用设备块信息

7、vgdisplay -v
查看卷分组
\
8、pvcreate /dev/sdb1
创建物理卷

9、pvdisplay
查看创建结果

10、vgextend centos /dev/sdb1
扩展卷分组,其中centos
是第7步中的VG Name

11、lvextend -L +40G /dev/centos/root
扩展逻辑卷

12、xfs_growfs /dev/centos/root
同步文件系统

13、df -h
再次查看挂载情况
以上磁盘挂载成功。
参考链接
推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:https://hqyman.cn/post/4584.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
打赏

微信支付宝扫一扫,打赏作者吧~
休息一下~~