Results 1 to 10 of 10

Thread: Clean delete USB

  1. #1
    Join Date
    Aug 2008
    Location
    Mexico and Sweden
    Posts
    1,502

    Default Clean delete USB

    Using XFCE.
    I want to write nulls to a USB stick. When I plug it in PCManFM automatically mounts it, so I can't...
    Code:
    #dd if=/dev/null of=/dev/sdb
    0+0 records in
    0+0 records out
    0 bytes copied, 0.0078898 s, 0.0 kB/s
    ...so I...
    Code:
    #umount /dev/sdb1
    localhost:/home/ion #dd if=/dev/null of=/dev/sdb
    0+0 records in
    0+0 records out
    0 bytes copied, 0.00384992 s, 0.0 kB/s
    ...because...
    Code:
    #fdisk /dev/sdb
    
    Welcome to fdisk (util-linux 2.33.1).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    
    fdisk: cannot open /dev/sdb: No such file or directory
    It's as if "you can't get there from here." Any suggestions would be appreciated.

  2. #2
    Join Date
    Sep 2012
    Posts
    5,978

    Default Re: Clean delete USB

    Quote Originally Posted by ionmich View Post
    I want to write nulls to a USB stick.
    Code:
    #dd if=/dev/null of=/dev/sdb
    0+0 records in
    /dev/null returns end-of-file immediately. You read nothing and you write nothing. If you want to overwrite something with zeroes, you need to use /dev/zero which returns endless stream of zero bytes.

  3. #3
    Join Date
    Aug 2008
    Location
    Mexico and Sweden
    Posts
    1,502

    Default Re: Clean delete USB

    Quote Originally Posted by arvidjaar View Post
    /dev/null returns end-of-file immediately. You read nothing and you write nothing. If you want to overwrite something with zeroes, you need to use /dev/zero which returns endless stream of zero bytes.
    Thank you. My frustrations are over.

  4. #4
    Join Date
    Jun 2008
    Location
    Netherlands
    Posts
    27,342

    Default Re: Clean delete USB

    Quote Originally Posted by ionmich View Post
    Thank you. My frustrations are over.
    That is fine!

    I am still wondering. Assuming that your conclusion that /dev/sdb is indeed the mass-storage device you want to tackle.

    You used /dev/sdb in your first CODE snippet. dd did NOT complain that it does not exist, but did what you asked for (though not what you wanted to do).

    Then you umount /dev/sdb1. That is a bit late (better not overwrite a file system that is still mounted)., but again, no protest.

    Then you use fdisk on that device and fdisk says there is no device file with that name??????
    Did you remove it (you say it connects through USB, thus I assume it is possible to remove it while the system is running), or what happened? I can not really understand this.
    Henk van Velden

  5. #5
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    3,457

    Question Re: Clean delete USB

    @ionmich:

    Yes, but, your original output from “#fdisk /dev/sdb” is a little bit puzzling …

    I'm assuming that, you first, with the user “root”, executed “lsblk” and “lsblk --fs” – the expected output should be something like this – I've removed the output for the system drives – the USB stick/thumb-drive isn't mounted:
    Code:
     # lsblk 
    NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
    sde      8:64   1   3,7G  0 disk 
    └─sde1   8:65   1   3,7G  0 part 
    sr0     11:0    1  1024M  0 rom  
    sr1     11:1    1  1024M  0 rom  
     # lsblk --fs 
    NAME   FSTYPE LABEL      UUID                                 FSAVAIL FSUSE% MOUNTPOINT
    sde                                                                          
    └─sde1 vfat              A853-E68B                                           
    sr0                                                                          
    sr1                                                                          
     #
    Then, “fdisk -l /dev/sde” produces the following output:
    Code:
     # fdisk -l /dev/sde
    Disk /dev/sde: 3.7 GiB, 3997171712 bytes, 7806976 sectors
    Disk model: Trans-It Drive  
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x156052b6
    
    Device     Boot Start     End Sectors  Size Id Type
    /dev/sde1        8064 7806975 7798912  3.7G  b W95 FAT32
     #
    • It's a “nominal” 4GB stick but, “fdisk” reports “GiB” – “only” 3.7G …


    So, now my question:
    • Does a “simple” ‘dd’ complete without a “can't write past the end of the device” error?

    Code:
     # dd if=/dev/urandom of=/dev/sd? iflag=fullblock bs=512 status=progress
    • The “bs=” value should match to the “optimal” I/O value mentioned by “fdisk” – a value of ‘4096’ translates to “bs=4K” …


    The reason for my question:
    • I'm erasing some old IDE HDDs before I drop them off at the local re-cycling depot and, I'm beginning to suspect that, I may have to use the “count=” parameter of “dd” …

  6. #6
    Join Date
    Sep 2013
    Location
    Norfolk, UK
    Posts
    1,691

    Default Re: Clean delete USB

    Quote Originally Posted by dcurtisfra View Post
    I'm erasing some old IDE HDDs ...
    dd? nah... https://paste.opensuse.org/view/raw/7b3dcf31
    Regards, Paul

    2x Tumbleweed (Snapshot: 20201125) KDE Plasma 5
    2x Leap 15.2 KDE Plasma 5

  7. #7
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    3,457

    Default Re: Clean delete USB

    Quote Originally Posted by tannington View Post
    Yes, of course or, an oxyacetylene torch …

  8. #8
    Join Date
    Sep 2013
    Location
    Norfolk, UK
    Posts
    1,691

    Default Re: Clean delete USB

    Quote Originally Posted by dcurtisfra View Post
    Yes, of course or, an oxyacetylene torch …
    Outdoors of course, else one may set off one's smoke alarm. ...
    Regards, Paul

    2x Tumbleweed (Snapshot: 20201125) KDE Plasma 5
    2x Leap 15.2 KDE Plasma 5

  9. #9
    Join Date
    Feb 2010
    Location
    Germany
    Posts
    3,457

    Cool Re: Clean delete USB

    Quote Originally Posted by tannington View Post
    else one may set off one's smoke alarm. ...
    Huh???!!! Since when is the use of welding equipment and forges in a workshop or smithy a smoke alarm issue? … …

  10. #10
    Join Date
    Sep 2013
    Location
    Norfolk, UK
    Posts
    1,691

    Default Re: Clean delete USB

    Quote Originally Posted by dcurtisfra View Post
    Huh???!!! Since when is the use of welding equipment and forges in a workshop or smithy a smoke alarm issue? … …
    Way off original topic now....

    Depends what the flame is being played upon, if it's generating smoke there's the possibility an alarm would trigger.

    I've set of a domestic smoke alarm, unintentionally, whilst simply using a portable propane torch when doing a little plumbing work, soldering 15mm copper water pipe fittings, presumably by smoke from the flux used. Made a change from the usual burnt toast alarm though...
    Regards, Paul

    2x Tumbleweed (Snapshot: 20201125) KDE Plasma 5
    2x Leap 15.2 KDE Plasma 5

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •