<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Smart on inetshell</title><link>https://inet.sh/en/tags/smart/</link><description>Recent content in Smart on inetshell</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sat, 26 Sep 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://inet.sh/en/tags/smart/index.xml" rel="self" type="application/rss+xml"/><item><title>badblocks on large disks: 'Value too large for defined data type (must be 32-bit value)'</title><link>https://inet.sh/en/posts/linux/badblocks-large-disks-32-bit/</link><pubDate>Sat, 26 Sep 2026 00:00:00 +0000</pubDate><guid>https://inet.sh/en/posts/linux/badblocks-large-disks-32-bit/</guid><description>badblocks dies instantly on disks over 4 TB with &amp;#39;Value too large for defined data type invalid end block: must be 32-bit value&amp;#39; because it counts blocks in a 32-bit integer. With -b 4096 it reaches 16 TiB and -b 8192 beyond. Which mode to use (read, -n, -w), how long it takes, and when a long SMART test is the better tool.</description><content:encoded><![CDATA[<h2 id="tldr">TL;DR</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">badblocks -b <span class="m">4096</span> -sv /dev/sdX          <span class="c1"># read-only: touches no data</span>
</span></span><span class="line"><span class="cl">badblocks -b <span class="m">4096</span> -nsv /dev/sdX         <span class="c1"># non-destructive read-write (twice as slow)</span>
</span></span><span class="line"><span class="cl">badblocks -b <span class="m">4096</span> -wsv /dev/sdX         <span class="c1"># DESTRUCTIVE: writes patterns and wipes the whole disk</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p><code>-b 4096</code> raises the ceiling from 4 TiB to 16 TiB. For disks over 16 TiB, <code>-b 8192</code>.</p>
<h2 id="the-error">The error</h2>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">badblocks: Value too large for defined data type invalid end block (7814026584): must be 32-bit value
</span></span></code></pre></td></tr></table>
</div>
</div><p>It shows up before a single sector is read. The number is the disk&rsquo;s block count at the default block size (1 KiB): 7,814,026,584 blocks is 8 TB.</p>
<h2 id="why-it-happens">Why it happens</h2>
<p><code>badblocks</code> numbers blocks with a <strong>32-bit</strong> integer: at most 4,294,967,295. With the default 1 KiB block that is <strong>4 TiB</strong> (about 4.4 TB as sold); any bigger disk overflows the counter. Raising the block size multiplies the ceiling:</p>
<table>
  <thead>
      <tr>
          <th><code>-b</code></th>
          <th>Ceiling</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td>1024 (default)</td>
          <td>4 TiB</td>
      </tr>
      <tr>
          <td>4096</td>
          <td>16 TiB</td>
      </tr>
      <tr>
          <td>8192</td>
          <td>32 TiB</td>
      </tr>
      <tr>
          <td>16384</td>
          <td>64 TiB</td>
      </tr>
  </tbody>
</table>
<p>4096 is also the natural size: it matches the physical sector of current disks (<code>blockdev --getpbsz /dev/sdX</code> confirms it) and ext4&rsquo;s default block, which is what matters if you are going to hand the list to <code>e2fsck</code>.</p>
<h2 id="which-mode-to-use">Which mode to use</h2>
<table>
  <thead>
      <tr>
          <th>Mode</th>
          <th>What it does</th>
          <th>When</th>
      </tr>
  </thead>
  <tbody>
      <tr>
          <td><code>-sv</code> (default)</td>
          <td>Reads the whole disk once</td>
          <td>Disk with data; quick check</td>
      </tr>
      <tr>
          <td><code>-nsv</code></td>
          <td>Reads, writes a pattern, restores the original, block by block</td>
          <td>Disk with data you want to test for writes. Unmounted; a power cut halfway loses the block in flight</td>
      </tr>
      <tr>
          <td><code>-wsv</code></td>
          <td>Four write passes (0xaa, 0x55, 0xff, 0x00) with verification</td>
          <td>New or second-hand disk <strong>before</strong> putting data on it (<em>burn-in</em>)</td>
      </tr>
  </tbody>
