Linux under Mount FreeBSD partition

Source: Internet
Author: User
Tags dmesg

Suppose you need to copy files from a second hard drive. The hard disk is formatted as a UFS 2 file system. How to mount the UFS 2 file system created by FreeBSD onto the Ubuntu system?

UFS file systems are widely used in different operating systems (e.g., Hp-ux,sun Solaris). Contains FreeBSD. The following syntax is used to mount the Mount UFS 2 file system:

Mount-t Ufs-o Ufstype=ufs2,ro/dev/sdxy/path/to/mnt/point

Each partition consists of a file system that exists in FreeBSD, called a slice.

Slice is a term in FreeBSD, often referred to as partitioning. This is because FreeBSD has a UNIX background, slice is numbered, starting from 1 to 4.

So you need to use the equivalent Linux partition name.

Verifying UFS partition Support

To check if your Linux kernel supports UFS file systems. You can run the following command:

$ cat/proc/filesystems

Output Demo Sample:

Nodev Sysfs

Nodev Rootfs

Nodev Bdev

Nodev proc

Nodev Cpuset

Nodev Binfmt_misc

Nodev Debugfs




Nodev Pipefs

Nodev Anon_inodefs




Nodev Eventpollfs

Nodev devpts


Nodev Ramfs



Nodev Mqueue


Nodev Rpc_pipefs

Nodev AutoFS

The Keywordnodev meaning of the first line is that the file system does not need to mount a block device, which is why it is also called a virtual file system. Support is also compiled into the kernel or as a separate module.

Check if you have a UFS-driven method installed:

Method 1:# Cat/proc/filesystems | grep UFS

Method 2:ls-l/lib/modules/' Uname-r '/kernel/fs/ufs/ufs.ko

The 1th method has no output and the 2nd method file does not exist to indicate that the UFS driver is not compiled into the kernel or installed as a module.

Installing UFS Drivers

[Email protected]:~# modprobe ufs

[Email protected]:~# cat/proc/filesystems| grep ufs


# modinfo ufs







Vermagic:3.11.0-14-generic SMP mod_unloadmodversions

[Email protected]:~# uname-r


[Email protected]:~# Ll/lib/modules/3.11.0-14-generic/kernel/fs/ufs/ufs.ko

# lsmod | grep ufs

# grep bsd_disklabel/boot/config-' uname-r '


# grep ufs/boot/config-' uname-r '


# DMESG |grep BSD

Mount-t Ufs-oufstype=sun|sunx86|44bsd|ufs2|5xbsd|old|hp|nextstep|nextstep-cd|openstep ...

Mount a UFS hard drive

Depending on whether your FreeBSD partition type is UFS1 or UFS2, you need to refer to different mount options.

UFS1 use Ufstype=44bsd. UFS2 use UFSTYPE=UFS2.

In order to discover the appropriate equipment for the FFS partition, perform:

# fdisk-l

# sfdisk-l

disk/dev/hda:155061 Cylinders, heads,63 sectors/track

warning:extended partition does not startat a cylinder boundary.

DOS and Linux would interpret the contentsdifferently.

Units = Cylinders of 516096 bytes, blocksof 1024x768 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System

/DEV/HDA1 * 0+ 34536-34537-17406396 7 Hpfs/ntfs

End: (c,h,s) expected (1023,15,63) found (1023,254,63)

/dev/hda2 34536+ 134767-100231-50516392+ F W95 Ext ' d (LBA)

Start: (c,h,s) expected (1023,15,63) found (1023,255,63)

End: (c,h,s) expected (1023,15,63) found (1023,254,63)

/dev/hda3 134767+144935-10169-5124735 A5 FreeBSD

Start: (c,h,s) expected (1023,15,63) found (1023,255,63)

End: (c,h,s) expected (1023,15,63) found (1023,254,63)

/DEV/HDA4 144935+ 155060 10126-5103189 A9 NetBSD

Start: (c,h,s) expected (1023,15,63) found (1023,255,63)

End: (c,h,s) expected (1023,15,63) found (1023,80,63)

/dev/hda5 34536+ 102366-67830-34186288+ Linux

Start: (c,h,s) expected (1023,15,63) found (0,1,1)

End: (c,h,s) expected (1023,15,63) found (1023,254,63)

/dev/hda6 102366+ 104294 1929-971901, Linux Swap/solaris

Start: (c,h,s) expected (1023,15,63) found (0,1,1)

End: (c,h,s) expected (1023,15,63) found (120,254,63)

/DEV/HDA7 104295+ 134767-30473-15358108+ Linux

Start: (c,h,s) expected (1023,15,63) found (0,1,1)

End: (c,h,s) expected (1023,15,63) found (1023,254,63)

/dev/hda8 134767+143910-9143-4608000

/DEV/HDA9 143910+144935-1026-516735

/DEV/HDA10 144935+ 154078-9143 4608072

/dev/hda11 154078+ 155060 983-495117

/dev/hda12 0+ 34536-34537-17406396

/dev/hda13 34536+ 102366-67830-34186288+

/DEV/HDA14 102366+ 104294 1929-971901

/DEV/HDA15 104295+ 144935-40641-20482843+

Therefore, for FreeBSD (FFSV2),/dev/hda3 is equivalent to/DEV/AD0S3

