Skip to content
Home » Linux » How to Resolve dd: invalid number

How to Resolve dd: invalid number

dd: invalid number: ‘1m’

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 1m caused the error.

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

Rationale

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.

They are all uppercase.

Solutions

1. Upper-cased Suffixes

Which says, we should use an uppercase 1G for 1024*1024*1024 bytes or 1M for 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

2. Ignore bs

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-dependent command.

Sometimes, using 1G for each loop might produce share memory issue when executing dd command, we should be aware of that.

Leave a Reply

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