FreeUnix.Dyndns.Org Sat, 21 November 2009 - 10:44:09 CET
Home ·  AcpiTool ·  Howto ? ·  Links ·  Hardware ·  FTP Archive ·  Search ·  Contact ·  About
>  How to access BSD filesystems under Linux   <
Intro
This article will explain briefly how to access a FreeBSD filesystem under Linux, when these 2 are installed on the same machine.

First of all, your Linux kernel should have support (either built in or as a module) for the BSD filesystem, also referred to as UFS, and for BSD disklabels. So, it might be necessary to recompile your kernel if these are missing. More precisely, following options have to be enabled in your kernel config file:

  - UFS filesystem support (read only) (CONFIG_UFS_FS) [N/y/m/?] y
  - BSD disklabel (FreeBSD partition tables) support (CONFIG_BSD_DISKLABEL) [N/y/?](NEW) y

As you can see, the UFS filesystem support is read only. Write support is still in experimental stage, therefore considered dangerous and should be avoided. If you never (re)compiled a Linux kernel before, this is a good place to learn how to do so. Read it ? Good !
Now, recompile your kernel, install it and reboot. Once rebooted, check the dmesg output and look for something like this :
Partition check:
 hda: hda1 hda2 < hda5 hda6 hda7 hda8 hda9 hda10 hda11 hda12 > hda3 
 hda3: <bsd hda13 hda14 hda15 hda16 hda17 hda18 > 

Here you can see that /dev/hda3 is the BSD slice (that's how partitions are referred to in BSD). Then, inside the BSD slice, you can see the different BSD partitions. To get more information, start fdisk and type p :
Command (m for help): p

Disk /dev/hda: 255 heads, 63 sectors, 3736 cylinders
Units = cylinders of 16065 * 512 bytes

Device Boot    Start       End    Blocks   Id  System
/dev/hda1   *         1       261   2096451    6  FAT16
/dev/hda2           262      2744  19944697+   5  Extended
/dev/hda3          2745      3736   7968240   a5  BSD/386
/dev/hda5           262       263     16033+  83  Linux native
   .                .         .       .       .    .
/dev/hda11         2474      2728   2048256   83  Linux native
/dev/hda12         2729      2744    128488+  82  Linux swap

Again, we see /dev/hda3 showing up as BSD/386 filesystem. Note that although being listed as the 3th partition, it actually starts as the last partition. To see the partitions inside the BSD slice, type b at the prompt :
Command (m for help): b
Reading disklabel of /dev/hda3  at sector 44082361.

BSD disklabel command (m for help): p

8 partitions:
#       start       end      size     fstype   [fsize bsize   cpg]
 a:     2745      2783*       38*    4.2BSD        0     0     0 
 b:     2783*     2799*       16*      swap                      
 c:     2745      3736       992     unused        0     0       
 e:     2799*     2930*      130*    4.2BSD        0     0     0 
 f:     2930*     2942*       12*    4.2BSD        0     0     0 
 g:     2942*     3073*      130*    4.2BSD        0     0     0 
 h:     3073*     3736*      663*    4.2BSD        0     0     0 

Here you get more details about your BSD partitions. In this example, it says 8 partitions although we only count 7, but the 8th partition is actually a few MB's of unpartitioned diskspace. The "unused" c partition seems to hold the entire BSD slice.

Knowing that our kernel can deal with the BSD slices and filesystems, time has come to actually mount them. After all, that was the purpose of this document, wasn't it ? First we need a mount point. IMHO, /mnt/bsd will do just fine. You can create more subdirectories in there for the different BSD partittions (if any). Next, add entries to your /etc/fstab for the partitions you want to mount. If you don't know how, take a look at the following examples :
/dev/hda13      /mnt/bsd/rootdir      ufs       ro,noauto,users,ufstype=44bsd   0   0
/dev/hda15      /mnt/bsd/home         ufs       ro,noauto,users,ufstype=44bsd   0   0
/dev/hda16      /mnt/bsd/var          ufs       ro,noauto,users,ufstype=44bsd   0   0 

The most important option used here is ufstype=44bsd. If you omit this one, you will be able to mount the partition, but Linux wil spit out I/O error messages as soon as you try to read something from it. This is because there are several UFS file types, and it's difficult to determine the ufs type automatically. Type man mount to learn more about these.
So, now you can finally mount your BSD partitions with a command like mount /mnt/bsd/home and use them.

Top