Linux command
blockdev 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Report
sudo blockdev --report
Example
sudo blockdev --report /dev/sda1
Example
sudo blockdev --getsz /dev/sda1
Example
sudo blockdev --setro /dev/sda1
Example
sudo blockdev --setrw /dev/sda1
Flush
sudo blockdev --flushbufs /dev/sda1
Example
sudo blockdev --getpbsz /dev/sda1
Example
sudo blockdev --setra 128 /dev/sda1
说明
blockdev queries and manipulates block device properties from the command line. It can report device sizes, set read-only/read-write modes, flush buffers, and configure performance parameters like read-ahead.
参数
- --report
- Print a report for specified devices or all devices
- --getsz
- Get size in 512-byte sectors
- --getsize64
- Get size in bytes
- --getpbsz
- Get physical block size
- --getbsz
- Get logical block size
- --setro
- Set device to read-only
- --setrw
- Set device to read-write
- --flushbufs
- Flush buffers
- --setra _sectors_
- Set read-ahead value in 512-byte sectors
- --getra
- Get current read-ahead value
FAQ
What is the blockdev command used for?
blockdev queries and manipulates block device properties from the command line. It can report device sizes, set read-only/read-write modes, flush buffers, and configure performance parameters like read-ahead.
How do I run a basic blockdev example?
Run `sudo blockdev --report` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --report do in blockdev?
Print a report for specified devices or all devices