Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Mini-Mini-Howto: Mount FreeBSD Filesystems (UFS1 and UFS2)
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
daff
Apprentice
Apprentice


Joined: 02 Jul 2003
Posts: 232
Location: Vienna, Austria

PostPosted: Wed Aug 11, 2004 3:21 pm    Post subject: Mini-Mini-Howto: Mount FreeBSD Filesystems (UFS1 and UFS2) Reply with quote

A very short Howto on mounting UFS partitions. FreeBSD, OpenBSD and NetBSD use the UFS file system and lay out the disk differently from Linux. I've seen a lot of posts that all ask more or less the same things and describe the same problems.

These problems were

  • When trying to mount a UFS partition mount would bail with an error message like the following:
    Code:

    mount: wrong fs type, bad option, bad superblock on /dev/hdb1,
           or too many mounted file systems

  • Linux would only see the first partition on the BSD disk, i.e. only the BSD / partition, no other partitions would be available (i.e. no BSD /usr, no BSD /var, etc.)

Here's how I solved it with/for FreeBSD. This was done on a gentoo-dev-sources 2.6.7-r12 machine.

Description of FreeBSD disk layout

What is known as a partition under Linux is called a slice under FreeBSD. Such a slice holds a set of (FreeBSD) partitions (which are created by applying a BSD disklabel). These partitions are formatted with the UFS file system and get mounted under /, /usr, /var, and so on.

When FreeBSD occupies the whole disk then there's only one slice (almost as big as the disk itself). Using Linux's fdisk on that disk shows only the slice, not the partitions within the slice.

FreeBSD names the devices thus (for IDE drives):

/dev/ad0 -- The whole disk
/dev/ad0s1 -- The first slice on the first disk
/dev/ad0s1a -- The first partition on the first slice on the first disk
/dev/ad0s1b -- The second partition on the first slice on the first disk
...
/dev/ad4s2f -- The sixth partition on the second slice on the fourth disk

FreeBSD also follows some tradition on which partition gets which name. Suppose we work on the first disk and the first slice. Typically the / partition is /dev/ad0s1a, /var gets /dev/ad0s1e and /usr gets /dev/ad0s1f.

There are two types of UFS for BSD. UFS1 is used in FreeBSD 4-STABLE as the default, UFS2 became default as of FreeBSD 5.1. Both seem to be supported in recent 2.6 kernels.

See here (FreeBSD handbook: pre-install tasks), here (FreeBSD handbook: allocating disk space), here and here for further information.

BSD/UFS disks on Linux

Linux doesn't know about slices. The BSD partitions are represented just like any other partition types. So /dev/ad0s1a under FreeBSD becomes /dev/hda1 under Linux, /dev/ad0s1f is /dev/hda8 and so on. Linux only sees partitions other than /dev/ad0s1a if the kernel supports BSD disklabels (next section).

Preparing the kernel for UFS and BSD disklabels

Activate UFS support:
Code:

Filesystems -> Miscellaneous filesystems ->
<*> UFS file system support (read only)

Then allow for BSD disklabels:
Code:

Filesystems -> Partition types ->
[*] Advanced partition selection
[*]   PC BIOS (MSDOS partition tables) support                                           
[*]     BSD disklabel (FreeBSD partition tables) support


Recompile the kernel, install it and reboot.
Code:

# make
# mount /boot
# cp arch/i386/boot/bzImage /boot/kernel
# reboot


Mounting

Depending on whether your FreeBSD partitions are of type UFS1 or UFS2 you need to apply different mount options. ufstype=44bsd is for UFS1, ufstype=ufs2 for UFS2.

A FreeBSD / partition (/dev/ad0s1a) of type UFS1 would be mounted thus:
Code:

# mount -r -t ufs -o ufstype=44bsd /dev/hda1 /mnt

This tells mount to mount the partition read-only and apply the mount option ufstype=44bsd to tell the kernel it is of type UFS1.

Code:

# mount -r -t ufs -o ufstype=44bsd /dev/hda8 /mnt/usr

This would mount the FreeBSD /usr partition on /mnt/usr.

Notes

I only have disks of type UFS1 so I can't verify that it is possible to mix UFS1 and UFS2 mounts. For example the default setup under FreeBSD 5.1 onwards is to create a UFS1-type / partition and UFS2 partitions for everything else (/var, /usr, ...).

Theoretically it should be possible to do this:
Code:

# mount -r -t ufs -o ufstype=44bsd /dev/hda1 /mnt
# mount -r -t ufs -o ufstype=ufs2 /dev/hda8 /mnt/usr

As said, I can't verify that but it seems reasonable.

If you find any errors or mishaps in this Mini-howto please point them out.
_________________
Instead of asking why a piece of software is using 1970s technology,
start asking why software is ignoring 30 years of accumulated wisdom.


Last edited by daff on Wed Apr 27, 2005 6:08 pm; edited 1 time in total
Back to top
View user's profile Send private message
Moloch
Apprentice
Apprentice


Joined: 17 Mar 2003
Posts: 293
Location: Albuquerque, NM, US

PostPosted: Wed Aug 11, 2004 6:27 pm    Post subject: Reply with quote

Thanks! Although I could have used this howto 4 weeks ago. :wink:
Back to top
View user's profile Send private message
dob
Apprentice
Apprentice


