How do I determine the best number to use for the bs (block size) operand of the dd command?


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers How do I determine the best number to use for the bs (block size) operand of the dd command?
# 1  
Old 01-25-2018
How do I determine the best number to use for the bs (block size) operand of the dd command?

When I create a bootable Linux distro installation USB drive, I use this command:
Code:
sudo dd if=/Path/to/linux_distro.iso of=/dev/rdisk<disk number>
 bs=<number of bytes>

When I look it up, I've seen variations of people choosing 4M, and I think 8M, 2M, and maybe even 1M.

If I leave the operand off, it seems to take a long time (I never let it finish).

How would I determine what number to use to make it go the fastest? Is speed the only factor?
# 2  
Old 01-25-2018
What instructions are you following? It makes little sense to dump a raw ISO to a partition, flash drive is not CDROM. A few odd boot systems do this, but usually you'd install to a flash drive like a hard drive.

4M is fine. The point is that it's not left at the default of 512, which would be extremely slow.

It may seem to take a long time because it may take a long time. USB media not particularly fast. If you want to know how much it has written and are running in Linux, not some other UNIX try running sudo killall -USR1 dd which should cause dd to print statistics. (On non-Linux operating systems, killall has a more literal meaning.)
# 3  
Old 01-25-2018
Quote:
Originally Posted by Corona688
What instructions are you following?
There's a bunch of places online that detail how to make bootable USB drives for Linux distros like Ubuntu on Mac. I can't post a URL, because it says I need to have at least 5 posts. It seems to be the only way to do it from Mac's terminal.

Quote:
Originally Posted by Corona688
It makes little sense to dump a raw ISO to a partition, flash drive is not CDROM. A few odd boot systems do this, but usually you'd install to a flash drive like a hard drive.
I don't quite follow you here. I guess dd stands for dump something? All I knew is the command is able to make bootable media.

Quote:
Originally Posted by Corona688
4M is fine. The point is that it's not left at the default of 512, which would be extremely slow.
I appreciate the suggestion, but I'm looking for a bit more of an explanation. I want to be able to work out an optimal number by myself.

You said 512(M?) would be slow. What about 256? What about 1M? What about 8M? I've seen various suggestions, but not much explanation.

Hopefully that makes sense.

Last edited by Quenz; 01-25-2018 at 08:06 PM.. Reason: Rewording
# 4  
Old 01-26-2018
Quote:
Originally Posted by Quenz

I don't quite follow you here. I guess dd stands for dump something? All I knew is the command is able to make bootable media.
I've always thought it stood for "Disk to Disk" or "Disk Dump". The Wikipedia page for dd mentions the JCL language's DD command. I would say the origins of the name are lost in time.
Quote:
I appreciate the suggestion, but I'm looking for a bit more of an explanation. I want to be able to work out an optimal number by myself.

You said 512(M?) would be slow. What about 256? What about 1M? What about 8M? I've seen various suggestions, but not much explanation.

Hopefully that makes sense.
Presumably as the original use of dd was for copying data between devices the block size is that of the target device. If you have the Gnu stat command on your system you could use that to determine the block size of your USB. I put an 8Gb USB drive and a 32Gb drive in my system and got this:
Code:
$ stat -f -c"%s" /media/apm/24F4-1B66 # 8GB volume
4096
$ stat -f -c"%s" /media/apm/F170-2ADC # 32GB volume
16384

In actual fact the man page for stat says:
Code:
       %s     block size (for faster transfers)

Andrew
# 5  
Old 01-26-2018
The origin and history of dd vanish in the haze, proven by its unusual and unwieldy command line handling, but rumours are it stands for "data dump". Of course, this attempt of an explanation is as good as any other interpretation.

