1 Reply Latest reply: Oct 18, 2011 8:29 AM by abrante RSS

    solaris10 high secure erase with dd

    894997
      I need help with the redirection of the output from dd in a logfile.
      Following you will see two scripts, but both scripts creates only empty files without the contents...
      The scripts reads from /dev/urandom and writes then to the disks (seven times)


      1. script with normal redirection:
      ------------------------------------------------------
      #!/bin/bash
      for i in {1..7}
      do
      dd if=/dev/urandom of=/dev/dsk/c0d0s0 bs=1048576 conv=notrunc >> run$i-dsk0.log &
      dd if=/dev/urandom of=/dev/dsk/c0d1s0 bs=1048576 conv=notrunc >> run$i-dsk1.log &
      wait
      done
      -------------------------------------------------------


      2. script with tee:
      -------------------------------------------------------
      #!/bin/bash
      for i in {1..7}
      do
      dd if=/dev/urandom of=/dev/dsk/c0d0s0 bs=1048576 conv=notrunc | tee run$i-dsk0.log &
      dd if=/dev/urandom of=/dev/dsk/c0d1s0 bs=1048576 conv=notrunc | tee run$i-dsk1.log &
      wait
      done
      --------------------------------------------------------

      Have you any ideas?
      Thank you!
        • 1. Re: solaris10 high secure erase with dd
          abrante
          I'm not sure what your exact issue is, but the redirects stated should work.

          One problem however is that your script will start off two processes, one for each dd, but the 'wait' will only wait for the last process, so your script will continue even if the last dd finishes before the other one..

          If you wish to make sure that your script exits after all your dd-processes finishes you could record the pids, i.e:
          for i in {1..7}; do
          dd [..]c0d0s0 [...]&
          jobs="$!"

          dd [..]c0d1s0 [...]&
          jobs="$jobs $!"

          for i in $jobs; do
          wait $i
          done

          echo "all dd commands have now completed for run $i".
          done




          You might also want to change the redirects from:
          run$i-dsk0.log
          to
          run$i-dsk0.log 2>&1
          .. to capture any errors..


          Btw, there is also a format command named 'purge', which may be of interest since it writes new data onto the disk four times..

          .7/M.