"Fixing" problem USBs

Here is where you can post tips and tricks to share with other users of MX. Do not ask for help in this Forum.
Message
Author
User avatar
manyroads
Posts: 2624
Joined: Sat Jun 30, 2018 6:33 pm

Re: "Fixing" problem USBs

#11 Post by manyroads »

fehlix wrote: Mon Jun 17, 2019 5:42 pm [...]
With running sgdisk and wipfs you have the chance twice to wipe your system. :footinmouth:
So I would not really recommend those "dangerous" commands to "newbies" nor to "oldies", as with one wrong pressed key your system might be wiped.
:puppy:
But it is only after you delete an entire drive full of data that you truly understand the value of a backup. :eek: :eek:
Pax vobiscum,
Mark Rabideau - ManyRoads Genealogy -or- eirenicon llc. (geeky stuff)
i3wm, bspwm, hlwm, dwm, spectrwm ~ Linux #449130
"For every complex problem there is an answer that is clear, simple, and wrong." -- H. L. Mencken

User avatar
Head_on_a_Stick
Posts: 919
Joined: Sun Mar 17, 2019 3:37 pm

Re: "Fixing" problem USBs

#12 Post by Head_on_a_Stick »

To backup a partition table use

Code: Select all

sgdisk --backup=sdX_table.bak /dev/sdX
To restore the table:

Code: Select all

sgdisk --load-backup=sdX_table.bak /dev/sdX
To make a backup while wiping the filesystem signatures use

Code: Select all

wipefs --all --backup /dev/sdX
To restore the signatures:

Code: Select all

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.
mod note: Signature removed, please read the forum rules

User avatar
manyroads
Posts: 2624
Joined: Sat Jun 30, 2018 6:33 pm

Re: "Fixing" problem USBs

#13 Post by manyroads »

Head_on_a_Stick wrote: Tue Jun 18, 2019 1:34 am [...]
Thank you @Head_on_a_Stick. I have added all of your latest suggestions. :number1:
Pax vobiscum,
Mark Rabideau - ManyRoads Genealogy -or- eirenicon llc. (geeky stuff)
i3wm, bspwm, hlwm, dwm, spectrwm ~ Linux #449130
"For every complex problem there is an answer that is clear, simple, and wrong." -- H. L. Mencken

User avatar
oops
Posts: 1620
Joined: Tue Apr 10, 2018 5:07 pm

Re: "Fixing" problem USBs

#14 Post by oops »

... Too many roads to "Fixing" problem USBs ;-)

Here I used "udiskie -nt" with success for some issues with some usb keys.
Pour les nouveaux utilisateurs: Alt+F1 pour le manuel, ou FAQS, MX MANUEL, et Conseils Debian - Info. système “quick-system-info-mx” (QSI) ... Ici: System: MX-19_x64 & antiX19_x32

User avatar
manyroads
Posts: 2624
Joined: Sat Jun 30, 2018 6:33 pm

Re: "Fixing" problem USBs

#15 Post by manyroads »

oops wrote: Tue Jun 18, 2019 8:44 am ... Too many roads to "Fixing" problem USBs ;-)

Here I used "udiskie -nt" with success for some issues with some usb keys.
Thank you! :number1: I have added your contribution.
Pax vobiscum,
Mark Rabideau - ManyRoads Genealogy -or- eirenicon llc. (geeky stuff)
i3wm, bspwm, hlwm, dwm, spectrwm ~ Linux #449130
"For every complex problem there is an answer that is clear, simple, and wrong." -- H. L. Mencken

User avatar
oops
Posts: 1620
Joined: Tue Apr 10, 2018 5:07 pm

Re: "Fixing" problem USBs

#16 Post by oops »

Your are welcome manyroads ... the idea was from handy:
viewtopic.php?p=500514#p500514
Pour les nouveaux utilisateurs: Alt+F1 pour le manuel, ou FAQS, MX MANUEL, et Conseils Debian - Info. système “quick-system-info-mx” (QSI) ... Ici: System: MX-19_x64 & antiX19_x32

User avatar
Head_on_a_Stick
Posts: 919
Joined: Sun Mar 17, 2019 3:37 pm

Re: "Fixing" problem USBs

#17 Post by Head_on_a_Stick »

fehlix wrote: Mon Jun 17, 2019 5:42 pm And partition-clear shall actually exactly do what the other two tools supposed to do. In addition partition-clear gives you a kind of safety measure for you system,
as it will only provide you found USB device to select from.
With running sgdisk and wipfs you have the chance twice to wipe your system. :footinmouth:
So I would not really recommend those "dangerous" commands to "newbies" nor to "oldies", as with one wrong pressed key your system might be wiped.
:puppy:
Well I don't really agree that the live-usb-maker tool is necessarily any safer than the simple commands I listed because the all it does it list any connected drives that have "1" in /sys/block/sdX/removable and this would include any USB-attached drives.

