
Facing issues with a USB drive that inexplicably becomes read-only on your Linux system? This common problem can prevent you from writing, deleting, or modifying files on the stick. Fortunately, several straightforward steps can help you diagnose and resolve the issue. Let’s dive into how to regain write access to your USB storage.
First, ensure the problem isn’t a simple physical mechanism. Many USB drives, especially older ones or SD card adapters, have a small physical write-protection switch. Check the side of the USB stick or adapter and make sure this switch is in the unlocked or write-enabled position. It’s a simple check, but easily overlooked.
If there’s no physical switch, the issue is likely software or filesystem related. Start by checking the system messages kernel ring buffer for clues. Open a terminal and type: dmesg | tail. Look for lines related to the USB drive when you plugged it in. Error messages here can indicate why the system mounted it as read-only, often due to detected filesystem corruption.
Next, you need to identify the specific device name your system assigned to the USB stick. Commands like lsblk or fdisk -l are useful for this. Plug in the drive and run one of these commands again, observing the output to see which new device, typically /dev/sdX
(where X is a letter like b, c, d etc.), or its partitions like /dev/sdX1
, appears. Note this name carefully.
Before attempting repairs, you must unmount the drive. Even if it appears read-only, it might still be mounted. Use the umount command followed by the device partition name. For example, if your partition is /dev/sdc1
, run: sudo umount /dev/sdc1. If it’s mounted multiple times or you’re unsure of the mount point, findmnt /dev/sdX
(where X is the device letter) can help identify mount points to unmount. Sometimes unmounting the entire device (sudo umount /dev/sdc) is necessary if partitions aren’t listed or recognized correctly.
The most frequent cause is a damaged or inconsistent filesystem. The fsck (filesystem check) utility is your primary tool here. Run fsck on the device partition, not the entire device /dev/sdX
. For example, for /dev/sdc1
: sudo fsck /dev/sdc1. The system might prompt you to fix errors. Use the -y flag (e.g., sudo fsck -y /dev/sdc1) to automatically confirm fixes, but be aware this can sometimes make incorrect assumptions. Running without -y
first is safer if you understand the prompts. Note that you need the correct fsck variant for the filesystem type (e.g., fsck.vfat
or fsck.ext4
). Running fsck
without specifying the type often works as it detects it, but explicitly using the type (sudo fsck.vfat -y /dev/sdc1) is also an option.
If fsck reports it cannot write to the drive, or if the issue persists after running it, the drive might be in a state where it’s forcing itself to be read-only, often indicating impending hardware failure. In some cases, a low-level write test or even reformatting can reset this state, though data will be lost with formatting. To attempt reformatting (use with extreme caution as this erases everything), identify the device name (e.g., /dev/sdc
) and use a command like sudo mkfs.vfat /dev/sdc1 for a FAT32 partition or sudo mkfs.ext4 /dev/sdc1 for an Ext4 partition. You might need to create a new partition table first using tools like fdisk, parted, or gparted.
Occasionally, permissions issues can mimic a read-only state for non-root users, although this typically wouldn’t affect the entire drive at a filesystem level. Ensure your user has write permissions to the mount point directory after the drive is mounted.
If none of these steps work, especially if dmesg or fsck report persistent write errors, it’s possible the USB drive itself is failing and has entered a permanent read-only mode to protect existing data. In such cases, data recovery might be possible, but writing to the drive is no longer feasible, and replacing the drive is the necessary next step.
This detailed approach covers the most common scenarios and provides powerful command-line tools to diagnose and fix read-only USB drives on Linux, often restoring full write access.
Source: https://www.tecmint.com/fix-usb-read-only-linux/