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
# 4194304 for 4GB
# 8388608 for 8GB
# 16777216 for 16GB
# 33554432 for 32GB
# 67108864 for 64GB
# 134217728 for 128GB

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

#  bottom of the file, add a line that will tell OS to automatically use the file as swap on boot
echo '/swapfile none swap sw 0 0' >> /etc/fstab; # make swapfile permanent

# let's rerun 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
# generally very costly to look up and very frequently requested,
# so it's an excellent thing for 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 (src)

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

liked this article?

  • only together we can create a truly free world
  • plz support dwaves to keep it up & running!
  • (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
  • really really hate advertisement
  • contribute: whenever a solution was found, blog about it for others to find!
  • talk about, recommend & link to this blog and articles
  • thanks to all who contribute!
admin