</table>
<p>Time: one read pass takes capacity ÷ speed (an 8 TB disk at 180 MB/s, about 13 hours); <code>-w</code> is eight passes (four writes and four reads), several days on big disks. Run it inside <code>tmux</code> or <code>screen</code>.</p>
<p>Useful options:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">badblocks -b <span class="m">4096</span> -c <span class="m">1024</span> -wsv /dev/sdX          <span class="c1"># -c: blocks per pass (more memory, somewhat faster)</span>
</span></span><span class="line"><span class="cl">badblocks -b <span class="m">4096</span> -sv -o /root/sdX-bad.txt /dev/sdX   <span class="c1"># -o: list of bad blocks</span>
</span></span><span class="line"><span class="cl">e2fsck -f -l /root/sdX-bad.txt /dev/sdX1              <span class="c1"># mark them on an ext4 (same -b as the fs block)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><h2 id="what-a-modern-disk-does-not-tell-badblocks">What a modern disk does not tell badblocks</h2>
<p>Disks remap defective sectors on their own: if <code>badblocks</code> finds any at all, the disk has already used up, or is using up, its spare pool. Before and after any pass, look at SMART:</p>
<div class="highlight"><div class="chroma">
<table class="lntable"><tr><td class="lntd">
<pre tabindex="0" class="chroma"><code><span class="lnt">1
</span><span class="lnt">2
</span><span class="lnt">3
</span></code></pre></td>
<td class="lntd">
<pre tabindex="0" class="chroma"><code class="language-shell" data-lang="shell"><span class="line"><span class="cl">smartctl -A /dev/sdX <span class="p">|</span> grep -E <span class="s1">&#39;Reallocated_Sector|Current_Pending|Offline_Uncorrectable&#39;</span>
</span></span><span class="line"><span class="cl">smartctl -t long /dev/sdX          <span class="c1"># long test inside the disk itself, no bus traffic</span>
</span></span><span class="line"><span class="cl">smartctl -l selftest /dev/sdX      <span class="c1"># result once it finishes (hours)</span>
</span></span></code></pre></td></tr></table>
</div>
</div><p>To decide whether a second-hand disk joins the pool, <code>smartctl -t long</code> plus attributes 5, 197, and 198 say more than <code>badblocks</code> in a fraction of the time. <code>badblocks -w</code> still makes sense as a <em>burn-in</em> for a new disk, because it forces writes over the whole surface.</p>
<h2 id="traps">Traps</h2>
<ul>
<li><strong><code>-w</code> on the wrong device wipes the wrong disk.</strong> <code>lsblk -o NAME,SIZE,MODEL,SERIAL</code> before typing the command, and never on a mounted one.</li>
<li><strong>USB-SATA bridges that reset</strong> halfway through a multi-day pass: connect the disk to SATA directly if you can. A bridge reset aborts the test and leaves no partial result.</li>
<li><strong><code>mkfs.ext4 -c</code></strong> runs <code>badblocks</code> for you with the filesystem&rsquo;s block size (4 KiB), so it does not overflow; but it is a <code>mkfs</code>, destructive by definition.</li>
<li><strong>HPE Smart Array controllers</strong>: disks behind the controller are queried over SMART with <code>smartctl -d cciss,N /dev/sda</code>; <code>badblocks</code> sees the logical volume, not each disk.</li>
<li><strong>On ZFS</strong> do not run <code>badblocks</code> on a pool member: <code>zpool scrub</code> does the check with real data checksums.</li>
</ul>
<p>References: <a href="https://wiki.archlinux.org/title/Badblocks">badblocks</a> on the ArchWiki and <code>man 8 badblocks</code>.</p>
]]></content:encoded></item></channel></rss>