进入VMware设置,添加硬盘
查看挂载点信息
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 893M 0 893M 0% /dev
tmpfs 910M 0 910M 0% /dev/shm
tmpfs 910M 11M 900M 2% /run
tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/mapper/centos-root 9.0G 9.0G 296K 100% /
/dev/sda1 1014M 185M 830M 19% /boot
tmpfs 182M 24K 182M 1% /run/user/1000
查看硬盘状态
[root@localhost ~]# fdisk -l
磁盘 /dev/sda:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000d431f
设备 Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda3 2099200 41943039 19921920 8e Linux LVM
磁盘 /dev/sdb:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xdeaffced
设备 Boot Start End Blocks Id System
/dev/sdb1 2048 41943039 20970496 83 Linux
磁盘 /dev/mapper/centos-root:9659 MB, 9659482112 字节,18866176 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/mapper/centos-swap:10.7 GB, 10737418240 字节,20971520 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
[hikktn@localhost ~]fdisk /dev/sda
查看新硬盘分区名
格式化分区
[root@localhost ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242624 blocks
262131 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
进入lvm管理
[root@localhost ~]# lvm
初始化分区
lvm> pvcreate /dev/sdb1
WARNING: ext3 signature detected on /dev/sdb1 at offset 1080. Wipe it? [y/n]: y
Wiping ext3 signature on /dev/sdb1.
Physical volume "/dev/sdb1" successfully created.
查看卷和卷组
lvm> vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size <19.00 GiB
PE Size 4.00 MiB
Total PE 4863
Alloc PE / Size 4863 / <19.00 GiB
Free PE / Size 0 / 0
VG UUID Y69a5D-cc63-1MwY-oZzY-r9wn-JY1p-uSyLVj
加入虚拟卷组
lvm> vgextend centos /dev/sdb1
Volume group "centos" successfully extended
内存不足,必须删除必要的文件建议删除/var/cache/yum/x86_64/7/updates/packages/这下面的文件,这些都是压缩包,不会影响linux。
扩展卷容量
lvm> lvextend -l +21513 /dev/mapper/centos-root
Insufficient free space: 21513 extents needed, but only 5119 available
本来打算直接扩容20G,失败!找了找解决方案,没看到有效的。
最后思考了下,尝试一点点来,
[root@localhost ~]# lvextend -L +3G /dev/centos/root
Size of logical volume centos/root changed from <17.00 GiB (4351 extents) to <20.00 GiB (5119 extents).
Logical volume centos/root successfully resized.
成功了,然后分批次进行扩容,每次扩容就加到文件里去[root@localhost ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=8, agsize=589568 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=4455424, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 4455424 to 5241856
上面操作多试几次就可以了,最后查看容量。
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 893M 0 893M 0% /dev
tmpfs 910M 0 910M 0% /dev/shm
tmpfs 910M 11M 900M 2% /run
tmpfs 910M 0 910M 0% /sys/fs/cgroup
/dev/mapper/centos-root 24G 8.4G 16G 35% /
/dev/sda1 1014M 185M 830M 19% /boot
tmpfs 182M 36K 182M 1% /run/user/1000
tmpfs 182M 0 182M 0% /run/user/0
成功扩容!!!