LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 11-04-2013, 09:16 AM   #1
DBabo
Member
 
Registered: Feb 2003
Distribution: Fedora {latest}
Posts: 568

Rep: Reputation: 40
Question mount usb with several partitions


i think i have a brain freeze @ the moment... any suggestions are welcomed:
The ideal outcome:
mount to the default location, either first partition of the USB drive or all partitions into corresponding subdirs, e.g /media/usb/part1, /media/usb/part2

Situation:
there is a generic usb drive or for this matter any device (usb/ndd/sdd) with one or many partitions.
I want to have an easier way to mount/umount the device then "su-", check for partitions and mount.

What i have done:
a. dug out old udev scrips that map devices to a link e,g /dev/cardreader/SD*
b. in case of one partition i'll have /dev/cardreader/SD1, in case of 2 partitions - /dev/cardreader/SD1, /dev/cardreader/SD2
c. blindly staring @ fstab with semi-retarded ideas of writing 10^12 lines for each possible partition.
d. gave up and posted a question here in hopes of help
 
Old 11-04-2013, 09:26 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,143

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
Typically a USB drive just has one FAT partition and you mount it like:
Code:
mount /dev/sdb1 /mnt
You can get the actual partitions on /dev/sdb (say) and loop over them in a script:
Code:
PARTS=$(awk '/sdb[0-9]/ {print $4}' </proc/partitions)
for p in $PARTS ; do
The loop can make a directory for each partition and mount it as you wish.
 
Old 11-04-2013, 11:59 AM   #3
DBabo
Member
 
Registered: Feb 2003
Distribution: Fedora {latest}
Posts: 568

Original Poster
Rep: Reputation: 40
Quote:
Originally Posted by smallpond View Post
Typically a USB drive just has one FAT partition and you mount it like:...
Thank you . so nothing in fstab can do the "magic"?
 
Old 11-04-2013, 01:24 PM   #4
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 4,143

Rep: Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264Reputation: 1264
If you know the partitions in advance you can have them in fstab, but fstab can't do variables.
 
  


Reply

Tags
flash drive, mount usb, partition



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Mount hangs while trying to mount luks partitions after upgrade to 12.2 MeatPuppet Slackware 5 03-08-2009 07:57 AM
Can't mount partitions from HDA, But will mount partitions from HDB Colonel-1990 Linux - Hardware 13 08-09-2008 09:59 AM
mount directories of partitions, not partitions possible? kpachopoulos Linux - General 9 09-02-2007 07:25 PM
Help Me, automatically mount ntfs partitions on USB and Firewire drives RottenMutt Fedora 1 11-01-2006 12:27 PM
mount usb module then mount usb hard drive guanyu Linux - Hardware 1 10-08-2003 11:50 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:49 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration