How To Install dphys-swapfile on Debian 10

Learn how to install dphys-swapfile on Debian 10 with this tutorial. dphys-swapfile is Autogenerate and use a swap file

Introduction

In this tutorial we learn how to install dphys-swapfile on Debian 10.

What is dphys-swapfile

dphys-swapfile is:

This init.d script exists so one does not need to have a fixed size swap partition. Instead install without swap partition and then run this, with file size (re-)computed automatically to fit the current RAM size.

By default (and hence on installation) it creates swapfile twice as big as the present RAM amount with an upper limit of 2 GB.

It’s also very helpful when included in SD card, USB stick or disk images which are distributed and run on many machines with different amount of RAM, e.g. different models of the Raspberry Pi or cloud images.

There are three methods to install dphys-swapfile on Debian 10. We can use apt-get, apt and aptitude. In the following sections we will describe each method. You can choose one of them.

Install dphys-swapfile Using apt-get

Update apt database with apt-get using the following command.

sudo apt-get update

After updating apt database, We can install dphys-swapfile using apt-get by running the following command:

sudo apt-get -y install dphys-swapfile

Install dphys-swapfile Using apt

Update apt database with apt using the following command.

sudo apt update

After updating apt database, We can install dphys-swapfile using apt by running the following command:

sudo apt -y install dphys-swapfile

Install dphys-swapfile Using aptitude

If you want to follow this method, you might need to install aptitude first since aptitude is usually not installed by default on Debian. Update apt database with aptitude using the following command.

sudo aptitude update

After updating apt database, We can install dphys-swapfile using aptitude by running the following command:

sudo aptitude -y install dphys-swapfile

How To Uninstall dphys-swapfile on Debian 10

To uninstall only the dphys-swapfile package we can use the following command:

sudo apt-get remove dphys-swapfile

Uninstall dphys-swapfile And Its Dependencies

To uninstall dphys-swapfile and its dependencies that are no longer needed by Debian 10, we can use the command below:

sudo apt-get -y autoremove dphys-swapfile

Remove dphys-swapfile Configurations and Data

To remove dphys-swapfile configuration and data from Debian 10 we can use the following command:

sudo apt-get -y purge dphys-swapfile

Remove dphys-swapfile configuration, data, and all of its dependencies

We can use the following command to remove dphys-swapfile configurations, data and all of its dependencies, we can use the following command:

sudo apt-get -y autoremove --purge dphys-swapfile

Dependencies

dphys-swapfile have the following dependencies:

References

Summary

In this tutorial we learn how to install dphys-swapfile package on Debian 10 using different package management tools: apt, apt-get and aptitude.