Trying to nail down an optimal block size for a sizeable copy operation might end up like nailing jelly to the wall. While it makes real sense not to use the default of 512 bytes as that would result in way too many I/O operations, choosing too large a value could make the situation worse as it e.g. could start thrashing the swap space, also influencing overall system performance. And this is system load dependent and can vary with time.
I'd recommend doing some tests with e.g. 1M, 2M, 4M, and stop where the improvement rate starts dropping.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

How to extract operand size in bits of a C program?

Hi I'm new to shell programming. How do I extract the size of an operand in a simple instruction in a C program? Lets say there is an addition a+b somewhere in a C code where a and b are integers. How to extract the size of a & b in bits? Is there something called intermediate code before an... (4 Replies)
Discussion started by: beginner_99
4 Replies

2. Programming

Perl : Inline program to determine file size

Hi, I have 5 files as below $ ll sam* -rw-rw-rw- 1 sam ugroup 0 Mar 21 06:06 sam3 -rw-rw-rw- 1 sam ugroup 0 Apr 3 22:41 sam2 -rw-rw-rw- 1 sam ugroup 17335 Apr 10 06:07 sam1 -rw-rw-rw- 1 sam ugroup 5 Apr 10 07:53 sam5 -rw-rw-rw- 1 sam ugroup 661 Apr 10 08:16 sam4 I want to list out... (4 Replies)
Discussion started by: sam05121988
4 Replies

3. UNIX for Dummies Questions & Answers

Command for total number of files (and size) across subdirectories?

Hi all... I have a directory called dbrn. This directory contains an unknown number of subdirectories which in turn contain an unknown number of files. What I want to know is: How many files with extention .ABC can be found in /dbrn across all subdirecties, and what is the total size for... (9 Replies)
Discussion started by: Beun
9 Replies

4. Shell Programming and Scripting

determine the number of spaces

Here is a weird question :) i am trying to create a script written in bash that will create configuration files for nagios. As some of you aware is has to be written in the below format: define service{ option1 value1 option2 value2... (6 Replies)
Discussion started by: ppolianidis
6 Replies

5. UNIX for Dummies Questions & Answers

Determine switch buffer size

Hi everybody, I need to calculate the tcp buffer size of a network switch, since it's not specified in the manual; how do I do this? I have some machines connected to the switch and I can run some socket tests written in C between these machines (I can choose how many bytes to send and... (0 Replies)
Discussion started by: dimpim
0 Replies

6. HP-UX

determine the physical size of the hard disk

Hi is there a cmd in hpux 11 to determine the physical size of the hard disk. not bdf command. i have searched the other threads here but cant find an answer. thank you guys (4 Replies)
Discussion started by: hoffies
4 Replies

7. UNIX for Advanced & Expert Users

How to determine the max file size

Does anyone know a way to determine the maximum filesize on a file system on Solaris, HP-UX, AIX, Linux, and OSF1 using the command line? TIA (2 Replies)
Discussion started by: dknight
2 Replies

8. Shell Programming and Scripting

$A is a number / any other string? How to determine ?

I have a variable (say $A) and while passing it gets either a number or some other string. Now how can test (with if else) whether the variable is just a ne or something else ? Thanks a lot to all in advance C Saha (2 Replies)
Discussion started by: csaha
2 Replies

9. HP-UX

determine number of xterm connected

i more than one hp-ux 11.0 application server. some of these application server has an xterminal attached to them. ncd900 and ncd400. i would like to know how many xterm is connected to an application server. without physically checking each xterm, can i identify how many xterm? thanks alot. (0 Replies)
Discussion started by: inquirer
0 Replies

10. UNIX for Dummies Questions & Answers

determine the size of a file???

Hello, Can someone please tell me which command to use to determine the size of a file? When I log in to my shell account, I do this $>% ls -als total 632 8 -rw-r--r-- 1 user01 devgrp1 1558 Jul 30 23:25 .kshrc What is "1158"? Bytes? Kilobytes? I apologize if my... (8 Replies)
Discussion started by: alan
8 Replies
Login or Register to Ask a Question