gentoo linux, java, software libre y otras hierbas
Ene, 01 2010 - 1:02 am

Mounting *BSD partitions/slices on Linux

Some times it’s necessary to work with UFS (the default filesystem on FreeBSD, OpenBSD, NetBSD, etc.) from your linux box. Here I’ll explain how to do so by configuring your kernel in order to enable UFS read/write support. We’ll focus on FreeBSD.

Also, as you should know, FreeBSD uses its own hard disk partition scheme on your PC. It requires only one entry in the primary partition table of your disk and manages it similarly to DOS extended partitions, putting in its first sector a new partition table in BSD disklabel format. So we’ll enable support for reading these disklabels; otherwise we just will be able to mount the root ’slice’ of FreeBSD but not the partitions ‘inside’.

0. Preparing your kernel

You may already have support for UFS and BSD disklabel format, but I’ll assume that you have built your kernel by your self and/or don’t have those options enabled.

So, let’s get into the menu configuration of your kernel (I’m using Linux kernel 2.6.32):

cd /usr/src/linux
make menuconfig

Now, we are going to activate these options:

-> File systems
-> Miscellaneous filesystems
    <*> UFS file system support (read only)
      [*] UFS file system write support

It’ll look like this:

linux-kernel-menuconfig-ufs

Important: write support for UFS2 is on development and could be dangerous. Use it at your own risk ;)

Now, we’ll enable the FreeBSD disklabel support:

-> File systems
    -> Partition Types
        [*] Advanced partition selection
          [*] PC BIOS (MSDOS partition tables) support
          [*]    BSD disklabel (FreeBSD partition tables)

It’ll look like this:

linux-kernel-menuconfig-ufs

OK… with these options enabled we just need to compile our kernel and install it:

make && cp arch/x86_64/boot/bzImage /boot/kernel-2.6.32
Note: I’m assuming you already know how to work with the kernel… the line above will work fine for me, but some of you guys will use other kind of settings for your boot loader (for instance, those of you who use initramfs). In conclusion: I expect you know how to compile and configure your kernel for this kind of situations.

1. Looking for partitions names

When working with FreeBSD, the disks device names are like this: /dev/ad0s3a. But, as we are working with Linux, we’ll have the traditional /dev/sda* or /dev/hda* names. So, thanks to the FreeBSD Disklabel support that we’ve just added, we can do this in order to know the devices names:

cat /proc/partitions

You’ll get something like this:

major minor  #blocks  name
8        0  244198584 sda
8        1   41624383 sda1
8        2  158497290 sda2
8        3   39076695 sda3
8        4    5000184 sda4
8        5     524288 sda5
8        6    4194304 sda6
8        7    5223424 sda7
8        8     524288 sda8
8        9   28610391 sda9

2. Mounting UFS

In order to mount a UFS partition you’ll need to type this (suppose /dev/sda7 is one of the *BSD partitions):

mount -t ufs -o ufstype=ufs2 /dev/sda7 /media/freebsd

Of course, you can add an entry to your /etc/fstab file so the partition get mounted each time you boot your system:

/dev/sda7        /media/freebsd    ufs        ufstype=ufs2    0 0

That’s it. Let me know if you have any problem. And sorry for my English, I’m just learning ;)

Etiquetas: bsd, FreeBSD, linux, netbsd, openbsd

3 Comentarios | deja el tuyo

3 enlaces entrantes

Sin comentarios en “Mounting *BSD partitions/slices on Linux”

¡Déjanos tu comentario!