Hi Santos
I think that error is from seeking a sector number higher than what exists on the device.
A little searching turned up this:
https://unix.stackexchange.com/questions/275243/what-does-dd-if-dev-zero-of-dev-sda-do/275260#275260So I tried it on a 4GB thumb drive:
tc@E310:~$ dd if=/dev/zero of=/dev/sdg bs=512 count=10240 seek=$(expr `blockdev --getsz /dev/sdg` - 10240)
10240+0 records in
10240+0 records out
5242880 bytes (5.2 MB, 5.0 MiB) copied, 0.0386705 s, 136 MB/s
tc@E310:~$ sync
tc@E310:~$
And it zeroed out the last 5MB of the drive. Wait for the sync command to complete before removing the device.
Some quick notes on what's going on:
tc@E310:~$ blockdev --getsz /dev/sdg
7856127
tc@E310:~$ echo $(expr `blockdev --getsz /dev/sdg` - 10240)
7845887
The blockdev command (provided by util-linux.tcz) retrieves the number of sectors on the device.
The expr command subtracts the number of sectors you want to write (count) from the number of sectors on the device.
If you don't want to install util-linux.tcz you can use fdisk to get the number of sectors on the device:
tc@E310:~$ fdisk -l /dev/sdg
Disk /dev/sdg: 3.8 GiB, 4022337024 bytes, 7856127 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/sdg1 38 7839719 7839682 3.8G b W95 FAT32
And then plug in the number of sectors on the device by hand:
dd if=/dev/zero of=/dev/sdg bs=512 count=10240 seek=$(expr 7856127 - 10240)