Linux Command

blockdev

Calling the block device control program from the command line

Supplementary instructions

blockdev command Call the "ioxtls" function in the command to control the device.

grammar

blockdev(options)(parameters)

Options

-V: Print version number and exit;
-q: Quiet mode;
-v: detailed information mode;
--setro: read-only;
--setrw: write only;
--getro: Print read-only status, "1" means read-only, "0" means non-read-only;
--getss: Print sector size. Usually 521;
--flushbufs: Flush buffer;
--rereadpt: Reread the partition table.

Parameters

Device file name: Specify the device file name of the disk to be operated.

Example

Set the device as read-only:

blockdev --setro /dev/hda4

Read whether the device is read-only:

blockdev --getro /dev/hda4

Set the identifier to be readable and writable:

blockdev --setrw /dev/hda4
Keep reading

You may need these next

Related picks, plus your reading history and saved articles.