I have 3 LXC 22.04 systems. No physical system installs. Linux containers use the swap from the host system ... which is 20.04
The host LXC system:
Code:
$ free -hm
total used free shared buff/cache available
Mem: 30Gi 20Gi 2.6Gi 102Mi 8.1Gi 10Gi
Swap: 4.1Gi 2.1Gi 2.0Gi
Code:
$ swapon -s
Filename Type Size Used Priority
/dev/dm-5 partition 4300796 2232356 -2
$ sudo lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
swap vg00 -wi-ao---- 4.10g
...
LXC-1:
Code:
$ free -hm
total used free shared buff/cache available
Mem: 30Gi 108Mi 30Gi 33Mi 85Mi 30Gi
Swap: 4.1Gi 0B 4.1Gi
LXC-2:
Code:
$ free -mh
total used free shared buff/cache available
Mem: 30Gi 688Mi 29Gi 59Mi 215Mi 29Gi
Swap: 4.1Gi 0B 4.1Gi
LXC-3:
Code:
$ free -hm
total used free shared buff/cache available
Mem: 30Gi 229Mi 30Gi 7.0Mi 162Mi 30Gi
Swap: 4.1Gi 0B 4.1Gi
Interesting.
Here's a 20.04 VM (KVM/QEMU):
Code:
$ free -hm
total used free shared buff/cache available
Mem: 964Mi 187Mi 116Mi 1.0Mi 660Mi 598Mi
Swap: 1.0Gi 5.0Mi 1.0Gi
$ swapon -s
Filename Type Size Used Priority
/dev/dm-1 partition 1048572 5888 -2
$ lsblk
NAME TYPE FSTYPE SIZE FSAVAIL FSUSE% LABEL MOUNTPOINT
vda disk 30.2G
├─vda1 part ext2 487M 229.2M 46% /boot
├─vda2 part 1M
└─vda5 part LVM2_member 29.7G
├─blog--vg-root lvm ext4 23.5G 8.1G 59% /
└─blog--vg-swap_1 lvm swap 1G [SWAP]
VMs are just like physical systems.
That VM swap was manually sized. I should probably make it 500MB. The Linux kernel behaves different when there's no swap and when there's a minimal swap, it enables some good features.
Ah ... I have a VPS with a 22.04 server install. I didn't manually size anything. Everything for the base OS install was created in the provider's panel. I didn't customize the swap at all.
Code:
$ dft
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 24G 11G 13G 46% /
$ free -hm
total used free shared buff/cache available
Mem: 957Mi 255Mi 133Mi 1.0Mi 568Mi 538Mi
Swap: 2.3Gi 0B 2.3Gi
$ ll /swapfile
-rw------- 1 root root 2516582400 Jun 26 2023 /swapfile
The swap is much larger than I need. I'm unhappy that a swapfile is used, but I guess that's the default. The VPS is just a VPN and reverse proxy server, so it doesn't need much CPU or storage. I'm at a loss for how 11G is used. For a minimal Ubuntu server, I'd expect less than 7GB would be used. There aren't any snaps on the box. Just haproxy and wireguard with a basic Ubuntu 22.04 server. Clearly the bloat is strong in 22.04.
Lubuntu 24.04 - wipe disk + minimal install:
Code:
$ free -hm
total used free shared buff/cache available
Mem: 3.8Gi 756Mi 2.5Gi 11Mi 886Mi 3.1Gi
Swap: 511Mi 0B 511Mi
$ ll /swapfile
-rw------- 1 root root 536870912 May 1 10:37 /swapfile
$ lsblk -e 7 -o name,type,fstype,size,FSAVAIL,FSUSE%,label,mountpoint
NAME TYPE FSTYPE SIZE FSAVAIL FSUSE% LABEL M
sr0 rom 2K
vda disk 25G
└─vda1 part ext4 25G 16.3G 28% lubuntu_2404 /
I don't remember being asked about the swapfile size.
Bookmarks