[svlug] Need a shell/bash loop over each partition and execute dd && rm

Robert Hajime Lanning lanning at lanning.cc
Mon Aug 1 21:51:00 PDT 2011

Also note that long /dev paths will break df output to two lines.

Maybe parsing the output of "mount"?
I know on Linux, you can:
echo $( mount | grep "^/" | cut -d" " -f3 )

I don't have a BSD machine to check mount's output there.

On 08/01/11 21:16, John Sokol wrote:
> Good catch Rick, don't want to do that in wrong file systems.
> Also NFS mounts would be bad, really bad.
> On Mon, Aug 1, 2011 at 9:09 PM, Rick Moen <rick at linuxmafia.com
> <mailto:rick at linuxmafia.com>> wrote:
>     Quoting John Sokol (john.sokol at gmail.com <mailto:john.sokol at gmail.com>):
>     > Make sure the list of partitions looks correct.
>     If you'll pardon brief kibbitzing, here's a very minor refinement to
>     your
>     script, to exclude various abstract or odd Linux filesystems, in
>     addition to the df header line with the word 'Available' in it:
>     #!/bin/bash
>     for h in $( `df | egrep -v
>     'Available|tmpfs|udev|ramfs|romfs|cramfs|debugfs' | \
>     awk '{print $NF}'`   );do
>       echo "Cleaning partition $h"
>       sudo dd if=/dev/zero of=$hzerofile && sudo rm $hzerofile
>     done
>     Only the udev and tmpfs ones are likely to be common problems, but
>     I threw in the others just in case.


More information about the svlug mailing list