A simple and effective solution to the "No space left on device" error based on Linux servers

A simple and effective solution to the "No space left on device" error based on Linux servers

1. The meaning of the error, indicating that the storage space on the server device is full, and no more uploads or new folders or files can be created.

No space left on device

translated as

设备上没有剩余空间

2. Check the disk usage of the server system to see if there is really no remaining space, copy the following command and run it on the server, and then find that if the following figure shows that the sda3 disk has no remaining space and is full.

df -lh

insert image description here

3. First go back to the root directory of the server, and then check the size of each folder under the root directory.

  • return to the root directory
cd /

insert image description here

  • Check the size of each folder under the root directory root. Note: After running the following command, you need to enter the user password, and then wait patiently for the storage calculation and display.
sudo du -sh *

insert image description here

4. After the previous step is completed, you can know the size of the folders in the root directory, and then enter the corresponding folders in order from large to small according to your needs, and then check the size of its subfolders, so that the weekly cycle will be You can find relatively large files and delete useless files according to your own needs. Freeing up a lot of device space will naturally solve the problem. For example: the blogger gives an example that the largest folder in the root directory is home, so the next step is to directly enter the home folder to operate.

insert image description here

  • Enter the home folder under the root directory root
cd /home

insert image description here

  • Continue to check the size of each folder under the home folder. Note: After running the following command, you need to enter the user password, and then wait patiently for the storage calculation and display.
sudo du -sh *

insert image description here

5. Continue to go back to the previous step. Find useless folders that take up a large amount of server storage and delete them again and again. If you feel that the deletion is almost complete, you can proceed to the next step of the article. Note: rm is a Linux delete command, -r means to recurse downwards, no matter how many levels of directories there are, delete them together, -f means to delete directly without any prompt. At the same time, the following delete command bloggers are all examples of the absolute path of their files or folders. In fact, you can first cd to the corresponding path of the file or folder and then use its relative path to delete; the last but equally important is to use this rm -rf Be extra careful when doing so, because Linux does not have a recycle bin, so files cannot be restored once they are forcibly deleted. Note: The blogger recommends using conda clean -athis command to clean up the pkgs file in the Anconda folder in the server.

  • Delete a folder, for example: rm -rf /homedelete the directory home and all files and folders under it.
rm -rf 目录名字
  • Delete files, for example: rm -f /home/wgw/.bash_historydelete the .bash_history file.
rm -f 文件名字

6. After deleting the files in the previous step, check whether the server device has actually released some space. For example, the blogger deleted some files and ran the following command to check, and found that the original 100% to 97% of the sda3 disk indicates that it has indeed been released. some space.

df -lh

insert image description here

Guess you like

Origin blog.csdn.net/rothschild666/article/details/127466352
Recommended