Linux: Mount FreeBSD UFS 2 File System Command

by on July 16, 2012 · 2 comments· LAST UPDATED July 16, 2012

in ,

I need to copy files from my second hard disk. This hard disk formatted with UFS 2 file system. How do I mount UFS 2 file system created by FreeBSD on my Debian Linux 6 based system?

UFS filesystem widely used in different operating systems (such as HP-UX, Sun Solaris etc) including FreeBSD. The syntax is as follows to mount UFS 2 file system:

 
mount -t ufs -o ufstype=ufs2,ro /dev/sdXY /path/to/mnt/point
 

Each partition-that-contains-a-file-system is stored in what FreeBSD calls a slice. Slice is FreeBSD's term for what the common call partitions, and again, this is because of FreeBSD's UNIX background. Slices are numbered, starting at 1, through to 4. So you need to use equivalent Linux partition name.

First, login as root. In this example, mount /dev/sdb2 (FreeBSD root file system):
# mount -t ufs -o ufstype=ufs2,ro /dev/sdb2 /mnt
Verify new settings, enter:
# df -H
Sample outputs:

Filesystem             Size   Used  Avail Use% Mounted on
/dev/mapper/wks01-root
                       477G    70G   383G  16% /
tmpfs                  4.2G      0   4.2G   0% /lib/init/rw
udev                   4.2G   316k   4.2G   1% /dev
tmpfs                  4.2G   1.2M   4.2G   1% /dev/shm
/dev/sda1              239M    34M   193M  15% /boot
/dev/sdb2              488G    16G   433G   4% /mnt

To copy files or to view files cd into /mnt directory:
# cd /mnt
# ls

Sample outputs:

total 80
drwxr-xr-x  2 root root 1024 Jan  3  2012 bin
drwxr-xr-x  8 root root 1024 Jul 15 01:34 boot
drwxr-xr-x  3 root root  512 Jul 16 08:10 compat
-r--r--r--  1 root root 6199 Jan  3  2012 COPYRIGHT
drwxr-xr-x  2 root root  512 Jul  8 02:29 dev
drwxr-xr-x  2 root root  512 Jul  7 21:19 dist
-rw-------  1 root root 4096 Jul 16 09:05 entropy
drwxr-xr-x 20 root root 2048 Jul 16 09:02 etc
lrwxr-xr-x  1 root root    8 Jul  8 02:44 home -> usr/home
drwxr-xr-x  3 root root 1536 Jul 11 10:02 lib
drwxr-xr-x  3 root root  512 Jul  8 02:31 libexec
drwxr-xr-x  2 root root  512 Jul 16 09:03 media
drwxr-xr-x  2 root root  512 Jan  3  2012 mnt
dr-xr-xr-x  2 root root  512 Jan  3  2012 proc
drwxr-xr-x  2 root root 2560 Jul 11 10:02 rescue
drwxr-xr-x 12 root root  512 Jul 16 08:31 root
drwxr-xr-x  2 root root 2560 Jul 11 10:02 sbin
lrwxr-xr-x  1 root root   11 Jan  3  2012 sys -> usr/src/sys
drwxrwxrwt 21 root root 3584 Jul 16 09:05 tmp
drwxr-xr-x 16 root root  512 Jul  7 21:50 usr
drwxr-xr-x 25 root root  512 Jul 16 14:32 var

To copy a file called /mnt/usr/home/vivek/data/resume.pdf, enter:
# cp /mnt/usr/home/vivek/data/resume.pdf /home/vivek/
To unmount UFS 2 file system, enter:
# umount /mnt

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 2 comments… read them below or add one }

1 CDSU September 29, 2012 at 8:05 pm

Information provided in this article is incomplete. This does not work with RHEL nor CENTOS 5.x or 6.x. A customkernel needs to be compiled with the UFS filesystem options.

Reply

2 James January 29, 2013 at 11:30 am

This worked perfectly and allowed me to get my old FreeBSD UFS drive mounted as RO on my new Openmediavault system and all of the data copied off to my new RAID. Thank you very much.

And regarding CDSU’s comment, the article is fine and complete, as the author clearly states that this is for mounting a FreeBSD UFS drive under Debian 6. Debian has UFS support for RO on UFS, where it seems that RHEL and CENTOS lack this and require a custom kernel compile even just for RO.

Reply

Leave a Comment

Tagged as: , , , , , , , , , , ,

Previous Faq:

Next Faq: