DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 9th August 2015
betweendayandnight betweendayandnight is offline
friendly
 
Join Date: Jul 2015
Posts: 67
Default Unable to mount: Inappropriate file type or format

My box was booted up with my USB 2.0 flash drive plugged into a USB 2.0 port.

I logged in as root, opened up a terminal and typed:

Code:
mount /dev/sd1i /mnt/usb0
The error message was:

Code:
mount_msdos: /dev/sd1i on /mnt/usb0 : Inappropriate file type or format
Relevant info:

1. The USB stick was formatted as ext2 on a Ubuntu machine using gparted
2. The same stick was formatted as fat32 on the same Ubuntu machine using gparted
3. It was formatted as fat32 on a Microsoft Windows 7 machine

ntfs_3g-2014.2.15p0.tgz was installed on OpenBSD 5.8-beta
Reply With Quote
  #2   (View Single Post)  
Old 9th August 2015
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,984
Default

When you request a mount on OpenBSD, it will use the following basic procedure:
  1. If the drive has an OpenBSD disklabel, use it to determine the partition's location and format.
  2. If the drive doesn't contain an OpenBSD disklabel, use the MBR partition table to devise a virtual disklabel.
  3. Use the filesystem type in the disklabel (real or virtual) to determine which mount program to use: mount_ffs(8), mount_msdos(8), mount_ext2fs(8), mount_udf(8), mount_cd9660(8), or mount_ntfs(8).
For foreign filesystems, the mount command will only succeed if there is alignment between the MBR, the disklabel, and the filesystem format. You will need to inspect the output from # fdisk sd1 and # disklabel sd1 to determine the MBR partition type and the disklabel that is used.

If there is an incorrect filesystem type being used, you can override this by using the -t option of mount(8), or using the specific filesystem mount command from the list shown in step 3 above.

Last edited by jggimi; 9th August 2015 at 08:51 AM. Reason: use the word "foreign" for filesystems in MBR partitions, and other minor corrections
Reply With Quote
  #3   (View Single Post)  
Old 10th August 2015
betweendayandnight betweendayandnight is offline
friendly
 
Join Date: Jul 2015
Posts: 67
Default

Quote:
Originally Posted by jggimi View Post
You will need to inspect the output from # fdisk sd1 and # disklabel sd1 to determine the MBR partition type and the disklabel that is used.
Below are the results of # fdisk sd1

Code:
# fdisk sd1

Disk: sd1    geometry: 1897/255/63 [30489408 Sectors]
Offset: 0    Signature: 0xAA55

       Starting         Ending         LBA info:   
#: id  C   H   S  -     C    H   S  [    start:       size ]
----------------------------------------------------------------
0: 0B  0  32  33  -  1897  210  41  [     2048:   30486528 ] Win95 FAT-32
1: 00  0   0   0  -     0    0   0  [        0:          0 ] unused
2: 00  0   0   0  -     0    0   0  [        0:          0 ] unused
3: 00  0   0   0  -     0    0   0  [        0:          0 ] unused
Below are the results of # disklabel sd1

Code:
# disklabel sd1
# /dev/rsd1c:
type: SCSI
disk: OpenBSD/amd64
label: 5.8 Install CD
duid: 0000000000000000
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 255
sectors/cylinder: 16065
cylinders: 1897
total sectors: 30489408
boundstart: 0
boundend: 30489408
drivedata: 0

16 partitions

#         size            offset      fstype     [fsize   bsize   cpg]
   a:     30489408        0           ISO9660
   c:     30489408        0           ISO9660
#
Quote:
Originally Posted by jggimi View Post
If there is an incorrect filesystem type being used, you can override this by using the -t option of mount(8), or using the specific filesystem mount command from the list shown in step 3 above.
Well, I tried the command # mount -t msdos /dev/sd1i /mnt/usb0 and the same error message, as posted in my original post, appeared.

If you don't mind, I'd appreciate more help on this issue.
Reply With Quote
  #4   (View Single Post)  
