the problem is on a hetzner Q7 Server with as little as 512MB RAM, MySQL keeps crashin.

what can you do?

repartition? -> DANGEROUS and almost impossible without powering down the system.

also: one might want to create a virtual linux Debian 10 vm to be dd over ssh to harddisk.img.gz and then be restored on harddisks that go into desktop/laptops via USB-harddisk adapter like this: https://www.ebay.de/itm/Xystec-Universal-Festplatten-Adapter-IDE-SATA-auf-USB-2-0-fur-HDDs-SSDs/131785326001

and one wants to change the swap partition (takes too much space) into a swap file.

ADD SWAP AS FILE!

where is one’s swap space?

# check out if and how much swap is configured on your system
# where are swap files?
cat /proc/swaps;
Filename Type Size Used Priority
# -> seems pretty empty so no swap files in use/configured

# where are swap partitions?
swapon;
NAME      TYPE      SIZE USED PRIO
/dev/sda5 partition   2G   0B   -2

disable swap partition:

swapoff /dev/sda5

create swap file:

# let's add a swap file
dd if=/dev/zero of=/swapfile bs=1024 count=524288; # generate 512MB Swap File /swapfile
# 1048576 for 1GB
# 2097152 for 2GB

chown root:root /swapfile; # secure permissions on swap file
chmod 0600 /swapfile;
mkswap /swapfile; # make the system use the swap file
swapon /swapfile; # enable it

vim /etc/fstab; # make swapfile permanent

# At the bottom of the file, you need to add a line that will tell the operating system to automatically use the file you created:

/swapfile none swap sw 0 0

# now let's rerun our first check-swap-space command
swapon
NAME TYPE SIZE USED PRIO
/swapfile file 512M 0B -1

cat /proc/swaps;
Filename Type Size Used Priority
/swapfile file 524284 0 -1 > /etc/sysctl.conf

# configures how much the system will choose to cache inode and dentry information over other data

cat /proc/sys/vm/vfs_cache_pressure;
100

# Basically, this is access data about the filesystem. This is generally very costly to look up and very frequently requested, so it's an excellent thing for your system to cache

# As it is currently configured, our system removes inode information from the cache too quickly. We can set this to a more conservative setting like 50 by typing:

echo "vm.vfs_cache_pressure = 50" >> /etc/sysctl.conf;

admin