You are not logged in.
Pages: 1
Hello, I have a 16 GB USB 3.0 flashdrive and I want to format it but whenever I try to do so, I get the following output:
cannot open /dev/sdb: Read-only file system
I have tried commands like 'dd', 'fdisk', cfdisk', 'sfdisk', 'mkfs.vfat' but I always get the same output.
What do I do to get this corrected. [I have unmounted the USB drive before trying the above mentioned commands to format it, but to no avail].
Thanks!
Offline
Does the USB stick have a hardware switch that locks it to read-only mode?
If not, please post the output of
mount | grep "on /dev"
as well as the journal from an affected session.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
There is no hardware switch to lock it into read only mode.
The output of
mount | grep "on /dev"
dev on /dev type devtmpfs (rw,nosuid,relatime,size=4035504k,nr_inodes=1008876,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
mqueue on /dev/mqueue type mqueue (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
And the output of
fdisk -l
Disk /dev/sdb: 14.5 GiB, 15504900096 bytes, 30283008 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
Thanks!
Offline
Offline
Another newbie here, so not sure if this will help
But what file system are you trying to format in? If for example it is NTFS, have you installed the ntfs-3g package?
I had a similar issue writing to a USB stick that was only mounting in read only mode
Offline
Sanity check, you are trying to format the drive with root privileges right? Like either in a su'd console or with the sudo command?
Offline
Yes, I am trying to format it by being root user (or su).
I am trying to format it with FAT filesystem and I am using the command:
mkfs.vfat
I tried using 'hdparm' as follows:
# hdparm -r0 /dev/sdb
/dev/sdb:
setting readonly to 0 (off)
readonly = 0 (off)
But when I try to format it I again get the error:
Could not open /dev/sdb: Read-only file system
Thanks!
Offline
Sanity check: you are trying to format the partition (presumably /dev/sdb1) and not the device (/dev/sdb)?
If so, can you delete and recreate the partition?
Offline
There is no '/dev/sdbx'. It only shows '/dev/sdb' when I try to use the 'fdisk -l' command.
The modified output of 'fdisk -l' is:
Disk /dev/sdb: 14.5 GiB, 15504900096 bytes, 30283008 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
I cannot delete and recreate the partition. When I try to do so:
fdisk /dev/sdb
It gives the output-
fdisk: cannot open /dev/sdb: Read-only file system
Thanks
Offline
remove the usb drive, wait a few seconds then plug it in again.
post dmesg | tail -n 25 , partx -s /dev/sdb and lsblk output .
Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.
clean chroot building not flexible enough ?
Try clean chroot manager by graysky
Offline
The outputs of 'dmesg', 'partx' and 'lsblk' are as follows:
tail -n 25
[ 43.213293] fuse init (API version 7.25)
[ 165.433200] usb 1-3: new high-speed USB device number 5 using xhci_hcd
[ 165.670015] usb-storage 1-3:1.0: USB Mass Storage device detected
[ 165.673509] scsi host4: usb-storage 1-3:1.0
[ 165.673654] usbcore: registered new interface driver usb-storage
[ 165.910520] usbcore: registered new interface driver uas
[ 166.677402] scsi 4:0:0:0: Direct-Access SanDisk SanDisk Ultra PMAP PQ: 0 ANSI: 6
[ 166.677937] sd 4:0:0:0: [sdb] 30283008 512-byte logical blocks: (15.5 GB/14.4 GiB)
[ 166.678136] sd 4:0:0:0: [sdb] Write Protect is off
[ 166.678140] sd 4:0:0:0: [sdb] Mode Sense: 2b 00 00 08
[ 166.678345] sd 4:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 166.961737] sdb:
[ 166.962365] sd 4:0:0:0: [sdb] Write Protect is on
[ 166.962371] sd 4:0:0:0: [sdb] Mode Sense: 2b 00 80 08
[ 166.962567] sd 4:0:0:0: [sdb] Attached SCSI removable disk
# partx -s /dev/sdb
partx: /dev/sdb: failed to read partition table
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 30G 0 part /
├─sda2 8:2 0 8G 0 part [SWAP]
└─sda3 8:3 0 893.5G 0 part /home
sdb 8:16 1 14.5G 1 disk /run/media/<user>/Movies
sr0 11:0 1 1024M 0 rom
Thanks!
Offline
Please use code, not bold.
Offline
1. As philo says, please use “code” tags, not “b” tags, when posting program output. It preserves formatting and makes it easier to read.
2. You mount disk partitions, not disks - so why is /dev/sdb mounted?
I'm guessing you've got some sort of misconfigured automounter.
Correct your automounter to not mount /dev/sdb and then unmount the disk.
Can you now run fdisk/partx? If not, try replugging.
Offline
Ok, will use 'code' tag and not 'b' tag. Sorry.
When mounting other USB drives, the OS mounts them correctly. In case of this particular USB drive, this is happening. When I plug in the device, it opens the drive and I can see the contents in it. I can copy it's contents but cannot write to it.
I tried unmounting the drive and manually mounting it to a folder named 'Mount_USB' but I am getting the following error:
# mkdir Mount_USB
# mount /dev/sdb Mount_USB/
mount: /dev/sdb is write-protected, mounting read-only
I used this USB drive in a laptop where a WD external encrypted drive was also plugged in and it's (WD external HDD) contents were unlocked using the GUI of WD's drive unlocking software. I think that this error is occurring after this incident. Do you think this has got something to do with the errors I am getting?
Offline
Formatting a mounted device is a bad idea, so always ensure to unmount it first.
The device is considered write protected.
This is either a misinterpretation of the usb stack in the kernel or the device actually is write only.
1. Try another USB slot. Try all you have and avoid any adapters/readers
2. Can you write into it from a windows box?
In case of 2:
Check file permissions "stat /dev/sdb" and try to alter them "chmod +w /dev/sdb" (notice that sdb must of course match the actually troubling device and not some other usb key attached ;-)
Then try again.
In case it's a kernel bug, this might (or not) be due to some FS junk in the first sector of the device. You might be better of creating a partition table (using either fdisk or cfdisk)
Offline
Generally, I don't think that the issue is caused by the FS being directly on /dev/sdX rather than a partition, or the FS not having been unmounted properly, or whatever else...
If even fdisk (and similar) fail, it becomes more of a hardware issue.
I tried using 'hdparm' as follows:
# hdparm -r0 /dev/sdb
/dev/sdb: setting readonly to 0 (off) readonly = 0 (off)
What was the output of `hdparm -r` before you explicitly turned off read-only mode? If it was on, does it turn back on when you reconnect it?
Last edited by ayekat (2016-10-03 06:30:57)
Offline
chmod +w /dev/sdb
did not work.
hdparm -r /dev/sdb
/dev/sdb:
readonly = 1 (on)
hdparm /dev/sdb
/dev/sdb:
SG_IO: bad/missing sense data, sb[]: 70 00 05 00 00 00 00 0a 00 00 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
multcount = 0 (off)
readonly = 1 (on)
readahead = 256 (on)
geometry = 14786/64/32, sectors = 30283008, start = 0
Thanks
Offline
Pages: 1