How does the Linux kernel decide if a block device gets the read-only flag set by default?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
3
down vote

favorite












I have a USB stick which (for about 2 months) constantly gets mounted read-only. After a bit of research and testing I found out, that the block devices of the device itself (/dev/sdc) and one of the partitions (/dev/sdcX) always has read-only flags (cat /sys/block/sdc/ro and cat /sys/block/sdcX/ro is 1).



I'm not talking about mount options! I have to manually set the flag to 0 with hdparm -r0 /dev/sdcX to be able to mount the partitions as read-write and to write at them (yes, writing works) every time I plug in the USB stick and after a reboot. The USB stick has no read-only hardware switch. I already formatted the partitions, re-created the partition table and even did dd if=/dev/zero of=/dev/sdc to ensure that the old partition table gets destroyed completely, but nothing changed.



NOTE: Other devices however don't have this read-only flag set by default.



So how does the Linux kernel decide whether to set the read-only flag for a block device by default or not? And how can I change this behavior permanently and from early boot? (I actually boot my Raspberry Pi from this USB stick but the read-only behavior is the same on my laptop with different kernels...)?










share|improve this question























  • Might be related - askubuntu.com/questions/101637/usb-turn-write-protection-off
    – slm♦
    Aug 15 at 3:06














up vote
3
down vote

favorite












I have a USB stick which (for about 2 months) constantly gets mounted read-only. After a bit of research and testing I found out, that the block devices of the device itself (/dev/sdc) and one of the partitions (/dev/sdcX) always has read-only flags (cat /sys/block/sdc/ro and cat /sys/block/sdcX/ro is 1).



I'm not talking about mount options! I have to manually set the flag to 0 with hdparm -r0 /dev/sdcX to be able to mount the partitions as read-write and to write at them (yes, writing works) every time I plug in the USB stick and after a reboot. The USB stick has no read-only hardware switch. I already formatted the partitions, re-created the partition table and even did dd if=/dev/zero of=/dev/sdc to ensure that the old partition table gets destroyed completely, but nothing changed.



NOTE: Other devices however don't have this read-only flag set by default.



So how does the Linux kernel decide whether to set the read-only flag for a block device by default or not? And how can I change this behavior permanently and from early boot? (I actually boot my Raspberry Pi from this USB stick but the read-only behavior is the same on my laptop with different kernels...)?










share|improve this question























  • Might be related - askubuntu.com/questions/101637/usb-turn-write-protection-off
    – slm♦
    Aug 15 at 3:06












up vote
3
down vote

favorite









up vote
3
down vote

favorite











I have a USB stick which (for about 2 months) constantly gets mounted read-only. After a bit of research and testing I found out, that the block devices of the device itself (/dev/sdc) and one of the partitions (/dev/sdcX) always has read-only flags (cat /sys/block/sdc/ro and cat /sys/block/sdcX/ro is 1).



I'm not talking about mount options! I have to manually set the flag to 0 with hdparm -r0 /dev/sdcX to be able to mount the partitions as read-write and to write at them (yes, writing works) every time I plug in the USB stick and after a reboot. The USB stick has no read-only hardware switch. I already formatted the partitions, re-created the partition table and even did dd if=/dev/zero of=/dev/sdc to ensure that the old partition table gets destroyed completely, but nothing changed.



NOTE: Other devices however don't have this read-only flag set by default.



So how does the Linux kernel decide whether to set the read-only flag for a block device by default or not? And how can I change this behavior permanently and from early boot? (I actually boot my Raspberry Pi from this USB stick but the read-only behavior is the same on my laptop with different kernels...)?










share|improve this question















I have a USB stick which (for about 2 months) constantly gets mounted read-only. After a bit of research and testing I found out, that the block devices of the device itself (/dev/sdc) and one of the partitions (/dev/sdcX) always has read-only flags (cat /sys/block/sdc/ro and cat /sys/block/sdcX/ro is 1).



I'm not talking about mount options! I have to manually set the flag to 0 with hdparm -r0 /dev/sdcX to be able to mount the partitions as read-write and to write at them (yes, writing works) every time I plug in the USB stick and after a reboot. The USB stick has no read-only hardware switch. I already formatted the partitions, re-created the partition table and even did dd if=/dev/zero of=/dev/sdc to ensure that the old partition table gets destroyed completely, but nothing changed.



NOTE: Other devices however don't have this read-only flag set by default.



So how does the Linux kernel decide whether to set the read-only flag for a block device by default or not? And how can I change this behavior permanently and from early boot? (I actually boot my Raspberry Pi from this USB stick but the read-only behavior is the same on my laptop with different kernels...)?







mount kernel usb-drive block-device readonly






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 15 at 2:57









slm♦

238k65492662




238k65492662










asked Aug 14 at 23:22









CodingMarco

162




162











  • Might be related - askubuntu.com/questions/101637/usb-turn-write-protection-off
    – slm♦
    Aug 15 at 3:06
















  • Might be related - askubuntu.com/questions/101637/usb-turn-write-protection-off
    – slm♦
    Aug 15 at 3:06















Might be related - askubuntu.com/questions/101637/usb-turn-write-protection-off
– slm♦
Aug 15 at 3:06




Might be related - askubuntu.com/questions/101637/usb-turn-write-protection-off
– slm♦
Aug 15 at 3:06















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462635%2fhow-does-the-linux-kernel-decide-if-a-block-device-gets-the-read-only-flag-set-b%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462635%2fhow-does-the-linux-kernel-decide-if-a-block-device-gets-the-read-only-flag-set-b%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)