4

I know i can fill an entire disk with 0x0 like this:

dd if=/dev/zero of=/dev/sda bs=4k conv=notrunc

Is there a way to fill the entire disk with a char of my choice?

yonigo
  • 987
  • 1
  • 15
  • 30

3 Answers3

5

How about this:

yes "<char>" | dd of=/dev/sda bs=4k conv=notrunc

Substitute with character of your choice.

Nikhil
  • 2,298
  • 13
  • 14
4

You can do it this way:

while true; do echo -n 'x'; done | dd of=/dev/sda bs=4k conv=notrunc iflag=fullblock
Grzegorz Żur
  • 47,257
  • 14
  • 109
  • 105
2
yes "" | tr "\n" "<char>" | dd of=/dev/sda <rest of dd parameters>
cat /dev/zero | tr "\0" "<char>" | dd of=/dev/sda <rest of dd parameters>
cat /dev/zero | sed "y/\0x00/<char>/" | dd of=/dev/sda <rest of dd parameters>

Where <char> is your chosen character

martin clayton
  • 76,436
  • 32
  • 213
  • 198