Tag: disk-check

  • Quick Tip: Looping a command in bash

    Quick Tip: Looping a command in bash

    I recently came across the need to watch my disk space while running a slow program to make sure I didn’t run out. If I did, the command would fail silently and I’d have to start over again.

    This can easily be done with this short snippet:

    watch -n10 bash -c "df -h | ack disk1s5"Code language: JavaScript (javascript)
    Every 10.0s: bash -c df -h | ack disk1s5                                                                                  mbp.local: Mon Jul 20 15:09:51 2020
    
    /dev/disk1s5           488245288  10940872 144033352     8%   488237 4881964643    0%   /

    The important part here is disk1s5, which is the device file for the partition I wanted to watch. If you need to find this, it can be done simply by running the df as a whole:

    $ df
    Filesystem             1K-blocks      Used Available Capacity  iused      ifree %iused  Mounted on
    /dev/disk1s5           488245288  10940872 144035124     8%   488237 4881964643    0%   /
    devfs                        191       191         0   100%      662          0  100%   /dev
    /dev/disk1s1           488245288 331456068 144035124    70%  1379027 4881073853    0%   /System/Volumes/Data
    /dev/disk1s4           488245288   1048596 144035124     1%        1 4882452879    0%   /private/var/vm
    map auto_home                  0         0         0   100%        0          0  100%   /System/Volumes/Data/home
    /dev/disk1s3           488245288    516448 144035124     1%       48 4882452832    0%   /Volumes/RecoveryCode language: PHP (php)

    That is all.

    Photo by Wendy Wei from Pexels

  • Fake Flash Adventures

    Fake Flash Adventures

    I recently purchased a “256 GB” flash drive for $3.  I knew this had to be fake, but I was also curious about how it worked.  It turns out that there was a “256 GB” micro SD card inside of it and I’m pretty sure that’s fake.

    I didn’t get this on Amazon, but here’s a link to basically the same generic thing:

    Here’s a copy of the Amazon item page as of the writing of this post.

    Using the great program H2testw I was able to determine how much actual storage the device had:

    Warning: Only 255988 of 255989 MByte tested.
    The media is likely to be defective.
    29.5 GByte OK (62042393 sectors)
    220.4 GByte DATA LOST (462221031 sectors)
    Details:1.1 MByte overwritten (2300 sectors)
    0 KByte slightly changed (< 8 bit/sector, 0 sectors)
    220.4 GByte corrupted (462218731 sectors)
    1.0 MByte aliased memory (2160 sectors)
    First error at offset: 0x00000007644c3200
    Expected: 0x00000007644c3200
    Found: 0x0000000000000000
    H2testw version 1.3
    Writing speed: 9.09 MByte/s
    Reading speed: 10.3 MByte/s
    H2testw v1.4

    Turns out, it’s a little under 30 gigs.  Well, at least I’ve got a good 30 gigs I can use 🙂

    Of course, I’m not going to trust this for anything important at all, so I’m going to stick it in my Nintendo Switch to use for extra storage.  If it fails, then I’ll just need to re-download any games stored on it.  No biggie.