If you want to add a swap partition in the Linux system, how to add it? Let’s take a look at the detailed tutorial below.
1. First, click "Launcher" on the dock bar, find " Deepin Terminal" and run it.
2. Then set a password for the root user. Because the installation process is for the administrator user, the root password is not set.
sudo passwd root
3. After the setting is completed, execute the su command to switch to the root user
4. Execute the following command to generate a swap file in the root directory. Count sets the number of blocks, bs sets the block size, and generates a 4G swap.
dd if=/dev/zero of=/swapfile count=4096 bs=1024k
5. Next, you need to set it as a swap partition (the path is consistent with the path above).
mkswap /swapfile
6. Mount the swap partition (the path is the same as the path above).
swapon /swapfile
7. At this time, you can see the corresponding swap partition information by executing the top command.
2. Automatically mount swap when booting up
1. Next, to implement automatic mounting at boot, use vim to open the fstab file :
vim /etc/fstab
2. Press the G key, switch to the end of the file, and append the following content
/swapfile swap swap defaults 0 0
3. The wq command saves and exits vim.
4. Restart your computer and you will see the effect.
Precautions:
If you do not allocate swap partition, it is easy to get stuck
related suggestion:
How to add shortcut key startup function to QQ in Linux?
How to resize the dock icon in Linux system?
How to set the font color in text mode in Linux?
The above is the detailed content of Steps and methods to add swap partition - Linux System Guide. For more information, please follow other related articles on the PHP Chinese website!