Linux: Mount FreeBSD UFS 2 File System Command

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
                       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

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 2 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
2 comments… add one
  • CDSU Sep 29, 2012 @ 20:05

    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.

  • James Jan 29, 2013 @ 11:30

    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.

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum