What's the simplest way to rewrite the data without actually copying the data? Like in place rewrite - you write what you read.
What's the simplest way to rewrite the data without actually copying the data? Like in place rewrite - you write what you read.
I've seen "dd if=/dev/removable of=/dev/removable" suggested. I don't know if it actually works or if the OS optimizes it to a no-op.
Certainly the OS can't optimize it to a no-op, since `dd` makes separate read and write syscalls.
I suppose your `dd` implementation itself could do so, but I don't know why it would.
the risk of catastrophic data loss from misuse of `dd` makes my hackles rise just looking at this.
I will never forget when I mixed up `if` and `of` during a routine backup.
`cat /dev/sda > /mnt/myDisk2` is so much safer, explicit, and in unix norms. It's also faster because you don't have to tune block size parameters.
Plus you can also do `pv /dev/sda > /mnt/myDisk2` to get transfer speed details.
Friends don't let friends use `dd` where `cat` can do the same job.
I stopped getting scared of `if` and `of` about a decade ago when I started explicitly saying (in my head) "input file" and "output file" rather than "if" and "of." You still can mess up the order, but imo no more easily than you can swap `cat in > out` for `cat out > in`.
> Friends don't let friends use `dd` where `cat` can do the same job.
Technically yes... but I like being able to explicitly set block sizes and force sync writes.
Wouldn't a ZFS Scrub get the job done?
zpool scrub is what I would do, but it only rewrites data that needs it. The OP wanted to rewrite everything.