Old 10th August 2015
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,132
Default

At the MBR level, the USB partition is hardcoded as 0B, Windows FAT-32.
disklabel however, interprets the the partition as being ISO9660, the filesystem for CD's.
Is there an CD ISO image on the disk?

According to your info, the historical formatting sequence is first ext2fs, followed by two times as FAT-32. So I wonder why you would need ntfs_3g-2014.2.15p0.tgz (NTFS) to access it

Becaues mounting as FAT did not work, you could try mounting with mount_cd9660(8) as a last resort.
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump

Last edited by J65nko; 10th August 2015 at 07:32 AM. Reason: changed to mount_cd9660
Reply With Quote
  #5   (View Single Post)  
Old 10th August 2015
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,984
Default

I believe this device has a disklabel image remaining from a time when an OpenBSD CD image was written to it. (Which is unlikely to have booted, as a USB stick is not an optical device.)

The mounts are failing, because the disklabel is being used. It has no "i" partition, and the single CD9660 filesystem begins at sector 0. The MBR that is likely to be correct shows a FAT partition beginning at sector 2048.

---

To clear the bad disklabel, and replace it with a correct disklabel, you could use the disklabel(8) label editor with -d to ignore the on-disk disklabel:

# disklabel -dE sd1

At the first disklabel editor prompt, the "p" command can be used to inspect the replacement disklabel, a virtual one created solely from the MBR partition table.

> p

If correct, it can be written to disk.

> w

> q

---

Another alternative would be to zero out the leading sectors of the device, but that is brute-force. The device would need to be reformatted and data recopied. Here is an example command which will zero out the first megabyte of the device, which will remove both the MBR and, in this instance, the on-disk disklabel:

# dd if=/dev/zero of=/dev/rsd1c bs=1m count=1

The on-disk disklabel sector location depends on the architecture and the location of an OpenBSD MBR partition, if present.

Last edited by jggimi; 10th August 2015 at 08:27 AM. Reason: added explanation and alternatives
Reply With Quote
  #6   (View Single Post)  
Old 10th August 2015
betweendayandnight betweendayandnight is offline
friendly
 
Join Date: Jul 2015
Posts: 67
Default

Quote:
Originally Posted by J65nko View Post
Is there an CD ISO image on the disk?
There used to be. I thought reformatting the USB drive would remove everything, including the disklabel. This whole episode shows me that my assumption was incorrect.
Reply With Quote
  #7   (View Single Post)  
Old 10th August 2015
betweendayandnight betweendayandnight is offline
friendly
 
Join Date: Jul 2015
Posts: 67
Default

Quote:
Originally Posted by jggimi View Post
I believe this device has a disklabel image remaining from a time when an OpenBSD CD image was written to it. (Which is unlikely to have booted, as a USB stick is not an optical device.)
That's correct. I "burned" install58.fs to the USB drive and realized my machine wasn't able to install the OS using the said drive.

Quote:
Originally Posted by jggimi View Post
The mounts are failing, because the disklabel is being used.
Thanks, I learned something new today.

Can we somehow force OpenBSD to NOT use the disklabel to mount the USB flash drive?

Quote:
Originally Posted by jggimi View Post
To clear the bad disklabel, and replace it with a correct disklabel, you could use the disklabel(8) label editor with -d to ignore the on-disk disklabel:
Sorry, I'm confused here. The commands that you provided allow me to clear the bad disklabel permanently??

Quote:
Originally Posted by jggimi View Post
If correct, it can be written to disk.
If it's incorrect, what shall I do?

Quote:
Originally Posted by jggimi View Post
Another alternative would be to zero out the leading sectors of the device, but that is brute-force.
Will doing so cause physical damage to the USB flash drive?

Quote:
Originally Posted by jggimi View Post
The device would need to be reformatted and data recopied.
Can I reformat it using "gparted" package installed on my Ubuntu machine?

What data were you referring to that need to be recopied?

