Difference between revisions of "User:Filam/Block size"

From ArchWiki
Jump to: navigation, search
(Create page with block size examples)
 
m (Disparate examples)
(9 intermediate revisions by the same user not shown)
Line 1: Line 1:
This page lists examples of the {{Pkg|dd}} block size flag (i.e. {{ic|<nowiki>bs=</nowiki>}}) on English language pages.
+
The {{Pkg|dd}} command copies and converts raw data at a low level. The block size option (i.e. {{ic|<nowiki>bs=</nowiki>}}) defines the number of bytes involved in a single read or write operation. There is a great deal of confusion about the optimal value for this option.<sup>[http://serverfault.com/questions/4906/using-dd-for-disk-cloning]</sup>
 +
 
 +
{{Note|Specifying a value for the block size is only recommended for operations that copy or convert large amounts of data.}}
 +
 
 +
* Unix [[Wikipedia:Device file|device files]] use 512-byte blocks as their allocation unit by default.
 +
 
 +
If you have a [[Wikipedia:Advanced Format|Advanced Format]] hard drive it is recommended that you specify a block size larger than the default 512 bytes. To speed up the overwriting process choose a block size matching your drive's physical geometry by appending the block size option to the dd command (i.e. {{ic|<nowiki>bs=4096</nowiki>}}).
 +
 
 +
The block size value may be followed by the following multiplicative suffixes: {{ic|c}}=1, {{ic|w}}=2, {{ic|b}}=512, {{ic|kB}}=1000, {{ic|K}}=1024, {{ic|MB}}=1000<sup>2</sup>, {{ic|M}}=1024<sup>2</sup>, etc.
 +
 
 +
== Print block size ==
 +
To print the block size of the device issue the following command:
 +
# dumpe2fs -h /dev/sdX | grep 'Block size:'
 +
For more information read [http://www.linfo.org/get_block_size.html How to Find the Block Size] on The Linux Information Project and the [http://www.gnu.org/software/coreutils/manual/html_node/Block-size.html#Block-size Block size] section in the core GNU utilites manual.
 +
 
 +
== Disparate examples ==
 +
This section lists examples of the {{Pkg|dd}} block size flag (i.e. {{ic|<nowiki>bs=</nowiki>}}) on English language pages. The following examples all come from the first page of a [https://wiki.archlinux.org/index.php?title=Special%3ASearch&search=bs%3D&go=Go search for "bs="].
  
 
[[User-mode Linux]]
 
[[User-mode Linux]]
Line 19: Line 35:
 
{{bc|<nowiki>$ dd if=/dev/zero of=/arch/swapfile bs=1024 count=<# of KiB></nowiki>}}
 
{{bc|<nowiki>$ dd if=/dev/zero of=/arch/swapfile bs=1024 count=<# of KiB></nowiki>}}
  
The preceding examples all come from the first page of a [https://wiki.archlinux.org/index.php?title=Special%3ASearch&search=bs%3D&go=Go search for "bs="].
+
== See also ==
 +
{{Wikipedia|Dd (Unix)#Block size}}
 +
 
 +
* [http://www.gnu.org/software/coreutils/manual/html_node/dd-invocation.html GNU coreutils  manual]
 +
* [http://stackoverflow.com/questions/2787330/dd-block-size-optimisation Dd block size optimisation] question on Stack Overflow
 +
* [http://www.mail-archive.com/eug-lug@efn.org/msg12073.html Dexter's dd block size speed test]
 +
* [http://lists.freebsd.org/pipermail/freebsd-performance/2005-October/001555.html performance when copying a disk to another]

Revision as of 04:23, 25 September 2012

The dd command copies and converts raw data at a low level. The block size option (i.e. bs=) defines the number of bytes involved in a single read or write operation. There is a great deal of confusion about the optimal value for this option.[1]

Note: Specifying a value for the block size is only recommended for operations that copy or convert large amounts of data.
  • Unix device files use 512-byte blocks as their allocation unit by default.

If you have a Advanced Format hard drive it is recommended that you specify a block size larger than the default 512 bytes. To speed up the overwriting process choose a block size matching your drive's physical geometry by appending the block size option to the dd command (i.e. bs=4096).

The block size value may be followed by the following multiplicative suffixes: c=1, w=2, b=512, kB=1000, K=1024, MB=10002, M=10242, etc.

Print block size

To print the block size of the device issue the following command:

# dumpe2fs -h /dev/sdX | grep 'Block size:'

For more information read How to Find the Block Size on The Linux Information Project and the Block size section in the core GNU utilites manual.

Disparate examples

This section lists examples of the dd block size flag (i.e. bs=) on English language pages. The following examples all come from the first page of a search for "bs=".

User-mode Linux

dd if=/dev/zero of=rootfs bs=1MB count=1000

Remote Arch Linux Install

# dd if=/dev/zero of=/swapfile bs=1024 count=512288

USB Installation Media

# dd count=1 bs=512 if=/dev/zero of=/dev/sdx

Windows and Arch Dual Boot

dd if=$my_boot_part of=/media/win/linux.bin bs=512 count=1

Dm-crypt with LUKS

# dd if=/dev/urandom of=mykeyfile bs=512 count=4
# dd if=/dev/urandom of=secretkey bs=512 count=4

KVM

$ dd if=/dev/zero of=image.img bs=1G count=0 seek=[NUMBER_OF_GB]

JFS Filesystem

dd bs=4k if=/dev/hdc1 of=/dev/hdj1

Installing ArchPPC on a PS3

$ dd if=/dev/zero of=/arch/swapfile bs=1024 count=<# of KiB>

See also

Template:Wikipedia