pve取消默认的swap,根目录扩容,dd new swap 15G

Swap 分区大小选择

Swap 合理的大小是与 VPS 的物理内存有关的,关系表(Red Hat Enterprise Linux):

  1. 内存 <= 4g:Swap 至少 4G
  2. 内存 4~16G:Swap 至少 8G
  3. 内存 16G~64G:Swap 至少 16G
  4. 内存 64G~256G:Swap 至少 32G

 lvs
  LV     VG     Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   pve    -wi-ao---- <111.74g
  swap   pve    -wi-ao----    7.00g

swapoff -a
lvremove /dev/pve/swap
Do you really want to remove active logical volume pve/swap? [y/n]: y
  Logical volume "swap" successfully removed.

lvresize -l +100%FREE /dev/pve/root
  Size of logical volume pve/root changed from <111.74 GiB (28605 extents) to <118.74 GiB (30397 extents).
  Logical volume pve/root successfully resized.

resize2fs /dev/mapper/pve-root
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/mapper/pve-root is mounted on /; on-line resizing required
old_desc_blocks = 14, new_desc_blocks = 15
The filesystem on /dev/mapper/pve-root is now 31126528 (4k) blocks long.

root@pve:/# lvs
  LV     VG     Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root   pve    -wi-ao---- <118.74g
 

cp /etc/fstab /etc/fstab.bak
vi /etc/fstab
#/dev/pve/swap none swap sw 0 0
dd if=/dev/zero of=/data/swapfile bs=1M count=16384
root@pve:/# chmod 0600 /data/swapfile
root@pve:/# mkswap /data/swapfile
Setting up swapspace version 1, size = 16 GiB (17179865088 bytes)
no label, UUID=f5768046-998c-4dfb-a60c-0ff6e73ee1a4
root@pve:/#
vi /etc/fstab
root@pve:/# vi /etc/fstab
root@pve:/# swapon -a
root@pve:/# free -h
               total        used        free      shared  buff/cache   available
内存:         7.6Gi       2.3Gi       166Mi       104Mi       5.5Gi       5.3Gi
交换:          15Gi          0B        15Gi

你可能感兴趣的:(linux)