Quote:
Originally Posted by jggimi View Post
Here is an example command which will zero out the first megabyte of the device, which will remove both the MBR and, in this instance, the on-disk disklabel:

# dd if=/dev/zero of=/dev/rsd1c bs=1m count=1
What about /dev/rsd1a ? Do I need to zero out rsd1a as well?

Is there a corresponding command in Linux? The reason is I need to zero out a USB 3.0 flash drive that I'll plug into a USB 3.0 port. Native support for USB 3.0 protocol is still patchy in OpenBSD.

Quote:
Originally Posted by jggimi View Post
The on-disk disklabel sector location depends on the architecture and the location of an OpenBSD MBR partition, if present.
So sorry, I'm lost here.

Suppose an OpenBSD MBR partition IS present because yesterday I used OpenBSD 5.8-beta (amd64) to fdisk the USB drive in order to reformat it.

Are you saying that # dd if=/dev/zero of=/dev/rsd1c bs=1m count=1 won't work?

------
N.B.: Thanks for teaching me new stuff today.
Reply With Quote
  #8   (View Single Post)  
Old 10th August 2015
shep shep is offline
Real Name: Scott
Arp Constable
 
Join Date: May 2008
Location: Dry and Dusty
Posts: 1,507
Default

An alternative sequence of commands would be to dd(1) either the miniroot.fs or install58.fs image to your hard drive according to the FAQ and then reformat the drive using newfs(8)
#
newfs -t msdos sd1c


This would brute force the MBR and then construct an msdos (vfat) partition. Anything on the drive is overwritten and lost. My drives have always mounted as msdos after using this sequence.
Reply With Quote
  #9   (View Single Post)  
Old 10th August 2015
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,984
Default

Quote:
Originally Posted by betweendayandnight View Post
That's correct. I "burned" install58.fs to the USB drive and realized my machine wasn't able to install the OS using the said drive.
No, I think you used one of the .iso files instead.
Quote:
Can we somehow force OpenBSD to NOT use the disklabel to mount the USB flash drive?
No, you can only zero out the sector, or replace it. If OpenBSD finds a disklabel on the drive, it will use it.
Quote:
Sorry, I'm confused here. The commands that you provided allow me to clear the bad disklabel permanently??
No, they replace it. With a new, on-disk disklabel based on the MBR.
Quote:
If it's incorrect, what shall I do?
Zero out the first megabyte or so, and then recreate an MBR and reformat an FAT partition. Follow the instructions below, or follow only the first step, then use gparted on Linux or use the formatting tools on Windows.
Quote:
Will doing so cause physical damage to the USB flash drive?
Nothing here does physical damage. The stick contains 30489408 512-byte blocks. We're trying to repair a mismatch between the first block, block #0, and a block that follows, somewhere between block #1 and likely block #63.
Quote:
Can I reformat it using "gparted" package installed on my Ubuntu machine?
Sure, after clearing out the bad disklabel. You can also use OpenBSD. One set of possible instructions will follow below.
Quote:
What data were you referring to that need to be recopied?
My assumption was that you had data on the stick (from Windows or other systems) you were bringing to OpenBSD. If the stick was empty, there would be no data loss.
Quote:
What about /dev/rsd1a ? Do I need to zero out rsd1a as well?
At the moment -- you have an MBR which is likely accurate, and a disklabel which is not. It refers to an "a" partition but that's meaningless.

However, there is one special partition letter: "c". Partition "c" is always reserved, and is "the entire, physical drive." Whether there is a disklabel on the drive, an MBR on the drive, or nothing on the drive.
Quote:
Is there a corresponding command in Linux? The reason is I need to zero out a USB 3.0 flash drive that I'll plug into a USB 3.0 port. Native support for USB 3.0 protocol is still patchy in OpenBSD.
I'm sure there is, but I'm not a Linux user. If the drive can be attached to an OpenBSD USB 2.0 port, then these same commands will work.
Quote:
Suppose an OpenBSD MBR partition IS present because yesterday I used OpenBSD 5.8-beta (amd64) to fdisk the USB drive in order to reformat it.

