Need to overwrite file with same sized characters, ZFS, No /dev/null /dev/zero

Hello,

my external drive filesystem tool “sudo zpool status -v” reported error ZFS Message ID: ZFS-8000-8A in one file and suggested i recover it from backup. That file was part of some torrent so i have re-checked the torrent, yet the torrent app reports “Invalid exchange” for that file. So i was wondering if HDD block is not damaged (did smart Short offline, Completed without error, no pending/uncorrectable sectors), maybe i can try to overwrite file with random or zero characters, so i tried /dev/zero but “/dev/zero: command not found” on my Manjaro.

Do you have idea what to try?

It’s not a command ─ it’s a device special file.

Try… :arrow_down:

dd if=/dev/zero of=/path/to/file bs=4096 count=N

… whereby you replace N by the number of times needed for filling up the file with chunks of 4096 bytes each. It’ll depend on how big that file is, of course. You can also specify larger blocks (and units) than 4096 bytes. See…

man dd
1 Like

Thanks for help. Since the stat command shown file is
Size: 0 Blocks: 1 IO Block: 524288 regular empty file
(i guess 0 bytes)
i can only expect how big file to write. 4096 is 4 kilobyte according to Byte Converter: Bytes to KB to MB to GB to TB [Calculator] | Whatsabyte
So 1 MB is:
dd if=/dev/zero of="/path/to/file" bs=1048576 count=1
(note that i have mentioned /dev/zero is not found on my Manjaro

Anyway, my manjaro was lagging, and some apps stuck, so i had to try to reboot, it was stuck on black screen where i have seen “F@iled to start CUPS sch€dull€r” so i lost patience and reset. After boot and zfs import and re-downloading the file, it seems it is working again.

You were trying to use /dev/zero as a command, and indeed, no such command exists, but /dev/zero itself does always exist. As I told you, it’s not a command but a device special file that always returns zeroes when read from.

Also, had you read the man page for dd, then you would have seen that you can specify units in the block size, so there was no need to calculate the number of bytes. :wink:

Thanks regarding /dev/zero, indeed, i could use “cat /dev/zero > file” possibly, but dd better to fill whole file size i guess…
Yes, man page is badly written, because it should have mentioned i can use K, M etc on the bs description line.

btw, someone advised dd conv=noerror
Though i am unsure what it do and how beneficial it can be in this case.

from man page:
conv - convert the file as per the comma separated symbol list
noerror - continue after read errors

1 Like

Interesting, the “sudo zpool status -v” file/folder/meta? permanent errored items (password: private) disappeared after “sudo zpool scrub poolname” waiting a few hours (someone said a few minutes is sufficing) and then “sudo zpool scrub -s poolname”. But someone said that the errors may reappear on full scrub run, so i will see. Though an program that is reading from the directory which was displayed as permanently errored in ZFS before, is refusing to write files to this dir. saying: [Errno 5] Input/output error
So i guess it is a bug in zfs that it clears the errored items list even the scrub not completed and errors remain. btw. that files can not be read, written nor removed (by “rm”) :confused: