一、查看我们的根分区大小是多少
df -h
显示此目录下磁盘已满
二、进一步发现/proc/目录下有很多不知名的进程,占用了系统空间,且删不掉
[root@Anwar01 proc]# ls
1 17 276 303 33 412 5 603 67 acpi dma
kcore modules softirqs vmallocinfo
10 18 280 30634 34 413 503 630 670 asound driver keys mounts stat vmstat
100 19 282 30653 381 414 505 631 6941 buddyinfo execdomains key-users mtrr swaps zoneinfo
11 2 284 30755 382 415 575 634 7 bus fb kmsg net sys
12 20 299 309 391 416 576 635 7244 cgroups filesystems kpagecount pagetypeinfo sysrq-trigger
1238 21 3 31 392 417 577 636 7513 cmdline fs kpageflags partitions sysvipc
1240 2139 300 310 407 42 578 643 7560 consoles interrupts loadavg sched_debug timer_list
13 22 30091 3180 408 45 579 660 8 cpuinfo iomem locks schedstat timer_stats
1317 23 30095 32 409 46 580 6637 9 crypto ioports mdstat scsi tty
1321 24 301 320 410 48 581 665 994 devices irq meminfo self uptime
15 275 302 321 411 486 582 667 995 diskstats kallsyms misc slabinfo version
三、查看整个磁盘情况
[root@Anwar01 /]# fdisk -l
磁盘 /dev/sda:500.1 GB, 500107862016 字节,976773168 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xf0b1ebb0
设备 Boot Start End Blocks Id System
/dev/sda1 * 63 122865119 61432528+ 7 HPFS/NTFS/exFAT
/dev/sda2 122865120 965088809 421111845 f W95 Ext'd (LBA)
/dev/sda4 965089280 976773167 5841944 12 Compaq diagnostics
/dev/sda5 122865183 491492609 184313713+ 7 HPFS/NTFS/exFAT
/dev/sda6 491492673 778204664 143355996 7 HPFS/NTFS/exFAT
/dev/sda7 778204728 952268939 87032106 7 HPFS/NTFS/exFAT
/dev/sda8 952272896 954370047 1048576 83 Linux
/dev/sda9 954372096 965087231 5357568 8e Linux LVM
磁盘 /dev/mapper/centos-root:4823 MB, 4823449600 字节,9420800 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘 /dev/mapper/centos-swap:658 MB, 658505728 字节,1286144 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
四、于是找出系统中有哪些分区,查看磁盘编号即物理卷
[root@Anwar01 /]# ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sda4 /dev/sda5 /dev/sda6 /dev/sda7 /dev/sda8 /dev/sda9
五、将卷组/dev/sda1进行扩展
[root@Anwar01 /]# vgextend centos /dev/sda1
WARNING: ntfs signature detected on /dev/sda1 at offset 3. Wipe it? [y/n]: y
Wiping ntfs signature on /dev/sda1.
Physical volume "/dev/sda1" successfully created.
Volume group "centos" successfully extended
六、成功把vg卷扩展了,在用vgs查看一下
[root@Anwar01 /]# vgs
VG #PV #LV #SN Attr VSize VFree
centos 2 2 0 wz--n- <63.69g 58.58g
七、虽然把vg扩展了,但是lv还没有扩展
[root@Anwar01 /]# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root centos -wi-ao---- 4.49g
swap centos -wi-ao---- 628.00m
八、扩展lv,使用lvextend命令
lvextend -L +20G /dev/mapper/centos-root
[root@Anwar01 /]# lvextend -L +20G /dev/mapper/centos-root
Size of logical volume centos/root changed from 4.49 GiB (1150 extents) to 24.49 GiB (6270 extents).
Logical volume centos/root successfully resized.
九、命令使系统重新读取大小
xfs_growfs /dev/mapper/centos-root
[root@Anwar01 /]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=294400 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=1177600, 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 1177600 to 6420480
十、再使用df -h查看
[root@Anwar01 /]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/centos-root 25G 4.5G 21G 19% /
devtmpfs 892M 0 892M 0% /dev
tmpfs 903M 0 903M 0% /dev/shm
tmpfs 903M 8.6M 894M 1% /run
tmpfs 903M 0 903M 0% /sys/fs/cgroup
/dev/sda8 1014M 143M 872M 15% /boot
tmpfs 181M 0 181M 0% /run/user/0
网友评论