FreeBSD and mounting ext2
Author: jason
Date: 2003-11-23
Category: Technical

Now, I'm jumping the gun. I need to write a tut on installing FreeBSD. But you know? It's pretty easy. Just go to: http:/ / and read the newbie section, the faq section, and the handbook. Download the 2 cds. And install. But you didn't want to blow linux did you? So you dug up a spare 2-3 gig drive and installed it on that, right? Now you're dual booing...

So now you want to mount your linux ext2/3 in FreeBSD? Need to do a couple things...

Look for this line "options EXT2FS" in the kernel
>cat /usr/src/sys/i386/conf/GENERIC |more

If it isn't there then you need to recompile the kernel. Make sure you're root!
>cd /usr/scr/sys/i386/conf
Arrow down to the options section. Hit the Insert key. Find a space, type: "options EXT2FS" without the quotes. Then hit Escape and type :wq!

Now compile the thing!
>config -r NEWKERNEL
>cd ../../compile/NEWKERNEL
>make depend && make && make install

Now reboot

You may need to install fsck_ext2fs to check the ext2 partitions/disks:
>cd /usr/ports/sysutils/fsck_ext2fs
>make install

You can check to make sure your disk is being picked up by looking in dmesg.boot:
>cat /var/run/dmesg.boot |more

Let's find out what type of partitions we have. Run /stand/sysinstall - then Configure - then fdisk. Choose your disk, hit the space bar, look at the partitions. Here's an example of mine, with extended:


Name PType Desc Subtype
- 6 unused 0
da0s1 1 ext2fs 131
da0s2 1 ext2fs 131
da0s3 1 ext2fs 131
da0s4 4 extended 15
- 6 unused 0

Notice that fdisk isn't reading into the extended. I booted into RedHat and used WebMin to look at the disk:

No. Type Extent Start End Use Free
1 Linux 1 13 /boot 85 %
2 Linux 14 1288 /usr 76 %
3 Linux 1289 2563 / 93 %
4 Extended 2564 8924
5 Linux 2564 3200 /var 89 %
6 Linux 3201 3455 /tmp 93 %
7 Linux swap 3456 3582 swap
8 Linux 3583 8924 /home 89 %

Once you know your partition numbers you can try to mount your ext2/3 in BSD. You can read about how BSD defines disks, partitions, and slices here: http:/ /

For me to mount the /home partition (1st disk, 8th partition) from RedHat I had to:
>mkdir /home/tmp
>mount_ext2fs /dev/da0s8 /home/tmp

I'm mounting the RedHat /home in the BSD /home/tmp. da0 is my first scsi disk. s8 is the last extended partition. BSD starts at number 5 for extended partitions. There can only be 4 primary. So referencing the 2 primary on scsi disk 2 would be: da1s2. For ide it would be: ad1s2.

Now, guess what error I got? "BAD SUPER BLOCK, WRONG MAGIC NUMBER" So now I try to fix the ext2 partition for BSD with:
>fsck_ext2fs /dev/da0s8

But I can't do it!! I get another error!! Then after a good night sleep I use Partition Magic 8.0 to change the swap and /home partitions. So now my swap is partition 8 and the /home is partition 7. Boot into BSD. Run:
>mount_ext2fs /dev/da0s8 /home/tmp

And it works just fine... The dang swap was keeping me from mounting the drive... Now, if I still would have gotten a superblock or magic number error I would have ran fsck_ext2fs again. I had to run it on three partitions. I first ran it on a partition with only a small amount a data. I was afraid it would corrupt it. But it didn't. So I ran it on the other two. After that, I mounted them all just fine.

Pretty cool? Now you're a BSD geek...

written by jasonthomasfrance
date 23 Nov 2003
systems FreeBSD 4.8

jason @ - - copyright 2009