|
| 1 | +--- |
| 2 | +tags: ["linux", "ntfs", "troubleshooting", "ntfsfix", "systemd"] |
| 3 | +categories: ["linux", "troubleshooting"] |
| 4 | +title: "When the Power Dies: Rescuing an NTFS Drive on Linux" |
| 5 | +image: |
| 6 | + path: /assets/img/2026-07-01/main.jpg |
| 7 | + alt: A hard drive being pulled back from the brink. |
| 8 | +--- |
| 9 | + |
| 10 | +Hey everyone, your friendly neighborhood developer _is_ back-and this time with a small horror story that had a happy ending. |
| 11 | + |
| 12 | +My PC lost power out of nowhere. When it booted back up, the big NTFS drive I keep all my projects on simply refused to show up. The folder where it should live was just… empty. Cue the mild panic. Let's walk through how I got everything back, because the fix is easier than the scare suggests. |
| 13 | + |
| 14 | +## The Symptom |
| 15 | + |
| 16 | +The drive is set to auto-mount at a folder in my home directory. But after the reboot, that folder was empty and the disk was nowhere to be seen. Digging into the system logs, one line stood out: |
| 17 | + |
| 18 | +```text |
| 19 | +mount: wrong fs type, bad option, bad superblock on /dev/sdX2 |
| 20 | +``` |
| 21 | + |
| 22 | +Scary words. But here's the good news: **this is usually not a broken disk.** |
| 23 | + |
| 24 | +## What Actually Happened |
| 25 | + |
| 26 | +When you pull the power on a running machine, NTFS doesn't get the chance to close up shop cleanly. So it flips a little **"dirty" flag** that means _"I wasn't shut down properly, check me before you trust me."_ |
| 27 | + |
| 28 | +Linux's built-in `ntfs3` driver sees that flag and politely refuses to mount the drive. It's not being difficult-it's protecting your files from getting scrambled further. Think of it like a shop with a "CLOSED - INVENTORY IN PROGRESS" sign on the door. The stuff inside is fine; you just can't walk in yet. |
| 29 | + |
| 30 | +First, I confirmed the disk was actually there and healthy: |
| 31 | + |
| 32 | +```bash |
| 33 | +lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINT |
| 34 | +``` |
| 35 | + |
| 36 | +Sure enough, the drive showed up with all its size and NTFS label intact. The data wasn't gone-it was just locked behind that dirty flag. |
| 37 | + |
| 38 | +## The Fix |
| 39 | + |
| 40 | +The tool for the job is `ntfsfix`, which comes with the `ntfs-3g` package. If you don't have it: |
| 41 | + |
| 42 | +```bash |
| 43 | +sudo pacman -S ntfs-3g |
| 44 | +``` |
| 45 | + |
| 46 | +Before changing anything, I did a **dry run** with `-n`. This looks but doesn't touch: |
| 47 | + |
| 48 | +```bash |
| 49 | +sudo ntfsfix -n /dev/sdX2 |
| 50 | +``` |
| 51 | + |
| 52 | +It reported a tiny mismatch in the drive's internal file table (`$MFT` vs its backup copy `$MFTMirr`)-a classic power-loss hiccup, and exactly what `ntfsfix` is built to repair. Good. Time to do it for real: |
| 53 | + |
| 54 | +```bash |
| 55 | +sudo ntfsfix -d /dev/sdX2 |
| 56 | +``` |
| 57 | + |
| 58 | +The `-d` clears the dirty flag once the drive is fixed. A few seconds later: |
| 59 | + |
| 60 | +```text |
| 61 | +NTFS partition /dev/sdX2 was processed successfully. |
| 62 | +``` |
| 63 | + |
| 64 | +_Chef's kiss._ |
| 65 | + |
| 66 | +## The Last Little Gotcha |
| 67 | + |
| 68 | +I tried to open the folder again and… still empty. Huh? |
| 69 | + |
| 70 | +Turns out the auto-mount had failed so many times during my panic that `systemd` gave up and put it in a "failed" state. Once a unit hits that wall, it stops trying until you tell it to wake up: |
| 71 | + |
| 72 | +```bash |
| 73 | +sudo systemctl reset-failed 'home-*-Projects.*' |
| 74 | +sudo systemctl restart 'home-*-Projects.automount' |
| 75 | +``` |
| 76 | + |
| 77 | +And there they were-every last file, exactly where I left them. 🎉 |
| 78 | + |
| 79 | +## Bonus: Make Sure Nothing Got Hurt |
| 80 | + |
| 81 | +Once it was mounted, I wanted to be _sure_ the files were actually readable, not just visible. A quick trick is to read every file and send it into the void-if anything is unreadable, it'll shout: |
| 82 | + |
| 83 | +```bash |
| 84 | +tar -cf /dev/null --ignore-failed-read -C ~/Projects . |
| 85 | +``` |
| 86 | + |
| 87 | +No errors. Every file survived the blackout. |
| 88 | + |
| 89 | +## Summary |
| 90 | + |
| 91 | +If a power cut ever eats your NTFS drive on Linux, don't panic: |
| 92 | + |
| 93 | +- **`bad superblock` usually means "dirty," not "dead."** |
| 94 | +- Confirm the disk is really there with `lsblk`. |
| 95 | +- Peek first with `sudo ntfsfix -n`, then fix with `sudo ntfsfix -d`. |
| 96 | +- If auto-mount is sulking, `reset-failed` and `restart` it. |
| 97 | +- Read your files back to confirm they're healthy. |
| 98 | + |
| 99 | +Oh, and one more thing: this is your friendly reminder to consider a **UPS**. No filesystem loves a sudden power cut, and a cheap battery backup buys you the few seconds needed for a clean shutdown. Stay safe out there! |
0 commit comments