SCSI_CH_SWP(8) | SDPARM | SCSI_CH_SWP(8) |
scsi_ch_swp - change SCSI Software WRITE Protect and block device settings
scsi_ch_swp [--help] [--set 0|1] [--verbose] [--wr] BLK_DEVICE
This bash shell script attempts to read or change the Software Write Protect (SWP) bit in the SCSI Control mode page using the sdparm utility. If that change is successful then it uses the blockdev utility to change BLK_DEVICE's read-write or read-only setting in sympathy. This script is only available in Linux since the blockdev utility is Linux specific.
If changing the SWP bit is supported, setting the SWP bit makes BLK_DEVICE read-only at the device (disk) itself. Clearing the SWP bit makes BLK_DEVICE read-write which is usually the default setting at device (disk) power up.
If no options are given then the current state of the SWP bit is printed out (using sdparm) together with blockdev's RO bit. If they are both 1 then BLK_DEVICE is in read-only mode; if they are both 0 then BLK_DEVICE is in read-write mode.
Arguments to long options are mandatory for short options as well.
The exit status of this script is 0 when it is successful. Otherwise the exit status is that of the sdparm or the blockdev utility, whichever is called last. See the sdparm(8) man page.
Written by D. Gilbert
Copyright © 2013 Douglas Gilbert
This software is distributed under a FreeBSD license. There is NO warranty;
not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
sdparm(sdparm), blockdev(8)
May 2013 | sdparm-1.08 |