NetBSD (FFSV1),/dev/hda4 equivalent to/dev/wd0c.

But these devices are the entire BSD slice (bois partition), not the BSD partition.

By carefully examining the output of the sfdisk, we found that/dev/hda3 including/dev/hda8 and/dev/hda9,/dev/hda4 include/DEV/HDA10 and/DEV/HDA11.

We are able to launch. For freebsd/dev/hda8 equivalent to/dev/ad0s3a (the root partition of FreeBSD),/DEV/HDA9 is equivalent to/dev/ad0s3b (FreeBSD's swap partition).

For NetBSD. /DEV/HAD10 is equivalent to/dev/wd0a (NetBSD root partition). /DEV/HDA11 is equivalent to/dev/wd0b (NetBSD's swap partition).

So the root partition of FreeBSD is located in/dev/hda8. First create a folder for the Mountffs partition, and then mount it.


# mount-t Ufs-o ro,ufstype=ufs2/dev/hda8/mnt/freebsd/

NetBSD root partition is located on/DEV/HDA10, first create a folder to mount the FFS partition, and then mount it.


# mount-t Ufs-o ro,ufstype=44bsd/dev/hda10/mnt/netbsd/

Let's browse the mounted folder:



Bin cdrom COPYRIGHT Dist etc lib media proc Root sys usr

Boot Compat Dev Entropy home libexec mnt rescue Sbin tmp var


Altroot etc Gnome-screensave.core Mnt root var

Bin GENERIC Kern NetBSD Sbin

Boot generic-diagnostic Lib Onetbsd stand

CUSTOM generic-laptop libdata proc tmp

Dev generic-noacpi libexec Rescue usr


In order to boot their own active mount. You need to add the following two lines to the/etc/fstab file:

/dev/hda8/mnt/freebsd UFS Ufstype=ufs2,ro 0 2

/dev/hda10/mnt/netbsd UFS Ufstype=44bsd,ro 0 2

Now you can mount the FFS partition and enter:



and verify with the following command:

$ mount


/dev/hda8 On/mnt/freebsd type UFS (RO,UFSTYPE=UFS2)

/DEV/HDA10 On/mnt/netbsd type UFS (RO,UFSTYPE=44BSD)


Write support

Satisfying several conditions can support writing:

-Compile option in Linux kernel supports write, default disabled (config_ufs_fs_write=y)

-FFSV1 File System (FFSV1) (FFSV2 not supported)

Please note: Normally you do not need to write on the NetBSD partition. So don't compile the kernel again and test the feature.


1. Suppose you forget the RO option. You may get the following message in DMESG, for example:

$ DMESG | grep UFS

UFS is compiled with read-only Support,can ' t is mounted as Read-write

2. If you forget to set the Ufstype option, you may get the following message in DMESG:

$ DMESG | grep ufstype

Mount-t Ufs-oufstype=sun|sunx86|44bsd|ufs2|5xbsd|old|hp|nextstep|nextstep-cd|openstep ...

warning<<< wrong Ufstype Maycorrupt your filesystem, default is Ufstype=old

3. command to unmount a partition: Umount/mnt

# mount-t Ufs-r-O ufstype=ufs2/dev/sdb3/mnt/sdb3

Mount:wrong fstype, bad option, bad Superblock on/dev/sdb3,

Missing codepage or helper program, orother error

In some cases useful info is found Insyslog-try

DMESG | Tail or so

#dmesg | Tail

[1279.960537] Ufs_read_super:bad magic number

#mount-T ufs-r-o UFSTYPE=44BSD/DEV/SDB2/MNT/SDB3

4. View the partition information for each disk:

[Email protected]:~# file-ls/dev/sdb1

/dev/sdb1:x86 boot sector; Partition 4:id=0xa5, active, Starthead 0, Startsector 0, 50000 sectors, code offset 0X3C,BSD Disklabel cannot mount

[Email protected]:~# file-ls/dev/sdb2

/dev/sdb2:x86 bootsector; Partition 4:id=0xa5, active, Starthead 0,startsector 0, 50000 sectors, code offset 0x3c, BSD Disklabel Unable to mount

[Email protected]:~# file-ls/dev/sdb3 mount-o ufstype=44bsd-r-T UFs

/dev/sdb3:unix Fast File System [V1] (Little-endian), last mounted ON/CF, last written at Tue Nov 19:16:31 2014,clean Flag 1, number of blocks 2104515, number of data blocks 2069056, numberof cylinder groups, block size 4096, fragment Si Ze, minimum percentageof free blocks 8, rotational delay 0ms, disk rotational speed 60rps, timeoptimization

[Email protected]:~# file-ls/dev/sdb4 mount-o ufstype=ufs2-r-T UFs

/dev/sdb4:unix Fast File System [v2] (Little-endian) Last mounted On/var/log, last written at Tue Nov 11:16:432014, cl EAN flag 1, readonly flag 0, number of blocks 4909865, number of datablocks 4753848, number of cylinder groups, block s Ize 32768, fragment size4096, average file size 16384, average number of files in Dir., pendingblocks to free 0, pending Inodes to free 0, system-wide uuid 0, minimumpercentage of free blocks 8, time optimization

Linux under Mount FreeBSD partition

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.