Here's an example to illustrate why your tool can be dangerous:

Code: Select all

demo@mx1:~
$ sudo live-usb-maker partition-clear
Creating new config file /root/.config/live-usb-maker/live-usb-maker.conf
===============================================================================
Starting live-usb-maker
===============================================================================
The live media is not mounted
                                                                                                  
Please select the target usb device                                                               
  > sdb       3.8G Generic Flash Disk                                                             
  > sdc     931.5G TOSHIBA MK1059GSM                                                              
Press <Enter> to select the highlighted entry                                                     
Use 'h' for help, 'r' to redraw, 'q' to quit
In this case /dev/sdc is my backup drive and your tool is offering to wipe it for me :eek:

Not "safe" at all...

I would recommend that people use their brains rather than rely on a third-party tool that may offer false reassurances.

To make sure the correct device is used for my suggested commands first run this command in a terminal:

Code: Select all

dmesg -w
^ That will print out the kernel ring buffer messages and any new messages will be added to the bottom of the screen.

Now plug in the problematic USB stick and wait for the new messages, for example:

Code: Select all

demo@mx1:~
$ dmesg -w
[list of old kernel messages]
[ 1197.183867] usb 1-4: new high-speed USB device number 5 using xhci_hcd
[ 1197.315852] usb 1-4: New USB device found, idVendor=0951, idProduct=1665, bcdDevice= 1.00
[ 1197.315856] usb 1-4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 1197.315858] usb 1-4: Product: DataTraveler 2.0
[ 1197.315860] usb 1-4: Manufacturer: Kingston
[ 1197.315862] usb 1-4: SerialNumber: 60A44C413E29FE61EB4CF82B
[ 1197.316592] usb-storage 1-4:1.0: USB Mass Storage device detected
[ 1197.317441] scsi host3: usb-storage 1-4:1.0
[ 1198.396398] scsi 3:0:0:0: Direct-Access     Kingston DataTraveler 2.0 1.00 PQ: 0 ANSI: 4
[ 1198.397247] sd 3:0:0:0: Attached scsi generic sg3 type 0
[ 1198.397515] sd 3:0:0:0: [sdd] 15131636 512-byte logical blocks: (7.75 GB/7.21 GiB)
[ 1198.397784] sd 3:0:0:0: [sdd] Write Protect is off
[ 1198.397786] sd 3:0:0:0: [sdd] Mode Sense: 45 00 00 00
[ 1198.398033] sd 3:0:0:0: [sdd] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[ 1198.405287] sd 3:0:0:0: [sdd] Attached SCSI removable disk
^ So we can see that a new (removable) drive has been added, a Kingston DataTraveler USB 2.0 device and this has been assigned to /dev/sdd so that is what we should use in the sgdisk & wipefs commands.

Even newbies & oldies should be able to follow this method without risk of being confused :happy:
mod note: Signature removed, please read the forum rules

User avatar
fehlix
Developer
Posts: 10383
Joined: Wed Apr 11, 2018 5:09 pm

Re: "Fixing" problem USBs

#18 Post by fehlix »

Head_on_a_Stick wrote: Tue Jun 18, 2019 2:38 pm Not "safe" at all...
Yes, you can clear your usb-backup drive, if you want :footinmouth:
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB

User avatar
sunrat
Posts: 636
Joined: Mon Mar 28, 2016 9:54 pm

Re: "Fixing" problem USBs

#19 Post by sunrat »

Head_on_a_Stick wrote: Tue Jun 18, 2019 2:38 pmI would recommend that people use their brains rather than rely on a third-party tool that may offer false reassurances.
If people used their brains the forums would be really quiet! :p :happy:

User avatar
manyroads
Posts: 2624
Joined: Sat Jun 30, 2018 6:33 pm

Re: "Fixing" problem USBs

#20 Post by manyroads »

sunrat wrote: Tue Jun 18, 2019 7:00 pm
Head_on_a_Stick wrote: Tue Jun 18, 2019 2:38 pmI would recommend that people use their brains rather than rely on a third-party tool that may offer false reassurances.
If people used their brains the forums would be really quiet! :p :happy:
+8 :lipsrsealed: :happy: :number1:
Pax vobiscum,
Mark Rabideau - ManyRoads Genealogy -or- eirenicon llc. (geeky stuff)
i3wm, bspwm, hlwm, dwm, spectrwm ~ Linux #449130
"For every complex problem there is an answer that is clear, simple, and wrong." -- H. L. Mencken

Post Reply

Return to “Tips & Tricks by users”