Google
  Web www.spinics.net

Re: Can dd seek on a loop device?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


>
> Is there any easy way to see how full the device is (no filesystem on there)?
>

To answer my own post (this list seems quiet these days).

Came up with the following Perl one liner to read 512 bytes in at time from the loop device, if they're all hex 0 then read in the next 512, and so on,  printing a running total of MB processed thus far.  Stop when we run into a non-zeroed-out block on the loop device:

# perl -e 'open D, "<", "/dev/loop5"; while ($n=sysread(D,$x,512)){if ($x =~ /(\x00){512}/) { $o+=$n; print "\015", int($o/1024/1024), " MB" } else { exit} }'

Some Perl guru might well have a less gauche way to skip through the device looking for a non-zero block.



      

-
Linux-crypto:  cryptography in and on the Linux system
Archive:       http://mail.nl.linux.org/linux-crypto/



[Home]     [Kernel]     [Linux Crypto]     [Gnu Crypto]     [Gnu Classpath]     [Netfilter]     [Bugtraq]     [Network Security Reading]

Add to Google