1、问题
想运行tmux,结果
longqiping@ubuntu:~$ tmux
error creating /tmp//tmux-1000 (No space left on device)
2、检查
longqiping@ubuntu:~$ df /tmp
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/ubuntu--vg-ubuntu--lv 65019484 62892356 0 100% /
发现/tmp所在的/即ubuntu--vg-ubuntu--lv的空间没有了。
查看lvm卷组的信息
root@ubuntu:/home/longqiping# vgdisplay
--- Volume group ---
VG Name ubuntu-vg
System ID
Format lvm2
Metadata Areas 1 Metadata Sequence No 2 VG Access read/write
VG Status resizable
MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size <126.50 GiB
PE Size 4.00 MiB
Total PE 32383 Alloc PE / Size 16192 / 63.25 GiB
Free PE / Size 16191 / <63.25 GiB
VG UUID 8cak6E-4fZv-kGgq-lsOA-9FHC-Ju7R-kn2RJy
3、解决
使用命令进行磁盘扩容
lvextend -L 10G /dev/mapper/ubuntu--vg-ubuntu--lv //增大或减小至19G
lvextend -L +10G /dev/mapper/ubuntu--vg-ubuntu--lv //增加10G
lvreduce -L -10G /dev/mapper/ubuntu--vg-ubuntu--lv //减小10G
lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv //按百分比扩
使用如下命令,将/tmp增加60G
root@ubuntu:/home/longqiping# lvresize -L +60G /dev/mapper/ubuntu--vg-ubuntu--lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from 63.25 GiB (16192 extents) to 123.25 GiB (31552 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
扩容
root@ubuntu:/home/longqiping# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.45.5 (07-Jan-2020) Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line resizing required old_desc_blocks = 8, new_desc_blocks = 16 The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 32309248 (4k) blocks long.
看看效果
root@ubuntu:/home/longqiping# vgdisplay
--- Volume group ---
VG Name ubuntu-vg
System ID
Format lvm2
Metadata Areas 1 Metadata Sequence No 3 VG Access read/write
VG Status resizable
MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size <126.50 GiB
PE Size 4.00 MiB
Total PE 32383 Alloc PE / Size 31552 / 123.25 GiB
Free PE / Size 831 / <3.25 GiB
VG UUID 8cak6E-4fZv-kGgq-lsOA-9FHC-Ju7R-kn2RJy
root@ubuntu:/home/longqiping# df -h
Filesystem Size Used Avail Use% Mounted on
udev 16G 0 16G 0% /dev
tmpfs 3.2G 1.5M 3.2G 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 122G 61G 56G 52% /
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/vda2 976M 396M 514M 44% /boot
/dev/loop0 49M 49M 0 100% /snap/core18/1883
/dev/vda1 511M 3.5M 508M 1% /boot/efi
/dev/loop1 49M 49M 0 100% /snap/core18/1990
/dev/loop2 27M 27M 0 100% /snap/snapd/11043
/dev/loop3 29M 29M 0 100% /snap/snapd/11115
/dev/loop5 62M 62M 0 100% /snap/lxd/19206
/dev/loop4 63M 63M 0 100% /snap/lxd/19648
tmpfs 3.2G 0 3.2G 0% /run/user/1000