LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   What makes a usb stick from Read write -> read only (https://www.linuxquestions.org/questions/linux-newbie-8/what-makes-a-usb-stick-from-read-write-read-only-4175695546/)

andrewysk 05-24-2021 11:28 AM

What makes a usb stick from Read write -> read only
 
I am having Endeavorous linux KDE "can't write configuration file" issue.
Hence doing some manual copy of data from from /home to a usb drive.
I created a folder on the usbstick on the problematic laptop and transferred some data over 1 time, then paste it to a desktop.
Plugged the same usbstick the 2nd time on the same problematic laptop, wanted to create another folder to do data transfer again.. but this time it said :
Code:

mkdir: cannot create directory 'folder': Read-only file system
Why did it changes mounting of my usbstick to read-only file system instead of normal Read-write file system ? What made the decision ?

I have to do :
Code:

sudo mount -o remount,rw '/run/media/user/usbstick'
so that it changes mounting to Read-write file system .
Only after this i can create a new folder in the usbstick.

My question is why it changes ? What causes it to change ? is this the same thing that causes my current issue "can't write configuration file" ?

Thanks

teckk 05-24-2021 11:52 AM

What are you using to mount that usb device? Are you un-mounting it before you remove it? Does user have full mount permissions. Are you mounting as user or root? What kind of permissions does user have? Are you using an auto mounter?

Quote:

My question is why it changes ? What causes it to change ?
How do you have your box setup? Are you pulling it out without umounting it, sticking it in again and getting a new device node which is read only?

yancek 05-24-2021 02:16 PM

A common reason for that error is a corrupt filesystem which can sometimes be repaired. First thing we would need to know is what filesystem is on the usb drive. Also answering all the questions in post 2 will provide helpful information.

In your other thread, you indicate that you were having problems editing a configuration file with vi, When you edited it the first time, did you close the file properly?

jamison20000e 05-24-2021 04:08 PM

Code:

man chmod
:)

DavidMcCann 05-25-2021 10:42 AM

My practice here has always been to
1. start with a Linux format on the usb stick — less likely to cause trouble
2. if it goes read-only, use fsck
3. if it does it again, reformat
4. if it happens for the third time, dump it.

sofasurfer 05-25-2021 12:42 PM

Well, you learn something new every day. My mp3 player, when inserted into the pc, sometimes does not allow deletion of files or does not allow transfer of files. So are you saying the reason is because I always just yank it out when I'm done with it? I need to unmount it first or use the eject/remove button?

hazel 05-25-2021 12:57 PM

Quote:

Originally Posted by sofasurfer (Post 6253851)
Well, you learn something new every day. My mp3 player, when inserted into the pc, sometimes does not allow deletion of files or does not allow transfer of files. So are you saying the reason is because I always just yank it out when I'm done with it? I need to unmount it first or use the eject/remove button?

Yes, of course. The kernel saves up disk writes in its buffers to do when it's not particularly busy. If you don't unmount a plug-in device properly, it gets out of sync.

teckk 05-25-2021 01:15 PM

Quote:

So are you saying the reason is because I always just yank it out when I'm done with it? I need to unmount it first or use the eject/remove button?
Depends on the file system how much trouble you'll have doing that.

Even on a windows machine, with a external ntfs volume, you are suppose to click on that icon in the taskbar, "remove drive safely", before you pull it out, or it'll do it's checkdisk the next time you stick it in. And windows can fix it's own file system just fine. On a linux machine you need to make sure it is unmounted before removing, or it won't mount again. And ntfs-tools probably won't help.

Not something that you should do on purpose but, you can pull a FAT or EXT4 drive out in the middle of a write and it won't hurt it, other than the file that you were copying will be corrupt. But you'll have a hung mount. You'll probably need to do a force umount. That is what mount and df are for.

andrewysk 05-27-2021 04:41 PM

Quote:

Originally Posted by teckk (Post 6253555)
What are you using to mount that usb device? Are you un-mounting it before you remove it? Does user have full mount permissions. Are you mounting as user or root? What kind of permissions does user have? Are you using an auto mounter?


How do you have your box setup? Are you pulling it out without umounting it, sticking it in again and getting a new device node which is read only?

