You are not logged in.

#1 2021-11-13 12:03:27

Valso
Member
Registered: 2021-04-22
Posts: 76

Making a usb stick undeletable?

I'm not sure if the topic is for this section but since flash drives are considered media, I'm hoping that it is.

Recently I bought a 256GB flash drive and already filled it. But unlike other flash drives it doesn't have a hardware switch to make it undeletable, so I'm wondering if there's a command to make the whole device undeletable?
I know about

# chattr +i

but AFAIK it's used only for files and IDK if it's gonna work on an entire device or on a directory with the recursive option (because the flash drive is essentially one directory with many subdirs).

Offline

#2 2021-11-13 12:10:18

progandy
Member
Registered: 2012-05-17
Posts: 5,184

Re: Making a usb stick undeletable?

You can try hdparm, but it may or may not work with your usb drive:

# readonly
hdparm -r1 /dev/$USBDRIVE

# allow write
hdparm -r0 /dev/$USBDRIVE

https://www.thegeekdiary.com/how-to-dis … parm-tool/

The proper place for the question would be the Newbie Corner, though. Multimedia is not about the physical device, but digital content in different formats (audio, video, application, ...)

Last edited by progandy (2021-11-13 12:14:42)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#3 2021-11-13 12:59:43

Valso
Member
Registered: 2021-04-22
Posts: 76

Re: Making a usb stick undeletable?

Thanks for the link. It did work. Just one question: does it have to be executed as root? I ran it with sudo but it didn't ask for password, which makes me think it can be ran as a regular user.

Offline

#4 2021-11-13 13:20:34

Ammako
Member
Registered: 2021-07-16
Posts: 267

Re: Making a usb stick undeletable?

Valso wrote:

Thanks for the link. It did work. Just one question: does it have to be executed as root? I ran it with sudo but it didn't ask for password, which makes me think it can be ran as a regular user.

sudo will always ask for a password, even for commands that don't need root permissions. The main exception to this is if you already ran another sudo command in that terminal session in the past 5(?) minutes, the password is remembered so you don't have to type it in every time, because it would be annoying if you had several commands to run and needed to enter the password every time. This can be disabled or extended if you would prefer.

Otherwise you can set your user to have passwordless sudo permissions, but you probably haven't done that.

Offline

Board footer

Powered by FluxBB