Most storage devices, especially Fibre Channel storage devices, iSCSI storage devices etc.. The R/W state of device can only be changed through a management interface on the storage device. The operating system will not automatically update its view of the state of the device when a change is made.

Here is the steps for user to change the state of the device from Read/Write (R/W) to Read-Only (RO), and from RO to R/W.

Follow the procedures described in this chapter to make the operating system aware of the change.
Run the following command, XYZ just identified as a storage device in below example, to determine the operating system's current view of the R/W state of a device:

# blockdev --getro /dev/sdXYZ

The following command is also available for Red Hat Enterprise Linux 7:

# cat /sys/block/sdXYZ/ro 
1 = read-only 0 = read-write

When using multipath, refer to the ro or rw field in the second line of output from the multipath -ll command. For example:

36001438005deb4710000500000640000 dm-8 GZ,GZ500
\_ round-robin 0 [prio=200][active]
\_ 6:0:4:1 sdax 67:16 [active][ready]
\_ 6:0:5:1 sday 67:32 [active][ready]
\_ round-robin 0 [prio=40][enabled]
\_ 6:0:6:1 sdaz 67:48 [active][ready]
\_ 6:0:7:1 sdba 67:64 [active][ready]

To change the R/W state, use the following procedure:

Change the Storage Device R/W state

1. Change a storage device from R/W TO RO.

To move the device from R/W to RO, ensure no further writes will be issued. Do this by stopping the application, or through the use of an appropriate, application-specific action.
Ensure that all outstanding write I/Os are complete with the following command:

#blockdev --flushbufs /dev/device

Replace device with the desired designator; for a device mapper multipath, this is the entry for your device in dev/mapper. For example, /dev/mapper/mpath3.

2. Change a storage device from RO to R/W

2. Use the management interface of the storage device to change the state of the logical unit
from R/W to RO, or from RO to R/W. The procedure for this differs with each array. Consult
applicable storage array vendor documentation for more information.

3. Perform a re-scan of the device

To update the operating system's view of the R/W state of the device. rescan the device.

If using a device mapper multipath, perform this re-scan for each path to the device before issuing the command telling multipath to reload its device maps.