[LINUX] Set swap space on Ubuntu on Raspberry Pi

usage environment

Check if swap is set

$ sudo swapon --show

Nothing comes out because it is not set If it is set, it will be displayed like this

$ sudo swapon --show
NAME      TYPE  SIZE USED PRIO
/swapfile file 1024M   0B   -2

procedure

Swap file creation

I will make 1GB for the time being. Well, I'm not so pressed for it, and the physical memory is 1GB, so it's about the same.

$ sudo fallocate -l 1G /swapfile

Change permissions so that only the root user can read and write

$ sudo chmod 600 /swapfile

Create swap space in a file using mkswap

$ sudo mkswap /swapfile
Setting up swapspace version 1, size = 1024 MiB (1073737728 bytes)
no label, UUID=44dd3594-5812-473e-839d-d9c7a1af3d6a

Enable swap

$ sudo swapon /swapfile

I will check

$ sudo swapon --show
NAME      TYPE  SIZE USED PRIO
/swapfile file 1024M   0B   -2

See also on htop

htop.png

Add to fstab to automount at boot time

$ echo '/swapfile swap swap defaults 0 0' | sudo tee -a /etc/fstab
/swapfile swap swap defaults 0 0

Reboot and check

$ sudo reboot
$ sudo swapon --show
NAME      TYPE  SIZE USED PRIO
/swapfile file 1024M   0B   -2

Referenced site

https://linuxize.com/post/how-to-add-swap-space-on-ubuntu-18-04/ https://kazmax.zpp.jp/linux_beginner/mkswap.html

Recommended Posts

Set swap space on Ubuntu on Raspberry Pi
Build wxPython on Ubuntu 20.04 on raspberry pi 4
Cython on Raspberry Pi
Beginning cross-compilation for Raspberry Pi Zero on Ubuntu
Play with your Ubuntu desktop on your Raspberry Pi 4
Set up Python 3.4 on Ubuntu
Set matplotlib font on ubuntu
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
Introduced pyenv on Raspberry Pi
Use NeoPixel on Raspberry Pi
Install OpenCV4 on Raspberry Pi 3
Install TensorFlow 1.15.0 on Raspberry Pi
MQTT on Raspberry Pi and Mac
raspberry pi 4 centos7 install on docker
Try using ArUco on Raspberry Pi
OpenCV installation procedure on Raspberry Pi
Power on / off Raspberry pi on Arduino
Detect switch status on Raspberry Pi 3
Install OpenMedia Vault 5 on Raspberry Pi 4
L Chika on Raspberry Pi C #
"Honwaka Notification Lamp" on Raspberry Pi Part 2
Detect "brightness" using python on Raspberry Pi 3!
USB boot on Raspberry Pi 4 Model B
"Honwaka Notification Lamp" on Raspberry Pi Part 1
Enable UART + serial communication on Raspberry Pi
Adafruit Python BluefruitLE works on Raspberry Pi.
Accelerate Deep Learning on Raspberry Pi 4 CPU
Programming normally with Node-RED programming on Raspberry Pi 3
Use the Grove sensor on the Raspberry Pi
Install 64-bit OS (bate) on Raspberry Pi
Install docker-compose on 64-bit Raspberry Pi OS
Run servomotor on Raspberry Pi 3 using python
"Honwaka Notification Lamp" on Raspberry Pi Part 3
Working with sensors on Mathematica on Raspberry Pi
On Ubuntu Linux, set Tab to q
Build OpenCV-Python environment on Raspberry Pi B +
Detect temperature using python on Raspberry Pi 3!
Mount Windows shared folder on Raspberry Pi
Matrix multiplication on Raspberry Pi GPU (Part 2)
How to install NumPy on Raspberry Pi
I installed OpenCV-Python on my Raspberry Pi
Working with GPS on Raspberry Pi 3 Python
Why detectMultiScale () is slow on Raspberry Pi B +
Detect slide switches using python on Raspberry Pi 3!
Build a Django environment on Raspberry Pi (MySQL)
Try using a QR code on a Raspberry Pi
Shebang on Ubuntu 20.04
Detect magnet switches using python on Raspberry Pi 3!
Raspberry Pi backup
Enjoy electronic work with GPIO on Raspberry Pi
Power on / off your PC with raspberry pi
Use Grove-Temperature & Humidity Sensor (DHT11) on Raspberry Pi
Make DHT11 available on Raspberry Pi + python (memo)
Sound the buzzer using python on Raspberry Pi 3!
Display CPU temperature every 5 seconds on Raspberry Pi 4
Introduced Ceph on Kubernetes on Raspberry Pi 4B (ARM64)
Connect to MySQL with Python on Raspberry Pi
Build a Python development environment on Raspberry Pi
Build an Arch Linux environment on Raspberry Pi
Record temperature and humidity with systemd on Raspberry Pi
Build an OpenCV4 environment on Raspberry Pi using Poetry