<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Archiwa Bad sectors - soban</title>
	<atom:link href="https://soban.pl/category/bad-sectors/feed/" rel="self" type="application/rss+xml" />
	<link>https://soban.pl/category/bad-sectors/</link>
	<description>IT, Linux, Servers, Security</description>
	<lastBuildDate>Tue, 12 Oct 2021 18:26:50 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>
	<item>
		<title>Checking the disk for errors and bad sectors</title>
		<link>https://soban.pl/checking-the-disk-for-errors-and-bad-sectors/</link>
		
		<dc:creator><![CDATA[soban]]></dc:creator>
		<pubDate>Tue, 12 Oct 2021 16:31:11 +0000</pubDate>
				<category><![CDATA[Bad sectors]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Proxmox]]></category>
		<guid isPermaLink="false">https://soban.pl/?p=108</guid>

					<description><![CDATA[<p>This script helps to notify me by e-mail about the condition of the disk. Remember to indicate the disk accordingly &#8211; in this case it is &#8220;/dev/sda&#8221; and change the e-mail address from &#8220;soban@soban.pl&#8221; to your own. Save the script in &#8220;/root/checkbadsector.sh&#8220;: You can also download it from https://soban.pl/bash/checkbadsector.sh: Remember to grant permission to perform [&#8230;]</p>
<p>Artykuł <a href="https://soban.pl/checking-the-disk-for-errors-and-bad-sectors/">Checking the disk for errors and bad sectors</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This script helps to notify me by e-mail about the condition of the disk. Remember to indicate the disk accordingly &#8211; in this case it is &#8220;<strong>/dev/sda</strong>&#8221; and change the e-mail address from &#8220;<strong>soban@soban.pl</strong>&#8221; to your own. Save the script in &#8220;<strong>/root/checkbadsector.sh</strong>&#8220;:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">#!/bin/bash
date &gt; /root/badsectortest.txt
badblocks /dev/sda -v &amp;&gt;&gt; /root/badsectortest.txt
hoursworkhdd=`smartctl --all /dev/sda | grep Power_On_Hours | awk '{print $10}'`
dayworkhdd=`expr $hoursworkhdd / 24`
yesworkhdd=`expr $dayworkhdd / 366`
echo -e "Hours working hdd:" &gt;&gt; /root/badsectortest.txt
echo -e $hoursworkhdd &gt;&gt; /root/badsectortest.txt
echo -e "Days working hdd:" &gt;&gt; /root/badsectortest.txt
echo -e $dayworkhdd &gt;&gt; /root/badsectortest.txt
echo -e "Years working hdd:" &gt;&gt; /root/badsectortest.txt
echo -e $yesworkhdd &gt;&gt; /root/badsectortest.txt
date &gt;&gt; /root/badsectortest.txt
cat /root/badsectortest.txt | /usr/bin/mail -s "badsector - `date`" soban@soban.pl</pre></div>



<p>You can also download it from <a href="https://soban.pl/bash/checkbadsector.sh" target="_blank" rel="noreferrer noopener">https://soban.pl/bash/checkbadsector.sh</a>:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># cd
# wget https://soban.pl/bash/checkbadsector.sh</pre></div>



<p>Remember to grant permission to perform it:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># chmod +x /root/checkbadsector.sh</pre></div>



<p>On my server I added it once a month so that it would be performed periodically in the crontab:</p>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag"># crontab -l | grep checkbadsector
30 17 20 * * /root/checkbadsector.sh &gt; /dev/null 2&gt;&amp;1</pre></div>



<p>You should receive an email similar to the one below:</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="751" height="443" src="https://soban.pl/wp-content/uploads/2021/10/image-24.png" alt="" class="wp-image-111" srcset="https://soban.pl/wp-content/uploads/2021/10/image-24.png 751w, https://soban.pl/wp-content/uploads/2021/10/image-24-300x177.png 300w" sizes="(max-width: 751px) 100vw, 751px" /></figure>



<p>Good luck and I wish you no errors!</p>
<p>Artykuł <a href="https://soban.pl/checking-the-disk-for-errors-and-bad-sectors/">Checking the disk for errors and bad sectors</a> pochodzi z serwisu <a href="https://soban.pl">soban</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