Are you saying that # dd if=/dev/zero of=/dev/rsd1c bs=1m count=1 won't work?
That will eliminate the MBR, and eliminate the reference to the OpenBSD MBR partition, if there had been one.

If there is no OpenBSD MBR partition, the disklabel (if on disk) will be in the first few sectors. If there is an OpenBSD MBR partition, the disklabel will be in the first few sectors of the MBR partition, following the PBR (Partition Boot Record). Zeroing out the MBR would zero out the reference to the OpenBSD MBR partition and its offset from zero.

---

Creating a FAT 32 USB Stick on OpenBSD that can be used on Windows or other OSes. Device "sd1" is used in this example.
  1. Zero out the first megabyte, to clear partitions from the first logical "track" of the device. # dd if=/dev/zero of=/dev/rsd1c bs=1m count=1
  2. Create an MBR using the fdisk(8) program's interactive editor.

    # fdisk -e sd1

    At the first fdisk 1:> prompt, use the "e 0" command to edit the first partition table entry.

    You will be asked for the partition type. Reply "0b" to select a FAT-32 partition.

    You will be asked if you want to use CHS (cylinder, head, sector) addressing. Take the default, which is [n] for "no".

    You will be asked for a starting sector. You can use 2048, as in the MBR you are recreating.

    You will be asked for a size. Reply with an asterisk, "*", to refer to "the remaining space of this drive".

    You will receive a new fdisk:*1> prompt, the asterisk here means "the MBR has been changed, but not yet saved." You can use the "p" command to print out the currently edited table. Then, use "w" followed by "q" to write and quit.
  3. You will now have an MBR only, and a virtual disklabel will assign disklabel partition "i" to the newly created FAT partition. Use # disklabel sd1 to confirm.
  4. Format the partition, as FAT 32. # newfs_msdos -F 32 sd1i

Last edited by jggimi; 10th August 2015 at 10:56 AM. Reason: typos, clarity. repeatedly.
Reply With Quote
Old 10th August 2015
sacerdos_daemonis's Avatar
sacerdos_daemonis sacerdos_daemonis is offline
Real Name: Will forever be a secret.
Spam Deminer
 
Join Date: Sep 2014
Posts: 283
Default

Quote:
Originally Posted by betweendayandnight View Post
Can I reformat it using "gparted" package installed on my Ubuntu machine?
Last year I used Parted Magic to reformat a couple USB drives to FAT-32. They worked fine and I am still using them.

Quote:
What data were you referring to that need to be recopied?
Everything. Formatting destroys everything on the device or partition formatted.

jggimi posted while I was typing. His post post is better anyway.
Reply With Quote
Old 10th August 2015
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,984
Default

Quote:
Originally Posted by shep View Post
An alternative sequence of commands...
I couldn't recreate your success doing this on a test vnd(4) device just now. An existing MBR gets wiped, and the drive ends up without an MBR on it, with the entire drive formatted as a FAT16 filesystem. It can be successfully mounted, but only when using partition "c" -- since there is no partitioning metadata on the drive.
Reply With Quote
Old 10th August 2015
betweendayandnight betweendayandnight is offline
friendly
 
Join Date: Jul 2015
Posts: 67
Default

Quote:
Originally Posted by jggimi View Post
No, they replace it. With a new, on-disk disklabel based on the MBR
I suppose the replacement is permanent?

Quote:
Originally Posted by jggimi View Post
That will eliminate the MBR, and eliminate the reference to the OpenBSD MBR partition, if there had been one.
Using gparted I delete all the partitions on the USB flash drive.

Doesn't the act of deleting partitions also eliminate/delete the MBR?

Quote:
Originally Posted by jggimi View Post
Zero out the first megabyte, to clear partitions from the first logical "track" of the device. # dd if=/dev/zero of=/dev/rsd1c bs=1m count=1
Can the block size, bs, be 4m instead of 1m? On Linux, I always use bs=4M.

