How to Resolve dd: invalid number

  • by

dd: invalid number

Tried to replicate a partition to another with dd, but it failed with dd: invalid number.

Here I initially use 1g for each copy.

[root@test ~]# dd if=/dev/sdl1 of=/dev/sde1 bs=1g
dd: invalid number: ‘1g’

Even I use 1024m caused the error.

[root@test ~]# dd if=/dev/sdl1 of=/dev/sde1 bs=1024m
dd: invalid number: ‘1024m’

After that, I checked the manual of dd and found that the unit for bs is a little different from my thought.

[root@test ~]# man dd
       N and BYTES may be followed by the following multiplicative suffixes: c =1, w =2, b =512, kB =1000, K =1024, MB  =1000*1000,
       M =1024*1024, xM =M, GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y.

Which says, I should use an uppercase 1G for 1024*1024*1024 bytes.

[root@test ~]# dd if=/dev/sdl1 of=/dev/sde1 bs=1G
25+0 records in
25+0 records out
26843545600 bytes (27 GB, 25 GiB) copied, 927.091 s, 29.0 MB/s

Another way to work around it is to ignore bs option.

[root@test ~]# dd if=/dev/sdl1 of=/dev/sde1

It will use the default value 512 bytes to perform the command, you don't have to worry about the unit.

The lesson I learned from the above error is that I should check the manual before dd, because it seems a platform-specific command.


Leave a Reply

Your email address will not be published. Required fields are marked *