Software⏱️ 3 min read📅 2026-06-11

How to Fix: Resizing a partition in Linux - Bad magic number in super-block error

Linux partition resizing issue with bad magic number in super-block error.

Quick Answer: Use the `resize2fs -F` option to force resize2fs to recover from a corrupted superblock.

The 'Bad magic number in super-block' error occurs when trying to resize an ext4 partition in Linux using parted and resize2fs. This issue affects users who attempt to resize their partitions without proper precautions, leading to data loss or corruption.

Resizing a partition can be a frustrating experience for many Linux users, especially when dealing with errors like the 'Bad magic number in super-block' error. In this guide, we will walk you through two methods to safely resize your ext4 partition and avoid data loss.

🛑 Root Causes of the Error

  • The primary reason for this error is that parted's `mkpart` command does not properly handle large file systems when resizing. When the `mkpart` command tries to create a new partition, it may overwrite or corrupt the existing superblock, resulting in a 'Bad magic number' error.
  • Another possible cause of this error is that the existing partition table on your disk has become corrupted or damaged, leading to an invalid superblock. In some cases, this can be due to improper shutdowns, power failures, or other hardware-related issues.

🔧 Proven Troubleshooting Steps

Using parted and mkpart with a smaller size

  1. Step 1: Open a terminal as the root user and run `parted` to list your disk partitions.
  2. Step 2: Identify the partition you want to resize by its device name (e.g., `/dev/sda2`). Note that we will be using the `mkpart` command, which requires a smaller size than the original partition.
  3. Step 3: Run `parted` commands to create a new partition with a smaller size, as shown below: `rm 2`, `mkpart primary ext4 41GB 500GB`, and then `q` to exit.

Using fsck and mkfs

  1. Step 1: Boot into the Linux rescue mode by running `sudo init 3` (or your preferred method). This will load the rescue environment and allow you to access the file system.
  2. Step 2: Run `fsck -t ext4 /dev/sda2` to check the integrity of the superblock. If the command completes successfully, proceed with the next step.

✨ Wrapping Up

To safely resize an ext4 partition in Linux without data loss, use one of the two methods outlined above. By following these steps and taking necessary precautions, you can avoid the 'Bad magic number in super-block' error and ensure a successful partition resize.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions