创建目录 /u01 ,将/home 下存储均分给/u01 ,只留50G.
一、重新分配/home大小
1. 卸载/home
umount /home
如果无法umount ,会报错:
umount: /home:目标忙。 (有些情况下通过 lsof(8) 或 fuser(1) 可以找到有关使用该设备的进程的有用信息)
[root@localhost ~]# umount /home umount: /home:目标忙。 (有些情况下通过 lsof(8) 或 fuser(1) 可以 找到有关使用该设备的进程的有用信息) [root@localhost ~]# fuser -mv /home 用户 进程号 权限 命令 /home: root kernel mount /home root 13068 ..c.. bash [root@localhost ~]# kill -9 13068 [root@localhost ~]# umount /home
2. 删除/home的 lv
lvremove /dev/centos/home
3. 重新创建 /home 的 lv
lvcreate -L 30G -n home centos
4. 格式化磁盘
mkfs.xfs /dev/centos/home
5. 挂载磁盘至/home
mount /dev/centos/home /home
验证:查看/home 大小,vg剩余空间
[root@localhost mariadb10.4]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 50G 1.1G 49G 3% /
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 16G 9.0M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/sda1 1014M 145M 870M 15% /boot
tmpfs 3.2G 0 3.2G 0% /run/user/0
/dev/mapper/centos-home 30G 33M 30G 1% /home
[root@localhost mariadb10.4]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 1.36 TiB
PE Size 4.00 MiB
Total PE 356703
Alloc PE / Size 24512 / 95.75 GiB
Free PE / Size 332191 / <1.27 TiB
VG UUID GvnU39-YP2W-3s4J-vy9v-EGTy-Gyta-J3L8gB
二、分配空间给/u01 目录
1. 创建/u01 目录lv
lvcreate -L 1.265T -n u01 centos
2. 格式化/u01
mkfs.xfs /dev/centos/u01
[root@localhost ~]# mount /dev/centos/home /home mount: /dev/mapper/centos-home:不能读超级块 [root@localhost ~]# mkfs.xfs -f /dev/centos/home meta-data=/dev/centos/home isize=512 agcount=4, agsize=2690560 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0, sparse=0 data = bsize=4096 blocks=10762240, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal log bsize=4096 blocks=5255, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 [root@localhost ~]# mount /dev/centos/home /home [root@localhost ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 50G 1.2G 49G 3% / devtmpfs 16G 0 16G 0% /dev tmpfs 16G 0 16G 0% /dev/shm tmpfs 16G 9.3M 16G 1% /run tmpfs 16G 0 16G 0% /sys/fs/cgroup /dev/sda1 1014M 142M 873M 14% /boot tmpfs 3.2G 0 3.2G 0% /run/user/0 /dev/mapper/centos-home 42G 33M 42G 1% /home
3. 挂载/u01
mount /dev/centos/u01 /u01
验证查看存储
[root@localhost mariadb10.4]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 50G 1.1G 49G 3% /
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 16G 9.0M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/sda1 1014M 145M 870M 15% /boot
tmpfs 3.2G 0 3.2G 0% /run/user/0
/dev/mapper/centos-home 30G 33M 30G 1% /home
/dev/mapper/centos-u01 1.3T 33M 1.3T 1% /u01
写入开机自动挂载
/etc/fstab