我在 Windows 上的 VirtualBox 6 上运行 CentOS 7 来宾。free 命令的结果如下:
$ free -h
total used free shared buff/cache available
Mem: 15G 2.4G 11G 162M 1.5G 12G
Swap: 1.2G 0B 1.2G
显示交换分区有 1.2 GB。我需要将其扩展至至少 2GB。因此,在来宾停止的情况下,我添加了一个 1.2 GB 的新卷,并且在重新启动后,我执行了以下操作:
$ sudo pvcreate /dev/sdb
$ sudo vgextend centos /dev/sdb
$ sudo lvextend -L+1G /dev/centos/swap
现在,lvdisplay 命令显示新创建的卷,如下所示:
$ sudo lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID 1OT4R8-69eL-vczL-zydM-XrwS-jA47-YfikMS
LV Write Access read/write
LV Creation host, time localhost, 2019-12-30 22:01:35 +0100
LV Status available
# open 2
LV Size <2.20 GiB
Current LE 563
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID hGDGPf-iPMB-TUtM-nqRv-aDNd-D3mw-W15H8Z
LV Write Access read/write
LV Creation host, time localhost, 2019-12-30 22:01:35 +0100
LV Status available
# open 1
LV Size <76.43 GiB
Current LE 19565
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
fstab 文件如下所示:
dev/mapper/centos-root / xfs defaults 0 0
UUID=4ef0416f-1617-40da-99d2-83896d808eed /boot xfs defaults 0 0
/dev/mapper/centos-swap swap swap defaults 0 0
显示交换是在 /dev/mapper/centos-swap 分区上分配的。这是 fstab 命令的输出:
Disk /dev/mapper/centos-root: 82.1 GB, 82061557760 bytes, 160276480 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-swap: 2361 MB, 2361393152 bytes, 4612096 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
但重新启动后, swapon 命令似乎没有反映扩展名:
$ sudo swapon -s
Filename Type Size Used Priority
/dev/dm-1 partition 1257468 0 -2
出于某种原因,交换似乎不在 /dev/mapper/centos-swap 分区上,而是在 /dev/dm-1 上,甚至不存在。并且 free 命令仍然显示与开头相同的结果:
$ free -h
total used free shared buff/cache available
Mem: 15G 2.4G 11G 155M 1.5G 12G
Swap: 1.2G 0B 1.2G
和/proc/swaps:
$ cat /proc/swaps
Filename Type Size Used Priority
/dev/dm-1 partition 1257468 0 -2
我在这里想念什么?
西摩