Linux write error no space left on device

Ошибка no space left on device в Linux

Ошибка no space left on device в Linux может возникать при использовании различных программ или сервисов. В графических программах данная ошибка может выводится во всплывающем сообщении, а для сервисов она обычно появляется в логах. Во всех случаях она означает одно. На разделе диска, куда программа собирается писать свои данные закончилось свободное место.

Избежать такой проблемы можно ещё на этапе планирования установки системы. Выделяйте под каталог /home отдельный раздел диска, тогда если вы займете всю память своими файлами, это не помешает работе системы. Также выделяйте больше 20 гигабайт под корневой раздел чтобы всем программам точно хватило места. Но что делать если такая проблема уже случилась? Давайте рассмотрим как освободить место на диске с Linux.

Как исправить no space left on device

Первым дело надо понять на каком разделе у вас закончилась память. Для этого можно воспользоваться утилитой df. Она поставляется вместе с системой, поэтому никаких проблем с её запуском быть не должно:

На точки монтирования, начинающиеся со слова snap внимания можно не обращать. Команда отображает общее количество места на диске, занятое и доступное место, а также процент занятого места. В данном случае 100% занято для корневого раздела — /dev/sda5. Конечно, надо разобраться какая программа или файл заняла всё место и устранить эту проблему, но сначала надо вернуть систему в рабочее состояние. Для этого надо освободить немного места. Рассмотрим что можно сделать чтобы экстренно освободить немного памяти.

1. Отключить зарезервированное место для root

Обычно, у всех файловых систем семейства Ext, которые принято использовать чаще всего как для корневого, так и для домашнего раздела используется резервирование 5% памяти для пользователя root на случай если на диске закончится место. Вы можете эту память освободить и использовать. Для этого выполните:

Здесь опция -m указывает процент зарезервированного места, а /dev/sda5 — это ваш диск, который надо настроить. После этого места должно стать больше.

2. Очистить кэш пакетного менеджера

Обычно, пакетный менеджер, будь то apt или yum хранит кэш пакетов, репозиториев и другие временные файлы на диске. Они некоторые из них ненужны, а некоторые нужны, но их можно скачать при необходимости. Если вам срочно надо дисковое пространство этот кэш можно почистить. Для очистки кэша apt выполните:

sudo apt clean
sudo apt autoclean

Для очистки кэша yum используйте команды:

3. Очистить кэш файловой системы

Вы могли удалить некоторые большие файлы, но память после этого так и не освободилась. Эта проблема актуальна для серверов, которые работают долгое время без перезагрузки. Чтобы полностью освободить память надо перезагрузить сервер. Просто перезагрузите его и места на диске станет больше.

Читайте также:  Установка openvpn linux debian

4. Найти большие файлы

После выполнения всех перечисленных выше рекомендаций, у вас уже должно быть достаточно свободного места для установки специальных утилит очистки системы. Для начала вы можете попытаться найти самые большие файлы и если они не нужны — удалить их. Возможно какая-либо программа создала огромный лог файл, который занял всю память. Чтобы узнать что занимает место на диске Linux можно использовать утилиту ncdu:

Она сканирует все файлы и отображает их по размеру:

Более подробно про поиск больших файлов читайте в отдельной статье.

5. Найти дубликаты файлов

С помощью утилиты BleachBit вы можете найти и удалить дубликаты файлов. Это тоже поможет сэкономить пространство на диске.

6. Удалите старые ядра

Ядро Linux довольно часто обновляется старые ядра остаются в каталоге /boot и занимают место. Если вы выделили под этот каталог отдельный раздел, то скоро это может стать проблемой и вы получите ошибку при обновлении, поскольку программа просто не сможет записать в этот каталог новое ядро. Решение простое — удалить старые версии ядер, которые больше не нужны.

Выводы

Теперь вы знаете почему возникает ошибка No space left on device, как её предотвратить и как исправить если с вами это уже произошло. Освободить место на диске с Linux не так уж сложно, но надо понять в чём была причина того, что всё место занято и исправить её, ведь на следующий раз не все эти методы смогут помочь.

Обнаружили ошибку в тексте? Сообщите мне об этом. Выделите текст с ошибкой и нажмите Ctrl+Enter.

Источник

How to Fix the “No space left on device” Error in Linux

If you are a Linux user, you may have encountered the “No space left on device” error message when trying to save, create, or install something on your system. This error message can be frustrating and confusing, especially if you are not familiar with the underlying cause of the issue.

In this article, we will explain what causes the “No space left on device” error in Linux and provide step-by-step instructions on how to fix it.

What Causes the “No Space Left on Device” Error in Linux?

The “No space left on device” error in Linux occurs when your system has run out of disk space. This error can happen for multiple reasons some of them are:

Now that we understand the cause of the “No space left on device” error, let’s dive into how to fix it.

How to Fix the “No space left on device” Error in Linux?

There are several reasons related to the storage that cause this error. Let’s discuss them one by one and their respective solutions.

Reason 1: Deleted Files Taking up Space

When we delete a file from a Linux system the space taken by the file is not automatically released by the system. As a result, the space keeps getting filled up with deleted files, causing the system to run out of space.

Solution: Free up the Occupied Storage

The best solution to this problem is to release the storage space occupied by deleted files. Now list all the deleted processes using the command below:

Once you have identified the deleted processes, you can release the storage space by performing a reload using the command below:

Читайте также:  Astra linux unexpected inconsistency

This command will ensure that the system releases the storage space for any deleted files.

Reason 2: Temporary Files Taking Space

A large number of temporary files accumulate over time, consuming disk space. To delete these temporary files, follow the given solution.

Solution: Clean Up Temporary Files

This command will give us the size of files that are stored in a temporary directory.

Run the below mentioned command to delete all files stored inside the temporary directory.

To confirm all the files got deleted again run the command:

Reason 3: Corrupted Blocks

Over time, unused storage blocks or other reasons can cause blocks to become corrupted, which the operating system will no longer recognize. This can result in the “No space left on device” error.

Solution: Repair the Corrupted Blocks

To resolve this issue, you need to mark the corrupted blocks as unusable so that the operating system can recognize them and repair them. Below command will give us list of the blocks:

To mark the corrupted blocks as unusable so system can recognize them, use the fsck command to check and repair the Linux filesystems:

Run given below command to check the device name:

Following result about system devices will appear showing us the size used by devices:

Alternatively, you can also use following command to check the current size of different partition:

This command will show you the disk usage of all the partitions in your system. Identify which partition has low disk space.

Type the following command and replace “/dev/sda2” with the partition name you want to check, and press Enter:

This command will check and repair the file system.

Note: By marking the corrupted blocks, your data will be reallocated from those blocks, and the system will perform a check on these sectors. This will replace all the corrupted blocks with functioning ones. The fsck command cannot be executed on the same filesystem being tested, so use a live CD to perform this task.

Reason 4: Limited Inode Count

Inodes are data structures used by the file system to store information about files and directories. Whenever a system runs out of disk space it also runs out of inodes.

Solution: Increase Inode Count

Find the current inodes count using command:

It is important to ensure that the column for available Inodes (Ifree) is not at zero. When all Inodes are used up, it is necessary to delete some old files from the base directory associated with the file location (Filesystem) to free up space.

Conclusion

The “No space left on device” error can occur in Linux because of corrupted blocks or deleted files that are still stored in the system. The first solution involves performing a daemon-reload, which releases the storage space that is being occupied by deleted files. The second solution is to use the fsck command to mark corrupted storage blocks as unusable, allowing the Linux OS to recognize them and repair them. By using these methods, you can resolve this error and avoid any issues related to storage space in the future.

About the author

Kashif

I am an Electrical Engineer. I love to write about electronics. I am passionate about writing and sharing new ideas related to emerging technologies in the field of electronics.

Читайте также:  Arch linux update all

Источник

bash: echo: write error: No space left on device

I am using Ubuntu Linux and using this as PHP server hosting the scripts and sites in /var/www/ . I am getting bash: echo: write error: No space left on device but there is huge space left on the device. I have found on google about this issue but no one suits my problem as people were getting this error after running some commands but I am getting it just after running gksudo nautilus yesterday, I am unable to umount any drive please suggest me what to do I have run $ sudo apt-get clean I have run $ sudo apt-get autoremove I am getting this message after running `$ df -k

Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda7 93956704 89329640 0 100% / udev 1989324 4 1989320 1% /dev tmpfs 799256 1076 798180 1% /run none 5120 0 5120 0% /run/lock none 1998132 3324 1994808 1% /run/shm overflow 1024 16 1008 2% /tmp /dev/sda2 240367612 192464952 47902660 81% /media/CE48787148785A63 bash: echo: write error: No space left on device 
Filesystem Size Used Avail Use% Mounted on /dev/sda7 90G 86G 0 100% / udev 1.9G 4.0K 1.9G 1% /dev tmpfs 781M 1.1M 780M 1% /run none 5.0M 0 5.0M 0% /run/lock none 2.0G 3.3M 2.0G 1% /run/shm overflow 1.0M 16K 1008K 2% /tmp /dev/sda2 230G 184G 46G 81% /media/CE48787148785A63 bash: echo: write error: No space left on device 

after running disk free command with -k and -h flags. It is clear that My device has ample space to work on. If someone has resolved the same issue please help me.

Источник

dd command error writing No space left on device [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

I am new to storage, trying to erase the data in the device ‘/dev/sdcd’ why should I get ‘No space left error’

[root@ dev]# dd if=/dev/zero of=/dev/sdcd bs=4k dd: error writing ‘/dev/sdcd’: No space left on device 1310721+0 records in 1310720+0 records out 5368709120 bytes (5.4 GB) copied, 19.7749 s, 271 MB/s [root@ dev]# ls -l /dev/null crw-rw-rw-. 1 root root 1, 3 Oct 27 01:35 /dev/null 

1 Answer 1

The /dev/zero device will continue to provide zeros for as long as you read from it, all the way to the heat death of the universe should your hardware last that long (a) .

With your command, you have no limiting clause like count= so it will continue to read from /dev/zero and write to /dev/sdcd until the latter runs out of space.

It will still be writing to the device so you can safely ignore the error at the end (although it may be a good idea to ensure the disk is actually an integral multiple of the block size to avoid the possibility of leaving sensitive information at the end).

(a) It may slow down somewhat in the final stages, as it becomes harder to get useful work out of a universe that’s losing all its energy gradients 🙂

Источник

Оцените статью
Adblock
detector