I plugged the usb stick in, it auto mounted (default). I don't need to mount it.
I do not unmount usb stick, just when it is no doing data transfer, just unplug it. I always do that, never a problem before. I also do that to my manjaro kde desktop, no problem what so ever.

andrewysk 05-27-2021 04:43 PM

Quote:

Originally Posted by yancek (Post 6253598)
A common reason for that error is a corrupt filesystem which can sometimes be repaired. First thing we would need to know is what filesystem is on the usb drive. Also answering all the questions in post 2 will provide helpful information.

In your other thread, you indicate that you were having problems editing a configuration file with vi, When you edited it the first time, did you close the file properly?

Yes, i always close vim properly (for the sake of my data ). That computer is seriously wrong.. somewhat..
The filesystem on the usb drive that i asked in this thread is actually liveusb from Endeavorous. I was borrowing the space to do 1 file transfer from problematic Endeavourous laptop to manjaro desktop. Never a problem on Manjaro.. but on the laptop with Endeavorous os.. the problem occurs.

andrewysk 05-27-2021 04:45 PM

Quote:

Originally Posted by DavidMcCann (Post 6253821)
My practice here has always been to
1. start with a Linux format on the usb stick — less likely to cause trouble
2. if it goes read-only, use fsck
3. if it does it again, reformat
4. if it happens for the third time, dump it.

I see, that would indicates usbstick got issue.. but my usbstick is fine on manjaro Desktop.. it only occurs on endeavorous laptop.

andrewysk 05-27-2021 04:47 PM

Quote:

Originally Posted by sofasurfer (Post 6253851)
Well, you learn something new every day. My mp3 player, when inserted into the pc, sometimes does not allow deletion of files or does not allow transfer of files. So are you saying the reason is because I always just yank it out when I'm done with it? I need to unmount it first or use the eject/remove button?

I don't think you need to unmount it before unplug, if this is a must than there is no proud of saying linux is better than window os. I unplug straight away from manjaro desktop, no problem what so ever.. just make sure you stop doing data transfer for a short while, at least.

andrewysk 05-27-2021 04:53 PM

Quote:

Originally Posted by teckk (Post 6253862)
Depends on the file system how much trouble you'll have doing that.

Even on a windows machine, with a external ntfs volume, you are suppose to click on that icon in the taskbar, "remove drive safely", before you pull it out, or it'll do it's checkdisk the next time you stick it in. And windows can fix it's own file system just fine. On a linux machine you need to make sure it is unmounted before removing, or it won't mount again. And ntfs-tools probably won't help.

Not something that you should do on purpose but, you can pull a FAT or EXT4 drive out in the middle of a write and it won't hurt it, other than the file that you were copying will be corrupt. But you'll have a hung mount. You'll probably need to do a force umount. That is what mount and df are for.

Oh really ? I have always unplug usb stick while not writing. never problem before.. it still mount each time. I tried many time on the same usb stick, it mounts fine.. ya.. eject before unplug is always the best practice.

computersavvy 05-27-2021 10:30 PM

Quote:

Originally Posted by andrewysk (Post 6254455)
I plugged the usb stick in, it auto mounted (default). I don't need to mount it.
I do not unmount usb stick, just when it is no doing data transfer, just unplug it. I always do that, never a problem before. I also do that to my manjaro kde desktop, no problem what so ever.

With the current level of USB drive handling, IF the drive is synced and not actively involved in writing data you can usually unplug it without actively dismounting it and systemd will handle that for you. If there is activity on the drive, or even if you have the file manager with a folder open on that device and you unplug it problems can occur. That is why the file manager has an icon to dismount those devices before you remove then. Better to take action and prevent problems than to try and repair what gets barfed up.

And you said the problem occurs on the endeavorous laptop. That is a different OS than the manjaro desktop so you have to expect the software may not be the same and it apparently does not handle unplugging a USB without dismounting it the same way.

Learn the differences and practice what works on the most restrictive one always; so you don't forget and cause yourself problems.

ondoho 05-27-2021 10:48 PM

This is strangely similar to this:
https://www.linuxquestions.org/quest...514/page2.html
I wonder if the "hard drive" in that other thread is really the same USB stick?


All times are GMT -5. The time now is 10:05 PM.