LinuxQuestions.org
Help answer threads with 0 replies.
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 05-18-2009, 09:14 AM   #1
gromot
LQ Newbie
 
Registered: May 2009
Posts: 6

Rep: Reputation: 0
why only "mount /dev/sda /mnt/usb" works and not "mount /dev/sda1..." ?


Hi,

I have a few USB flash-disks which probably have odd formatting. When I put them in:
Code:
root@zeus root#   Vendor: USB2.0    Model: Flash Disk        Rev: 2.50
  Type:   Direct-Access                      ANSI SCSI revision: 02
SCSI device sda: 4108288 512-byte hdwr sectors (2103 MB)
sda: Write Protect is off
sda: assuming drive cache: write through
SCSI device sda: 4108288 512-byte hdwr sectors (2103 MB)
sda: Write Protect is off
sda: assuming drive cache: write through
sd 4:0:0:0: Attached scsi removable disk sda

root@zeus root# mount /dev/sda1 /mnt/usb
mount: /dev/sda1 is not a valid block device
root@zeus root# mount /dev/sda /mnt/usb
root@zeus root#
the end part of the dmesg:
Code:
usb 1-1: new full speed USB device using pxa27x-ohci and address 7
usb 1-1: configuration #1 chosen from 1 choice
scsi5 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 7
usb-storage: waiting for device to settle before scanning
  Vendor: USB2.0    Model: Flash Disk        Rev: 2.50
  Type:   Direct-Access                      ANSI SCSI revision: 02
SCSI device sda: 4108288 512-byte hdwr sectors (2103 MB)
sda: Write Protect is off
sda: Mode Sense: 0b 00 00 08
sda: assuming drive cache: write through
SCSI device sda: 4108288 512-byte hdwr sectors (2103 MB)
sda: Write Protect is off
sda: Mode Sense: 0b 00 00 08
sda: assuming drive cache: write through
 sda: unknown partition table
sd 5:0:0:0: Attached scsi removable disk sda
usb-storage: device scan complete
Before mounting, fdisk -l returns:
Code:
root@zeus root# fdisk -l

Disk /dev/hda: 1025 MB, 1025998848 bytes
16 heads, 63 sectors/track, 1988 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1   *           1        1987     1001416+   6  FAT16

Disk /dev/sda: 2103 MB, 2103443456 bytes
65 heads, 62 sectors/track, 1019 cylinders
Units = cylinders of 4030 * 512 = 2063360 bytes

This doesn't look like a partition table
Probably you selected the wrong device.

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   ?      193086      476339   570754815+  72  Unknown
Partition 1 has different physical/logical beginnings (non-Linux?):
     phys=(357, 116, 40) logical=(193085, 54, 11)
Partition 1 has different physical/logical endings:
     phys=(357, 32, 45) logical=(476338, 54, 51)
Partition 1 does not end on cylinder boundary.
/dev/sda2   ?       41859      522263   968014120   65  Novell Netware 386
Partition 2 has different physical/logical beginnings (non-Linux?):
     phys=(288, 115, 43) logical=(41858, 28, 47)
Partition 2 has different physical/logical endings:
     phys=(367, 114, 50) logical=(522262, 30, 42)
Partition 2 does not end on cylinder boundary.
/dev/sda3   ?      463991      944395   968014096   79  Unknown
Partition 3 has different physical/logical beginnings (non-Linux?):
     phys=(366, 32, 33) logical=(463990, 28, 30)
Partition 3 has different physical/logical endings:
     phys=(357, 32, 43) logical=(944394, 29, 39)
Partition 3 does not end on cylinder boundary.
/dev/sda4   ?           1      902538  1818613248    d  Unknown
Partition 4 has different physical/logical beginnings (non-Linux?):
     phys=(372, 97, 50) logical=(0, 0, 1)
Partition 4 has different physical/logical endings:
     phys=(0, 10, 0) logical=(902537, 38, 30)
Partition 4 does not end on cylinder boundary.

Partition table entries are not in disk order
However if I mount it as mount /dev/sda /mnt/usb everything works fine. I can create files in /mnt/usb and see them on the other system.

Do you have any idea why is it like this? I know I can reformat the flash-disks (checked it and it works with sda1), but I have got a lot of them and would prefer to use them right from the box. I mount them in the software and I am not sure if it is a good idea to try to mount as sda1 and then as sda if no success.

Can anybody explain me why it is like this?

Best regards,
gromot
 
