一、介绍 根目录空间紧张,以不加硬盘的方式扩容根目录空间。
二、实操 (1)磁盘情况-根目录36G
[root@xdw0 disk]
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 3.0G 0 3.0G 0% /dev
tmpfs 3.0G 0 3.0G 0% /dev/shm
tmpfs 3.0G 13M 3.0G 1% /run
tmpfs 3.0G 0 3.0G 0% /sys/fs/cgroup
/dev/mapper/centos-root 36G 14G 22G 40% /
/dev/sda1 1014M 173M 842M 18% /boot
/dev/mapper/centos-home 18G 10G 7.8G 56% /home
tmpfs 601M 0 601M 0% /run/user/0
tmpfs 601M 0 601M 0% /run/user/1000
tmpfs 601M 16K 601M 1% /run/user/42
(2)dd命令生成空文件,赋权限
dd if=/dev/zero of=HDD.img bs=1M count=6500
chmod 777 HDD.img
(3)划盘
fdisk HDD.img
(4)发现新盘不识别
[root@xdw0 disk]
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 59G 0 part
├─centos-root 253:0 0 35.7G 0 lvm /
├─centos-swap 253:1 0 5.9G 0 lvm [SWAP]
└─centos-home 253:2 0 17.4G 0 lvm /home
sr0 11:0 1 9.5G 0 rom
(5)设置循坏设备 losetup命令介绍: 用来设置循坏设备,循坏设备可以把文件虚拟成块设备,借此来模拟整个文件系统,让用户得以将其视为硬盘驱动器,光驱等设备,并挂入当作目录来使用。
[root@xdw0 disk]
/dev/loop0
(6)识别新盘
[root@xdw0 disk]
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 60G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 59G 0 part
├─centos-root 253:0 0 35.7G 0 lvm /
├─centos-swap 253:1 0 5.9G 0 lvm [SWAP]
└─centos-home 253:2 0 17.4G 0 lvm /home
sr0 11:0 1 9.5G 0 rom
loop0 7:0 0 6.4G 0 loop
└─loop0p1 259:0 0 6G 0 loop
(7)文件系统格式化为XFS
[root@xdw0 disk]
Discarding blocks...Done.
meta-data=/dev/loop0p1 isize=512 agcount=4, agsize=393216 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=1572864, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
(8)创建物理卷
[root@xdw0 disk]
WARNING: xfs signature detected on /dev/loop0p1 at offset 0. Wipe it? [y/n]: y
Wiping xfs signature on /dev/loop0p1.
Physical volume "/dev/loop0p1" successfully created.
(9)扩展卷组
[root@xdw0 disk]
Volume group "centos" successfully extended
(10)扩展逻辑卷
[root@xdw0 disk]
Size of logical volume centos/root changed from 35.69 GiB (9137 extents) to 41.69 GiB (10673 extents).
Logical volume centos/root successfully resized.
(11)扩展一个现存的XFS文件系统
[root@xdw0 disk]
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=2339072 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=9356288, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=4568, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 9356288 to 10929152
(12)扩容成功-根目录变为42G
[root@xdw0 opt]
文件系统 类型 容量 已用 可用 已用% 挂载点
devtmpfs devtmpfs 3.0G 0 3.0G 0% /dev
tmpfs tmpfs 3.0G 0 3.0G 0% /dev/shm
tmpfs tmpfs 3.0G 13M 3.0G 1% /run
tmpfs tmpfs 3.0G 0 3.0G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 42G 38G 3.8G 91% /
/dev/sda1 xfs 1014M 173M 842M 18% /boot
/dev/mapper/centos-home xfs 18G 17G 1.4G 93% /home
tmpfs tmpfs 601M 0 601M 0% /run/user/0
tmpfs tmpfs 601M 0 601M 0% /run/user/1000
tmpfs tmpfs 601M 16K 601M 1% /run/user/42
|