CMD repair garbage USB stick w/ fsck. About soft replugging

· EOG, like EOF


Table of Contents

Q: USB still 'ro' #

i did sudo fsck.fat -av /dev/sdX1 2 times but i couldnt write to it even after remount rw. And the label was still unchanged. Error:

sudo mount -o remount,rw /dev/sdj1 /mnt/0015sandisk/ mount: /mnt/0015sandisk: mount point not mounted or bad option.

BUT: afer unplugginin and replugging all is as whished

A: Yeah, FAT can be super weird after a heavy fsck run. #

✔ Why remount didn’t work earlier #

After a serious repair pass, the kernel sometimes keeps the filesystem marked as “dirty” and read-only until a fresh mount happens.

This can cause:

Because even though fsck fixed the disk, the in-memory mount state was still locked read-only.

✔ Unplug → Replug #

forces:

That’s why everything was suddenly fine — the kernel finally accepted the repaired metadata.

✔ Why the label suddenly appeared correct #

The new, cleanly read boot sector + root dir let your system update:

/dev/disk/by-label

The old garbage label was just cached from the broken mount.

Q: can we tell kernel to do what needed -- w/o ,maulally replugging? only software sided? #

A: Yes you can do everything the kernel needs without physically replugging the USB stick.

There are several safe software-only ways. Here are the three best ones, depending on how deep you want to go.

1. Clean unmount + block-device refresh (simple, works 90%) #

After running fsck.fat, force the kernel to “forget” and reload the device:

1sudo umount 			 /dev/sdX
2sudo blockdev --rereadpt /dev/sdX

This tells the kernel:

Equivalent to a soft “reinsert”. After that, just mount again:

1sudo mount /dev/sdj1 /mnt/0015sandisk

2. Use sysfs to "soft-reset" USB device #

This exactly mimics a physical unplug/replug.

1ls -l /sys/block/sdj
2#=> /sys/block/sdj → ../../devices/pci0000:00/.../usb2/2-1/2-1:1.0/host6/...
3
4# (de)authorize
5echo 0 | sudo tee /sys/bus/usb/devices/2-1/authorized
6sleep 1
7echo 1 | sudo tee /sys/bus/usb/devices/2-1/authorized

3. Trigger a USB bus reset (strongest software option) #

Perform real USB-level reset → exact match to unplug+replug:

1lsusb
2#=> Bus 002 Device 005: SanDisk Corp.
3sudo usbreset /dev/bus/usb/002/005

If usbreset is missing, create it:

 1cat <<EOF | gcc -o usbreset -x c -
 2#include <stdio.h>
 3#include <stdlib.h>
 4#include <fcntl.h>
 5#include <unistd.h>
 6#include <linux/usbdevice_fs.h>
 7#include <sys/ioctl.h>
 8int main(int argc, char **argv) {
 9    int fd = open(argv[1], O_WRONLY);
10    ioctl(fd, USBDEVFS_RESET, 0);
11}
12EOF

Why these work #

When FAT is heavily repaired, the in-kernel VFS layer may:

A soft reset forces the kernel to:

❤️ TL;DR — Best , easy & safe #

1sudo umount              /dev/sdX1
2sudo blockdev --rereadpt /dev/sdX
3sudo mount               /dev/sdX1 /mnt/0015sandisk

If that fails:

usbreset works 100% and is safe.


I can make you a single command like:

1sudo refresh-usb sdj

that automatically unmounts, resets USB, and remounts — no thinking needed.

last updated: