USB Pointers & Tricks

The following two articles offer excellent assistance in getting troublesome USBs (broken USBs) to function:

  1. To find your USB, in terminal enter:
    $ fdisk -l
  2. Next to format the USB in terminal enter:
    $ sudo mkfs.<format> <USB-device>
    As an example: $ sudo mkfs.ntfs /dev/sdb1

Entering (MXLinux Tool) “sudo live-usb-maker partition-clear” in terminal will clear out all partition tables on a usb-stick without filling the drive with zeroes which is very slow and can damage devices. Sometimes Gparted has trouble dealing with usb-sticks if the partitions tables are not completely cleared out.

udiskie -nt” terminal cli may have success with certain issues repairing usb keys.

Force Mounting a USB drive:

  1. First you must identify or create a mount point. (see above)
  2. To create a mount point in terminal mode is pretty easy enter:
    $ sudo mkdir /run/mount/usb
  3. Next in terminal enter the following where:
    ntfs-3g is replaced by your usb format (ie. ext4, fat32 or other)
    $ sudo mount -t ntfs-3g /dev/sdb1 /run/mount/usb -o force

live-usb-maker partition-clear

Provides a nice selection screen for all identified USB / SDcard removable media.

And partition-clear performs exactly the next two tools while providing a degree of safety for you system; it only allows the selection of removable devices.

To backup a partition table use:

$ sgdisk –backup=sdX_table.bak /dev/sdX

To restore the table:

$ sgdisk –load-backup=sdX_table.bak /dev/sdX

To make a backup while wiping the filesystem signatures use:

$ wipefs –all –backup /dev/sdX

To restore the signatures:

$ dd if=$backup_file of=/dev/sdX seek=$((OFFSET)) bs=1 conv=notrunc

Replace $backup_file with the name of the backup file, which will be called wipefs-sdX-OFFSET.bak, use the OFFSET number in the seek option.


The Following Approaches are VERY Risky!!

Wipe a partition table with sgdisk ( https://packages.debian.org/stretch/gdisk ) — VERY Dangerous:

$ sgdisk –zap-all /dev/sdX

Note: Be careful with the drive letter though!

For USB sticks holding hybrid ISO images use the wipefs command which can be found in the util-linux package (Also VERY Dangerous).

$ wipefs -a /dev/sdX

That should clear all traces:

$ wipefs /dev/sdb

DEVICE OFFSET TYPE UUID LABEL
sdb 0x8001 iso9660 2019-06-15-21-06-55-00 SHARPBANG_BUSTER

$ wipefs -a /dev/sdb

/dev/sdb: 5 bytes were erased at offset 0x00008001 (iso9660): 43 44 30 30 31

$ wipefs /dev/sdb

Notes:

  • Once you have the USB mounted, you may use GParted or similar for additional disk management tasks.
  • Usually Gparted does not like to work on mounted devices so it is not a good idea to mount a device in order to use gparted on it. The standard procedure is the opposite: unmount the device before trying to use gparted.

Special Thanks to BitJam, fehlix,Head_on_a_Stick & oops for their help!