why only "mount /dev/sda /mnt/usb" works and not "mount /dev/sda1..." ?
Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
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.
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.
[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")
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.