Joined: 04 Oct 2002
Posts: 199
Location: S.L.P.

PostPosted: Sat May 21, 2005 1:47 pm    Post subject: Reply with quote

nice one :D
Back to top
View user's profile Send private message
isaacpeel
n00b
n00b


Joined: 27 Jun 2005
Posts: 12

PostPosted: Mon Jun 27, 2005 6:01 pm    Post subject: RE:Mini-Mini-Howto: Mount FreeBSD Filesystems (UFS1 and UFS) Reply with quote

I've followed your mini how-to and am still unable to mount my ufs drive. I get the following output:

#mount -r -t ufs -o ufstype=44bsd /dev/hdc1 /music
mount: unknown filesystem type 'ufs'

I have the following two lines in my kernel config file
CONFIG_UFS_FS=y
CONFIG_UFS_FS_WRITE=y (note: I've tried it with out this one too)

Any ideas? I'm new to linux, just switching over from freeBSD. Is there a way I can check to see if these new kernel options were installed correctly?
Back to top
View user's profile Send private message
isaacpeel
n00b
n00b


Joined: 27 Jun 2005
Posts: 12

PostPosted: Mon Jun 27, 2005 6:48 pm    Post subject: Reply with quote

Pay me no mind I've figured it out. Thanks for the how-to.
Back to top
View user's profile Send private message
PoUaScAiLLe
n00b
n00b


Joined: 17 Aug 2005
Posts: 1

PostPosted: Wed Aug 17, 2005 8:54 am    Post subject: Reply with quote

Thx for this how to very usefull for me:D
_________________
http://www.vakarm.net
Back to top
View user's profile Send private message
Gnux
n00b
n00b


Joined: 14 Aug 2003
Posts: 38

PostPosted: Sun May 28, 2006 9:10 pm    Post subject: Reply with quote

Nice tip, just one addenda:
Code:
mount -t ufs -o ufstype=44bsd etc...

does not work for me with a freebsd 6.0... To mount this block I have to type:
Code:
mount -t ufs -o ufstype=5xbsd etc...

But this is not very practicable (a swap block between the two (in ext2fs for ex) worth it really much more)
Back to top
View user's profile Send private message
kwisatz_haderais
Tux's lil' helper
Tux's lil' helper


Joined: 28 Sep 2004
Posts: 143

PostPosted: Tue Jul 04, 2006 10:22 am    Post subject: Reply with quote

thanks for the howto, however... doesn't really work for me :(

Quote:
usb 1-1: new high speed USB device using ehci_hcd and address 8
usb 1-1: configuration #1 chosen from 1 choice
scsi1 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 8
usb-storage: waiting for device to settle before scanning
Vendor: Maxtor Model: OneTouch II Rev: 023g
Type: Direct-Access ANSI SCSI revision: 04
SCSI device sda: 586114704 512-byte hdwr sectors (300091 MB)
sda: Write Protect is off
sda: Mode Sense: 24 00 00 00
sda: assuming drive cache: write through
SCSI device sda: 586114704 512-byte hdwr sectors (300091 MB)
sda: Write Protect is off
sda: Mode Sense: 24 00 00 00
sda: assuming drive cache: write through
sda: sda1
sda1: <bsd: >
sd 1:0:0:0: Attached scsi disk sda
usb-storage: device scan complete


a command like
Code:
mount -r -t ufs -o ufstype=ufs2 /dev/sda /mnt/tmp/


results in:
Quote:
ufs_read_super: bad magic number


although it says sda1 in dmesg, there's no such device in /dev
sda is the only one.
The hdd works on my freebsd server though...
Back to top
View user's profile Send private message
mofa
n00b
n00b


Joined: 20 Jul 2006
Posts: 11

PostPosted: Sat Oct 21, 2006 9:56 am    Post subject: same problem Reply with quote

i have the same problem with my firewire hd.

kwisatz_haderais wrote:
thanks for the howto, however... doesn't really work for me :(

Quote:
usb 1-1: new high speed USB device using ehci_hcd and address 8
usb 1-1: configuration #1 chosen from 1 choice
scsi1 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 8
usb-storage: waiting for device to settle before scanning
Vendor: Maxtor Model: OneTouch II Rev: 023g
Type: Direct-Access ANSI SCSI revision: 04
SCSI device sda: 586114704 512-byte hdwr sectors (300091 MB)
sda: Write Protect is off
sda: Mode Sense: 24 00 00 00
sda: assuming drive cache: write through
SCSI device sda: 586114704 512-byte hdwr sectors (300091 MB)
sda: Write Protect is off
sda: Mode Sense: 24 00 00 00
sda: assuming drive cache: write through
sda: sda1
sda1: <bsd: >
sd 1:0:0:0: Attached scsi disk sda
usb-storage: device scan complete


a command like
Code:
mount -r -t ufs -o ufstype=ufs2 /dev/sda /mnt/tmp/


results in:
Quote:
ufs_read_super: bad magic number


although it says sda1 in dmesg, there's no such device in /dev
sda is the only one.
The hdd works on my freebsd server though...
Back to top
View user's profile Send private message
gohmdoree
Guru
Guru


Joined: 12 Oct 2004
Posts: 533

PostPosted: Fri Dec 27, 2013 7:46 pm    Post subject: thank you Reply with quote

Thanks for this mini howto. helped me a lot.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum