> For the complete documentation index, see [llms.txt](https://hezhiqiang.gitbook.io/linux/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hezhiqiang.gitbook.io/linux/ming-ling/blockdev.md).

# blockdev

从命令行调用区块设备控制程序

## 补充说明

**blockdev命令** 在命令调用“ioxtls”函数，以实现对设备的控制。

### 语法

```
blockdev(选项)(参数)
```

选项

```
-V：打印版本号并退出；
-q：安静模式；
-v：详细信息模式；
--setro：只读；
--setrw：只写；
--getro：打印只读状态，“1”表示只读，“0”表示非只读；
--getss：打印扇区大小。通常为521；
--flushbufs：刷新缓冲区；
--rereadpt：重新读取分区表。
```

### 参数

设备文件名：指定要操作的磁盘的设备文件名。

### 实例

设置设备为只读：

```
blockdev --setro /dev/hda4
```

读取设备是否为只读：

```
blockdev --getro /dev/hda4
```

设置设别为可读写：

```
blockdev --setrw /dev/hda4
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://hezhiqiang.gitbook.io/linux/ming-ling/blockdev.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