What is count=1 ?

Quote:
Originally Posted by jggimi View Post
Then, use "w" followed by "q" to write and quit.
Can I omit "w" and simply type "q" to write and quit?

Quote:
Originally Posted by jggimi View Post
You will now have an MBR only, and a virtual disklabel will assign disklabel partition "i" to the newly created FAT partition.
Sorry, what is your definition of "virtual disklabel"? Is there a "real" disklabel as opposed to a virtual one? How do I find out the "real disklabel" of the USB flash drive?
Reply With Quote
Old 10th August 2015
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,984
Default

Quote:
Originally Posted by betweendayandnight View Post
I suppose the replacement is permanent?
Correct.
Quote:
Using gparted I delete all the partitions on the USB flash drive.

Doesn't the act of deleting partitions also eliminate/delete the MBR?
No. The MBR is a 512-byte sector (or block) that contains a boot program and a four entry primary partition table. Changing one of the partition table entries does not remove the MBR.
Quote:
Can the block size, bs, be 4m instead of 1m? On Linux, I always use bs=4M.

What is count=1 ?
Yes, you can use a different block size. It's logical, anyway, since the device has 512-byte sectors and a single I/O will be limited to 64 sectors (32KB), if memory serves. A block size of 1 MB and a count of 1 write a single MB of zeros, and if my math is correct that will start at sector number 0 and end with sector number 2047.
Quote:
Can I omit "w" and simply type "q" to write and quit?
Yes. Per the man page, the quite command will write the modified MBR.
Quote:
Sorry, what is your definition of "virtual disklabel"? Is there a "real" disklabel as opposed to a virtual one? How do I find out the "real disklabel" of the USB flash drive?
I'll try once more to clarify.

On any drive that has nothing but zeros in every sector, there will be no MBR and there will be no disklabel.

Let's make that drive a USB Stick. Let's stick that completely zeroed drive into a Windows machine and tell it to format the thing as a FAT drive. Windows will write an MBR, and it will format a FAT partition. There won't be an OpenBSD disklabel on this drive.

When you now move that drive to OpenBSD, the OS will discover there is only an MBR partition table on the drive, and no disklabel on it. Since there is no disklabel physically on the drive, it will use the MBR partition table entries to try to see if it recognizes any filesystems.

Behold! It discovers an MBR partition, of type 0B, or one of the other partition types that might be used for "FAT" partititions.

OpenBSD will not write an OpenBSD disklabel on the drive. But it will create one, in memory, so that the recognized foreign filesystem can be mounted. The mount(8) command will use the in-memory disklabel. That disklabel will not be written to disk unless you do so from the disklabel(8) program yourself. A multiboot install will also write a disklabel to disk, picking up any recognized filesystems.

To reiterate: an MBR, if present, will first be used to determine the location of the OpenBSD MBR partition, if present, so that the disklabel can be located and read into memory. If there is no OpenBSD MBR partition, a disklabel will be looked for from whichever leading sector might hold it for that architecture. If there is a disklabel found, it will be used, and any other partitioning in the MBR partition tables will be ignored.

Last edited by jggimi; 10th August 2015 at 12:35 PM. Reason: spelling
Reply With Quote
Old 10th August 2015
betweendayandnight betweendayandnight is offline
friendly
 
Join Date: Jul 2015
Posts: 67
Default

Quote:
Originally Posted by jggimi View Post
I'll try once more to clarify.
Yes, this time you succeeded in your re-clarification. A big thank-you for your time, patience and effort.

Quote:
Originally Posted by jggimi View Post
When you now move that drive to OpenBSD, the OS will discover there is only an MBR partition table on the drive, and no disklabel on it.
You meant there's NO OpenBSD disklabel, right? Because I zeroed my entire USB drive using the following command in Ubuntu:

Code:
dd if=/dev/zero of=/dev/rsd1c bs=1M
(I omitted count=1 and the whole zeroing process took about 1.5 hours for a 16GB USB flash drive)

