[opensuse] scripting usb pen recovery
Hello, I have a bunch of usb pen written as various openSUSE dvd/live stick. I want to reset them to be ordinary ones. The SDB is here: https://en.opensuse.org/index.php?title=SDB:Live_USB_stick&diff=next&oldid=77369 but it's not handy for many copies. It's not that difficult to copy this in a script, but it makes it a very dangerous script in case of sdX X error :-( I noticed imagewriter knows if a plugged device is usb pen or not is there a way to do the same in a script? May be detect if the pen is an iso image before acting? thanks jdd -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2016-10-20 09:14, jdd wrote:
I noticed imagewriter knows if a plugged device is usb pen or not
is there a way to do the same in a script? May be detect if the pen is an iso image before acting?
Telcontar:~ # lsblk lsblk --output NAME,LABEL,MODEL,SERIAL,ROTA,TYPE,TRAN,REV,VENDOR /dev/sde lsblk: lsblk: not a block device NAME LABEL MODEL SERIAL ROTA TYPE TRAN REV VENDOR sde STORE N GO 1 disk usb 1.0 Verbatim └─sde1 STORE N GO 1 part Telcontar:~ # :-) I don't know if that is what imagewriter writer uses, but it is a start. You can also detect if the device is mounted, and baulk if it is. Or mount and check contents. List on the screen and ask the user to accept. -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)
Le 20/10/2016 à 11:08, Carlos E. R. a écrit :
On 2016-10-20 09:14, jdd wrote:
I noticed imagewriter knows if a plugged device is usb pen or not
is there a way to do the same in a script? May be detect if the pen is an iso image before acting?
Telcontar:~ # lsblk lsblk --output NAME,LABEL,MODEL,SERIAL,ROTA,TYPE,TRAN,REV,VENDOR /dev/sde lsblk: lsblk: not a block device NAME LABEL MODEL SERIAL ROTA TYPE TRAN REV VENDOR sde STORE N GO 1 disk usb 1.0 Verbatim └─sde1 STORE N GO 1 part Telcontar:~ #
:-)
I don't know if that is what imagewriter writer uses, but it is a start. You can also detect if the device is mounted, and baulk if it is. Or mount and check contents. List on the screen and ask the user to accept.
I tried (since my mail) several solutions, none works as expected. the solution above detects also my 5 Tb disk I don't want to format :-)) I can detect the openSUSE branded USB pen by id ls /dev/disk/by-id/ | grep Flash_D seems to detect any of them, whatever is written on it #ls /dev/disk/by-id/ | grep Flash_D usb-General_USB_Flash_Disk_0531110000000324-0:0 usb-General_USB_Flash_Disk_0531110000000324-0:0-part1 the best one I found now is blkid -c /dev/null | grep iso9660 that seems to detect iso images. I will probably also detect iso DVD, but these ones can't be erased :-) to be continued :-) thanks jdd -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2016-10-20 11:25, jdd wrote:
Le 20/10/2016 à 11:08, Carlos E. R. a écrit :
I don't know if that is what imagewriter writer uses, but it is a start. You can also detect if the device is mounted, and baulk if it is. Or mount and check contents. List on the screen and ask the user to accept.
I tried (since my mail) several solutions, none works as expected. the solution above detects also my 5 Tb disk I don't want to format :-))
I can detect the openSUSE branded USB pen by id
ls /dev/disk/by-id/ | grep Flash_D
seems to detect any of them, whatever is written on it
#ls /dev/disk/by-id/ | grep Flash_D usb-General_USB_Flash_Disk_0531110000000324-0:0 usb-General_USB_Flash_Disk_0531110000000324-0:0-part1
the best one I found now is
blkid -c /dev/null | grep iso9660
that seems to detect iso images. I will probably also detect iso DVD, but these ones can't be erased :-)
to be continued :-)
Yes, checking for a particular string that the ISO images have is a good route. Just now I thought of hdparm -i/-I, but most info fields are blank. -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)
Finally I didn't found a good way. So to reset my usb pens, I used a blank new one in a port (i) and the one that needed reset in an other in an other port (j) and issued dd if=/dev/sdi of=/dev/sdj count=100 all the pens plugged after the first one on a sequence seemed to get the same j port (and anyway I don't have any risk to have a master disk there), so I could reset my lot of disks very fast. jdd -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Op vrijdag 21 oktober 2016 10:45:10 CEST schreef jdd <jdd@dodin.org> :
Finally I didn't found a good way.
So to reset my usb pens, I used a blank new one in a port (i) and the one that needed reset in an other in an other port (j)
and issued
dd if=/dev/sdi of=/dev/sdj count=100
all the pens plugged after the first one on a sequence seemed to get the same j port (and anyway I don't have any risk to have a master disk there), so I could reset my lot of disks very fast.
jdd
Resetting a pen drive ( haven't read the entire thread ): dd if=/dev/zero of=/dev/sdX bs=1M count=50 -- Gertjan Lettink, a.k.a. Knurpht openSUSE Board Member openSUSE Forums Team -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
participants (3)
-
Carlos E. R.
-
jdd
-
Knurpht - Gertjan Lettink