Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use dd to fill a disk with a specific char?

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?

like image 712
yonigo Avatar asked Dec 25 '22 20:12

yonigo


2 Answers

How about this:

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

Substitute with character of your choice.

like image 130
Nikhil Avatar answered Jan 04 '23 23:01

Nikhil


You can do it this way:

while true; do echo -n 'x'; done | dd of=/dev/sda bs=4k conv=notrunc iflag=fullblock
like image 24
Grzegorz Żur Avatar answered Jan 04 '23 23:01

Grzegorz Żur