Linux Commands Examples

A great documentation place for Linux commands

blockdev

call block device ioctls from the command line

Synopsis

blockdev [-q] [-v] command [command...] device [device...]
blockdev --report
[device...]


add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!

examples

1
source
            
ssh $host blockdev --getsize64 $partition
0
source
            
blockpart_blockdev=
for bd in $blockdev; do
update_blockdev $bd
blkpart=$(majorminor2blockdev $blockmajor $blockminor)
blockpart_blockdev="$(update_list $bd $blockpart_blockdev)"
done
blockdev="$blockpart_blockdev"
0
source
            
echo "0 `blockdev --getsize $1` flashbang $1 0" | dmsetup create flashbang-dev
0
source
            
echo "0 `blockdev --getsize $1` linear $1 0" | dmsetup create identity
0
source
            
echo 0 `blockdev --getsize /dev/loop0` crypt blowfish 0123456789abcdef0123456789abcdef 0 /dev/loop0 0 | dmsetup create volume1

description

The utility blockdev allows one to call block device ioctls from the command line.

options

-V

Print version and exit.

-q

Be quiet.

-v

Be verbose.

--report

Print a report for the specified device. It is possible to give multiple devices. If none is given, all devices which appear in /proc/partitions are shown. Note that the partition StartSec is in 512-byte sectors.

availability

The blockdev command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/.

commands

It is possible to give multiple devices and multiple commands.
--flushbufs

Flush buffers.

--getalignoff

Get alignment offset.

--getbsz

Print blocksize in bytes.

--getdiscardzeroes

Get discard zeroes support status.

--getfra

Get filesystem readahead in 512-byte sectors.

--getiomin

Get minimum I/O size.

--getioopt

Get optimal I/O size.

--getmaxsect

Get max sectors per request

--getpbsz

Get physical block (sector) size.

--getra

Print readahead (in 512-byte sectors).

--getro

Get read-only. Print 1 if the device is read-only, 0 otherwise.

--getsize64

Print device size in bytes.

--getsize

Print device size (32-bit!) in sectors. Deprecated in favor of the --getsz option.

--getss

Print sectorsize in bytes - usually 512.

--getsz

Get size in 512-byte sectors.

--rereadpt

Reread partition table

--setbsz bytes

Set blocksize.

--setfra sectors

Set filesystem readahead (same like --setra on 2.6 kernels).

--setra sectors

Set readahead (in 512-byte sectors).

--setro

Set read-only.

--setrw

Set read-write.


author

blockdev was written by Andries E. Brouwer and rewritten by Karel Zak.

How can this site be more helpful to YOU ?


give  feedback