Blockdev sets the file pre-read size

Source: Internet
Author: User

Call the ioctl function of the device on the command line. In Linux, it seems that only the ioctl function is used to directly operate the device. Not many parameters are accepted, and they all correspond one to one.

Blockdev-call the block device control program from the command line

Blockdev [Options]Commands Devices

The blockdev tool allows you to call the block device control program from the command line.

-Setro: set the device to read-only.
-Whether the getro reading device is read-only (if the value is 1 or 0, the device can be read and written)
-Setrw: Set to read/write.
-Getss prints the device's sector size, usually 512
-Getsize: prints the set capacity, which is calculated by 512 bytes per sector.
-Setra N: Set the pre-read sector (512 bytes) to N. Set readahead to N 512-byte sectors.
-Getra print readahead (pre-read sector)
-Flushbufs refresh buffer
-Rereadpt: Re-reads the partition table.

I think-setro and setrw are useful. This mount-O RO (RW) is different. Mount is read-only or readable to a partition at the file system level. Blockdev is set to read-only and read-write at the level of settings.
The output result of the following command is clear at a glance.

[Root @ lancy ~] # Blockdev-setro/dev/hda4
[Root @ lancy ~] # Blockdev-getro/dev/hda4
1
[Root @ lancy ~] # Mount/dev/hda4/MISC-O RW
Mount: block device/dev/hda4 is write-protected, mounting read-only
[Root @ lancy ~] # Umount/dev/hda4
[Root @ lancy ~] # Blockdev-setrw/dev/hda4
[Root @ lancy ~] # Blockdev-getro/dev/hda4
0
[Root @ lancy ~] # Mount/dev/hda4/MISC-O RW
[Root @ lancy ~] # Touch/MISC/One
[Root @ lancy ~] # Umount/dev/hda4
[Root @ lancy ~] # Mount/dev/hda4/MISC-O Ro
[Root @ lancy ~] # Rm-F/MISC/One
RM: cannot delete '/MISC/one': Read-Only File System

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.