Old 05-18-2009, 12:19 PM   #2
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,393
Blog Entries: 1

Rep: Reputation: 63
You don't ***NEED*** a partition table in a disk at all.
Partitioning the disk is more like a convenience feature to have one or more logical areas in the disk.
In this case, the filesystem was created on the whole device, not in a particular partition.
Floppy disks, (do you remember ?) don't have partition tables, just to mention another well known storage media that don't have/need a partition table.

However, this is application dependent, O.S. dependent and file system dependent.
For example, LVM expects a partition of a specific type, but this is just a safe measure to avoid one to add to LVM a partition which is already in use for regular access.
 
Old 05-19-2009, 01:55 AM   #3
gromot
LQ Newbie
 
Registered: May 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Thank you,

this explains a lot.

So in this case is it correct (good programming practice) to try to mount as /dev/sda1 and if failed try again as /dev/sda?

Target hardware has only one USB port so it will always be sdA or sdA_. When user select on of the GUI options, application will display the appropriate message and will wait for the USB disk. At the moment I am only trying to mount as /dev/sda1.
Software is in C++ + GTK.

Regards,
gromot
 
Old 05-19-2009, 02:06 AM   #4
gromot
LQ Newbie
 
Registered: May 2009
Posts: 6

Original Poster
Rep: Reputation: 0
... or is there any better method to detect it from the software?

regards,
gromot
 
Old 05-19-2009, 02:09 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,207

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
I recently bought an 8 Gig that displayed similar behaviour - must have had some M$soft crap at the front.
I deleted the partitions it thought it had, and created one VFAT (under Linux). Everything now works everywhere as expected - Vista included.
 
Old 05-19-2009, 02:50 AM   #6
gromot
LQ Newbie
 
Registered: May 2009
Posts: 6

Original Poster
Rep: Reputation: 0
I did the same with my usb disks, but I would like my software to be able to use USB disks with the partition table and without, as this type of formatting you can encounter very often.
 
Old 05-19-2009, 08:45 AM   #7
marozsas
Senior Member
 
Registered: Dec 2005
Location: Campinas/SP - Brazil
Distribution: SuSE, RHEL, Fedora, Ubuntu
Posts: 1,393
Blog Entries: 1

Rep: Reputation: 63
I guess you can check if there is a partition table first. If it exist, you can check the type of filesystem in each partition. In bash you can use "file -s /dev/sda1" and get "Linux rev 1.0 ext3 filesystem data" or "LVM2 (Linux Logical Volume Manager)", or "VFAT 32 bits" or even "x86 boot sector, mkdosfs boot message display".

If there is no partition table you can check if there is a filesystem on the primary device node, I mean, "/dev/sda" and check again if there is a valid file system on it.

Depending on what kind of operation and care, you can mount it read-only and only if succeeded you remount it in read-write mode for full access. This is the way the init scripts do when mounting the root partition by the way.
 
Old 05-19-2009, 10:18 AM   #8
gromot
LQ Newbie
 
Registered: May 2009
Posts: 6

Original Poster
Rep: Reputation: 0
Thank you again,

This is what I get on my desktop:
Code:
[gromot@localhost Projects]$ file -s /dev/sda1
/dev/sda1: ERROR: cannot open `/dev/sda1' (No such file or directory)
[gromot@localhost Projects]$ file -s /dev/sda
/dev/sda: writable, no read permission
[gromot@localhost Projects]$
However on the target device the 'file' command is unknown. I know I can install additional library, but I've decided to iterate through the list of device sources (constant char[] array in my code) trying to mount using each of them. It works fine.

Target system is very limited and I do not expect to see the device as 'sdb' so this solution is acceptable (constant array has now only two items: "/dev/sda1" and "/dev/sda")

Thank you once again,
regards,
gromot.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 userspace directory as "/dev" block device for USB Gadget API? Robert_A Programming 5 02-17-2011 02:26 AM
FC6: "mount: could not find filesystem '/dev/root'" sancho Fedora - Installation 16 04-07-2010 08:35 PM
FC6: "mount: could not find filesystem '/dev/root'" cheerful Fedora - Installation 2 07-27-2007 03:36 PM
How do I switch the labels "/dev/sda1" with "/dev/sda3" vonst Linux - General 10 05-27-2006 10:48 PM
Writing to "/dev/usb/hiddev*" and to "/proc/bus/usb/00B/00S" throw an arror EI stpg Programming 0 07-14-2004 05:44 AM


All times are GMT -5. The time now is 06:58 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration