📜  为什么 lubuntu 20.04 冻结 - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:49:39.349000             🧑  作者: Mango

代码示例1
You have no swap!

~$ free -h

              total        used        free      shared  buff/cache   available
Mem:          2.9Gi       671Mi       1.3Gi       141Mi       997Mi       2.0Gi
Swap:            0B          0B          0B
Lets create a /swapfile...

Note: Incorrect use of the dd command can cause data loss. Suggest copy/paste.

In the terminal...

Note: instructions reduced from a 4G, to a 1G /swapfile, due to disk space issues.

sudo swapoff -a           # turn off swap
sudo rm -i /swapfile      # remove old /swapfile

sudo dd if=/dev/zero of=/swapfile bs=1M count=1024

sudo chmod 600 /swapfile  # set proper file protections
sudo mkswap /swapfile     # init /swapfile
sudo swapon /swapfile     # turn on swap
free -h                   # confirm 3G RAM and 1G swap
Add this /swapfile line at the end of /etc/fstab... and confirm no other “swap” lines...

To edit, use sudo -H gedit /etc/fstab or sudo pico /etc/fstab

/swapfile    none    swap    sw      0   0
reboot                    # reboot and verify operation