Linux Blockdev Command Set file pre-read size introduction

Source: Internet
Author: User

Invokes the device's IOCTL function at the command line. In a Linux system, it seems that the direct operation of the device is only IOCTL function. The parameters he accepts are not too much, and they all correspond to one by one.

Blockdev-Call block Device control program from the command line

Blockdev [Options] Commands devices

The Blockdev tool allows the block device control program to be invoked from the command line.

–setro set device to read-only
–getro read whether the device is read-only (successful for 1,0 is writable)
–SETRW setting is read-only
–GETSS the sector size of the print device, usually 512
–getsize Print set other capacity, calculated in 512 bytes per sector
–setra N Sets 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 reread the partition table.

Think –SETRO,SETRW is more useful, this mount-o ro (rw) is a difference, mount is at the file system at this level for a partition to mount as read-only or writable. The Blockdev is set to read-only and read-write at the setting level.
Look at the output of the command below at a glance.

The

code is as follows:


[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.