and at the completion of the process, I switched over to OpenBSD,typed # disklabel sd1 and noticed there was a disklabel for my USB drive.

Quote:
Originally Posted by jggimi View Post
Behold! It discovers an MBR partition, of type 0B, or one of the other partition types that might be used for "FAT" partititions.
Since you mentioned type 0B, what's the difference between 0B (Win95 FAT-32) and 0C (Win95 FAT32L) ?

Quote:
Originally Posted by jggimi View Post
If there is a disklabel found, it will be used, and any other partitioning in the MBR partition tables will be ignored.
Thanks for the precious information. Is that what other *BSD operating systems do too, viz. ignore MBR partition tables when a disklabel is found? Would you know if Linux distros adopt the same approach?
Reply With Quote
Old 10th August 2015
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,984
Default

Quote:
Originally Posted by betweendayandnight View Post
You meant there's NO OpenBSD disklabel, right?
That is what I meant, yes.
Quote:
Because I zeroed my entire USB drive using the following command in Ubuntu:

Code:
dd if=/dev/zero of=/dev/rsd1c bs=1M
(I omitted count=1 and the whole zeroing process took about 1.5 hours for a 16GB USB flash drive)
This is why I recommended only zeroing the first megabyte -- it's quick.
Quote:
...I switched over to OpenBSD,typed # disklabel sd1 and noticed there was a disklabel for my USB drive.
An in-memory disklabel. What I call virtual, because it is not physically on the disk drive. It consists of the information obtained about the drive: sector size, number of sectors, and a single "c" partition consisting of every sector of the drive. If there had been an MBR, with one or more recognized foreign file systems defined in its partition tables, you would have seem them listed starting with partition "i".
Quote:
Since you mentioned type 0B, what's the difference between 0B (Win95 FAT-32) and 0C (Win95 FAT32L) ?
0B uses CHS addressing, 0C uses LBA addressing. For the purposes of OpenBSD, either can be used. See https://en.wikipedia.org/wiki/Partition_type for way too many more MBR partition types.
Quote:
Is that what other *BSD operating systems do too, viz. ignore MBR partition tables when a disklabel is found? Would you know if Linux distros adopt the same approach?
Linux uses MBR partitions, because it began life on PC hardware, and MBRs were an IBM invention for the IBM PC/XT and its new 10 MB hard drive, and later adapted by Microsoft for MS DOS.

BSD began life on other architectures, and adapted to dealing with MBRs when ported to Intel platforms. As an example of this, OpenBSD is currently supported on 16 architectures. I believe that only 6 of these architectures use MBRs: amd64, armish, i386, landisk, macppc, and zaurus. That leaves 10 supported architectures that do not use them.

There are active development efforts for 3 additional architectures, and I believe only 1 of those uses MBRs.

NetBSD and FreeBSD also use disklabels, but there has been divergence both internally and operationally in the many years since the BSDs branched.

Last edited by jggimi; 10th August 2015 at 04:55 PM. Reason: MBRs were invented for the IBM PC/XT and its new BIOS.
Reply With Quote
Old 10th August 2015
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 7,984
Default

A little lab experimentation during lunch today resulted in a simplified step.

# disklabel -dw sd1

Will replace the disklabel with one containing the "c" partition and only recognized MBR partition filesystems, without using the disklabel editor.
Reply With Quote
Reply


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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
roundcubemail-1.1.0p0 - unable to open database file Valus OpenBSD Packages and Ports 2 15th March 2015 10:54 AM
Update problem with .xz file format Crotalus FreeBSD Installation and Upgrading 6 28th February 2011 12:25 AM
Unable to mount second hard drive Roric OpenBSD General 3 15th February 2011 05:02 AM
unable to get packages/INDEX file from selected media... clovis FreeBSD Installation and Upgrading 5 11th August 2010 07:39 PM
Jails - mount: /usr/home: No such file or directory chris FreeBSD General 6 6th August 2008 10:47 PM


All times are GMT. The time now is 09:01 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick