Artificial intelligent assistant

How to overwrite beginning of a device with random bits or zeros? Just looking to overwrite a small portion of a device with zeros or random bits. More precisely I would like to overwrite the first 1% of all the sectors or few MiB. Is there an easy way to do that ?

Although `/dev/urandom` is extremely slow and as such not suitable for overwriting large amounts of data (entire disk), it might do for small regions.

Example overwriting 8MiB:


dd bs=1M count=8 iflag=fullblock if=/dev/urandom of=/dev/destroyme


Alternatively you can use `shred`:


shred -v -n 1 -s 8M /dev/destroyme


You can also use `losetup` to create devices of specific size and offsets, and overwrite them with utilities that don't have their own size / offset options.


losetup --find --show --offset 0 --sizelimit $((8*1024*1024)) /dev/destroyme
# will print /dev/loopX
cat /dev/urandom > /dev/loopX
losetup -d /dev/loopX

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy ac34f3ecbea2bd9099b8ae9579932b15