USB Flash or USB HD ???

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Post Reply
Message
Author
User avatar
LazY Puppy
Posts: 1934
Joined: Fri 21 Nov 2014, 18:14
Location: Germany

USB Flash or USB HD ???

#1 Post by LazY Puppy »

Hi.

Is there a way in shell script of how to find out if a external drive is usb flash or usb hd ?

Thanks.
RSH

"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:

learnhow2code

Re: USB Flash or USB HD ???

#2 Post by learnhow2code »

for some reason, lsusb isnt working in tahr. otherwise i would suggest you start here:

Code: Select all

lsusb | egrep -v "root hub|Mouse|Keyboard"
that will list the things you have plugged in to usb. from there, im not sure how "automatic" you can make it.

you could try looking for "xternal" but for example, if you plug in a Sandisk Cruzer it doesnt say "flash drive" it says the name and model. you may know a Cruzer is a flash drive not an external, but that doesnt make anything easy for you.

do let me know if lsub works in your version of puppy.

this isnt a lot better:

Code: Select all

find /sys/devices/ | egrep "roduct|eviceClass" | xargs cat | sort | uniq

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

Re: USB Flash or USB HD ???

#3 Post by rcrsn51 »

learnhow2code wrote:for some reason, lsusb isnt working in tahr.
Works for me.

User avatar
LazY Puppy
Posts: 1934
Joined: Fri 21 Nov 2014, 18:14
Location: Germany

#4 Post by LazY Puppy »

All of this doesn't have info about being usb hd or usb flash.

I wonder how Puppy handles this as its behavior on a pup save is different on usb hd and usb flash (pupmode 12 & 13).

Or is this different behavior just dependent on the value of PUPMODE= ???
RSH

"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:

learnhow2code

#5 Post by learnhow2code »

LazY Puppy wrote:All of this doesn't have info about being usb hd or usb flash.
correct.
I wonder how Puppy handles this as its behavior on a pup save is different on usb hd and usb flash (pupmode 12 & 13).
then we should have a look at the code. you dont know where to find the files for pup save do you? (or the filename of the program?)
Or is this different behavior just dependent on the value of PUPMODE= ???
my first guess was about partition types, but your guess is great.

if you help me find the files//programs in question, i will be happy to check their code out.

User avatar
LazY Puppy
Posts: 1934
Joined: Fri 21 Nov 2014, 18:14
Location: Germany

#6 Post by LazY Puppy »

Probably /etc/rc.d/rc.shutdown ?
Or /usr/sbin/shutdownconfig ?

At least I had modifications on these files to shutdown without option to create a save file at all.
RSH

"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:

learnhow2code

#7 Post by learnhow2code »

LazY Puppy wrote:Probably /etc/rc.d/rc.shutdown ?
Or /usr/sbin/shutdownconfig ?
thanks.

so im doing this:

cat /etc/rc.d/rc.shutdown | cat -n | grep SAVE

theres a lot of stuff.

this could be a good time to talk more about what youre trying to accomplish. im not sure puppy actually knows whether a drive is usb or usb external, per se. it may know similar information that helps it do something specific.

so what specifically do you want to know for? that might make it easier to find a solution or way around this.

Sailor Enceladus
Posts: 1543
Joined: Mon 22 Feb 2016, 19:43

#8 Post by Sailor Enceladus »

I just use "pmedia=ataflash" on both flash stick and hard drive so I can get a save icon. On my dads desktop to boot from flash stick you have to select USB HDD and not USB FDD in the Bios menu as FDD apparently means 1.44MB USB Floppy drive - lol.

learnhow2code

#9 Post by learnhow2code »

Sailor Enceladus wrote:I just use "pmedia=ataflash" on both flash stick and hard drive so I can get a save icon. On my dads desktop to boot from flash stick you have to select USB HDD and not USB FDD in the Bios menu as FDD apparently means 1.44MB USB Floppy drive - lol.
so perhaps running env would provide something lp is looking for?

User avatar
LazY Puppy
Posts: 1934
Joined: Fri 21 Nov 2014, 18:14
Location: Germany

#10 Post by LazY Puppy »

this could be a good time to talk more about what youre trying to accomplish. im not sure puppy actually knows whether a drive is usb or usb external, per se. it may know similar information that helps it do something specific.

so what specifically do you want to know for? that might make it easier to find a solution or way around this.
The term 'external' is somehow useless or not needed. Main cause is usb flash or usb hd.

I would like to make my installer script modifying/preparing the preset of menu.lst file automatically for pmedia=usbflash or pmedia=usbhd after installing.
RSH

"you only wanted to work your Puppies in German", "you are a separatist in that you want Germany to secede from Europe" (musher0) :lol:

No, but I gave my old drum kit away for free to a music store collecting instruments for refugees! :wink:

learnhow2code

#11 Post by learnhow2code »

ive probably spent an hour or two on this, and im not convinced (except for the functionality in puppy, which could be just a user-set variable) that its possible to do what you want.

this is only after a lot of looking. maybe its out there. theres a bash script by gregkh of systemd fame, that is included in devuan anyway, called usb-devices. honestly, most of these "list usb" programs are going to return similar information--

comparing thumb drives and externals with various utilities, im not finding a rule that wouldnt require a table of all possible devices (paried with info on whether they are external or not.) you can try looking through the output of usb-devices, lsusb, and udisks --dump but dont get excited. i thought grepping for ata might help. udisks says the thumb drive has "rotational media" but we know that isnt the case. udisks2 isnt more helpful.

i havent only been looking for stuff on listing usb and drive info. no, ive spent a lot of time looking for external drives udisks, determine external, i can show you a link on how to figure it out in c# on windows... not pertinent to your question.

at the top of that page they say it isnt possible to tell an enclosure from a thumb drive. but if you find a way, id love to read your post about it. im sure the computer knows, but we are trying to find an easy-to-use interface. does puppy really know without asking the user?

User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

#12 Post by Pete »

@LazY Puppy
Have you tried lsblk? Maybe it's of help.

Code: Select all

lsblk -b /dev/sdc1 -o RM   
Change sdc1 to what ever you drive is.
(BTW the -o above is a lower case letter o, not a zero).

If the output gives a RM and a 1, then it's removable if it's a zero, then it's not.

If you just a 1 or 0 just pipe it thru grep:

Each drive has a removable flag (set or not) but be aware that not all USB sticks/flash drives report this correctly.
Last edited by Pete on Thu 23 Jun 2016, 11:16, edited 1 time in total.

User avatar
Pete
Posts: 660
Joined: Sun 02 Mar 2014, 18:36

#13 Post by Pete »

Right, did some more snooping around and you can use:

Code: Select all

cat /sys/block/sdc/removable
You should get a 1 = yes, removable or 0 = not removable.
Adjust sdc to suit yours.

BIG NOTE:

Be careful as some USB flash drives report themselves as fixed even though they are not.
Something to do with Win 8 certification.

User avatar
Burn_IT
Posts: 3650
Joined: Sat 12 Aug 2006, 19:25
Location: Tamworth UK

#14 Post by Burn_IT »

"Just think of it as leaving early to avoid the rush" - T Pratchett

Post Reply