Solving the On battery power, so skipping file system check Error in Debian Systems

Welcome to my comprehensive guide on resolving a common issue encountered on Debian systems, particularly on laptops where the system decides to skip file system checks when it detects that the device is running on battery power. This can sometimes be a problem, especially when you need to ensure the integrity of your file system but are not connected to a power supply.

<h2>Understanding the Problem</h2>
<p>
The "On battery power, so skipping file system check" error occurs because the operating system is designed to avoid potentially long-running processes that could drain the battery quickly. File system checks can be time-consuming and resource-intensive, so by default, system maintenance tasks such as these are skipped when on battery power.
</p>

<p>
However, this safeguard can sometimes prevent necessary file system maintenance routines, leading to potential issues with file system integrity if not addressed properly over time. Therefore, it is important to override this behavior when you need to perform file system checks without being plugged in.
</p>

<h2>Forcing a File System Check</h2>
<p>
If you indeed need to run a file system check while on battery, you can force the system to perform it. To do this, you will have to bypass the condition that checks for power source or disable it temporarily.
</p>

<p>
One way to do this is by tricking the system into thinking it is not on battery power. However, this is not an advisable or practical approach. Instead, we should look at configuring the system to allow the check while on battery power.
</p>

<h3>Using 'tune2fs' and 'fsck'</h3>
<p>
The <code>tune2fs</code> command can be used to adjust various tunable filesystem parameters on Linux systems with the ext2, ext3, or ext4 file systems. We can use this command to force a file system check on the next reboot regardless of the power source.
</p>

<p>Here's how to do this:</p>

<code># Forcibly enable file system checks on the next reboot
$ sudo tune2fs -c 1 /dev/sdXY
</code>

<p>
In the command above, replace <code>/dev/sdXY</code> with the actual device name of your filesystem (e.g., <code>/dev/sda1</code>).
</p>

<p>
The <code>-c</code> option followed by a number tells <code>tune2fs</code> to set the maximum mount count to that number. Setting it to '1' forces a check on the next mount, which would happen on reboot.
</p>

<h3>Disabling Check on Battery Power Condition</h3>
<p>
Another approach involves disabling the condition that prevents the file system check when on battery power. For systems that use the <code>systemd</code> service <code>[email protected]</code> to perform file systems checks during boot, you can edit its configuration to change this behavior.
</p>

<p>To override the default behavior of <code>[email protected]</code>, follow these steps:</p>

<code># Create an override configuration file for [email protected]
$ sudo systemctl edit [email protected]
</code>

<p>
In the editor that opens, add the following lines:
</p>

<code>[Service]
Environment=SYSTEMD_FSCK_FORCE_FSCK=no
</code>

<p>
This will disable the check that skips file system checks when on battery power.
</p>

<p>After adding and saving the configuration, reload the system daemon:</p>

<code>$ sudo systemctl daemon-reload
</code>

<p>Now, your system should perform the file system check on the next boot irrespective of the power source.</p>

<h2>Conclusion</h2>
<p>
It's crucial to ensure that your file system is regularly checked for integrity, especially if your system frequently experiences improper shutdowns or power issues. While the default behavior to skip checks when on battery power is generally a good practice for power conservation, there are times when you may need to override this. With the techniques described above, you can manually initiate a file system check or configure your system to ignore the battery power state when performing these checks.
</p>

<p>
Remember that these steps should be used with caution and primarily when you are sure that your battery has enough charge to complete the process without shutting down abruptly.
</p>

<p>Stay tuned for more system administration tips and tricks. Happy computing!</p>

Author: admin

Leave a Reply

Your email address will not be published. Required fields are marked *