1.查看虚拟机硬盘驱动位置:设置→IDE控制器 →硬盘驱动器→检查
2.操作→编辑磁盘 下一步填写要扩容大小 确认,到此磁盘扩容已完成。
1.查看现在使用的磁盘分区信息,根分区是240G
1 2 3 4 5 6 7 8 9 10 11 |
|
2.查看新增加的磁盘信息,/dev/sda:483.2 GB ,嗯识别到了。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
3.根据上面的信息,对磁盘未分区的部分空间进行分区。这一步比较复杂,必须注释才能明白这些操作。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
我就先重启CentOS后,再继续。
重启完成。
4.创建物理卷
1 2 |
|
5.查看物理卷信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
6.将新创建的分区/dev/sda3加入到根目录分区cl中
1 2 |
|
7.重新查看卷组信息
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
8.进行卷扩容
1 2 3 |
|
9.使扩容生效
1 2 3 4 5 6 7 8 9 10 11 |
|
10.最后,查看磁盘信息,根目录分区大小435G,扩容完美成功。
1 2 3 4 5 6 7 8 9 10 11 |
|
提醒:扩展逻辑边界时,如有以下报错修复即可,没有则跳过:
- [root@localhost ~]# resize2fs -p /dev/mapper/centos-root
- resize2fs 1.42.9 (28-Dec-2013)
- resize2fs: Bad magic number in super-block 当尝试打开 /dev/mapper/centos-root 时
- 找不到有效的文件系统超级块.
首先想到使用fsck进行修复下,并没有用,看到错误信息,才知道xfs文件要使用xfs_repair进行修复
- [root@localhost ~]# fsck /dev/mapper/centos-root
- fsck,来自 util-linux 2.23.2
- If you wish to check the consistency of an XFS filesystem or
- repair a damaged filesystem, see xfs_repair(8).
然后尝试修复下,然而并没有用,需要卸载才能进行修复,而此文件系统是挂载到 / 下的,所以想都别想。
- [root@localhost ~]# xfs_repair /dev/mapper/centos-root
- xfs_repair: /dev/mapper/centos-root contains a mounted filesystem
- xfs_repair: /dev/mapper/centos-root contains a mounted and writable filesystem
-
- fatal error -- couldn't initialize XFS library
最后在网上查了一番后,才知道xfs文件系统在进行逻辑扩展后,还要进行一步才能完成:
- [root@localhost ~]# lvs
- LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
- root centos -wi-ao---- 95.00g
- swap centos -wi-ao---- 3.88g
- [root@localhost ~]# df -lh
- 文件系统 容量 已用 可用 已用% 挂载点
- /dev/mapper/centos-root 46G 42G 4.5G 91% / ------------>46G
- devtmpfs 1.9G 0 1.9G 0% /dev
- tmpfs 1.9G 164K 1.9G 1% /dev/shm
- tmpfs 1.9G 8.7M 1.9G 1% /run
- tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
- /dev/sda1 497M 208M 290M 42% /boot
- [root@localhost ~]# xfs_growfs /dev/mapper/centos-root #执行调整,扩展后需要执行此步骤
- meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=2987776 blks
- = sectsz=512 attr=2, projid32bit=1
- = crc=0 finobt=0
- data = bsize=4096 blocks=11951104, imaxpct=25
- = sunit=0 swidth=0 blks
- naming =version 2 bsize=4096 ascii-ci=0 ftype=0
- log =internal bsize=4096 blocks=5835, version=2
- = sectsz=512 sunit=0 blks, lazy-count=1
- realtime =none extsz=4096 blocks=0, rtextents=0
- data blocks changed from 11951104 to 24903680
-
- [root@localhost ~]# df -lh
- 文件系统 容量 已用 可用 已用% 挂载点
- /dev/mapper/centos-root 95G 42G 54G 44% / ------------>已经完成扩展
- devtmpfs 1.9G 0 1.9G 0% /dev
- tmpfs 1.9G 164K 1.9G 1% /dev/shm
- tmpfs 1.9G 8.7M 1.9G 1% /run
- tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
- /dev/sda1 497M 208M 290M 42% /boot
xfs相关常用命令
- xfs_admin: 调整 xfs 文件系统的各种参数
- xfs_copy: 拷贝 xfs 文件系统的内容到一个或多个目标系统(并行方式)
- xfs_db: 调试或检测 xfs 文件系统(查看文件系统碎片等)
- xfs_check: 检测 xfs 文件系统的完整性
- xfs_bmap: 查看一个文件的块映射
- xfs_repair: 尝试修复受损的 xfs 文件系统
- xfs_fsr: 碎片整理
- xfs_quota: 管理 xfs 文件系统的磁盘配额
- xfs_metadump: 将 xfs 文件系统的元数据 (metadata) 拷贝到一个文件中
- xfs_mdrestore: 从一个文件中将元数据 (metadata) 恢复到 xfs 文件系统
- xfs_growfs: 调整一个 xfs 文件系统大小(只能扩展)
- xfs_freeze 暂停(-f)和恢复(-u)xfs 文件系统
- xfs_logprint: 打印xfs文件系统的日志
- xfs_mkfile: 创建xfs文件系统
- xfs_info: 查询文件系统详细信息
- xfs_ncheck: generate pathnames from i-numbers for XFS
- xfs_rtcp: XFS实时拷贝命令
- xfs_io: 调试xfs I/O路径