Monday, May 28, 2012

HowTo: Mount UFS partition on CentOS / SL 6.2

By default RHEL clones such as CentOS and Scientific Linux don't come with UFS filesystem support.

However the ELRepo repository has the kmod-ufs package which provides the much needed kernel module. As such enabling ufs support on RHEL/CentOS/SL 6.2 consists of adding the ELRepo repository, installing and loading the kernel module for UFS.

The required steps are:
  1. $ su
  2. # rpm --import
  3. # rpm -Uvh
  4. # yum update
  5. # yum install kmod-ufs
  6. # modprobe ufs

Now that we have kernel support for UFS let's proceed to identify the partition(s) with UFS filesystems:
  1. # fdisk -l /dev/sdb
 Disk /dev/sdb: 203.9 GB, 203928109056 bytes  
 255 heads, 63 sectors/track, 24792 cylinders  
 Units = cylinders of 16065 * 512 = 8225280 bytes  
 Sector size (logical/physical): 512 bytes / 512 bytes  
 I/O size (minimum/optimal): 512 bytes / 512 bytes  
 Disk identifier: 0x90909090  
   Device Boot   Start     End   Blocks  Id System  
 /dev/sdb1        1    1968  15807928+  7 HPFS/NTFS  
 /dev/sdb2      1969    7067  40957717+ a5 FreeBSD  
 /dev/sdb3  *    7068    12166  40957717+ a5 FreeBSD  

In the BSD world slices are subdivided into partitions. Where Linux fdisk sees a FreeBSD partition that partition is in fact a BSD slice with internal partitions. Taking a peek at the output of /var/log/messages helps in identifying which are partitions that can be mounted.

For example in my system:

  1. # grep /dev/sdb /var/log/messages
 May 24 21:44:33 athon kernel: sda5 sdb2: <bsd: sdb5 sdb6 sdb7 sdb8 sdb9 >  
 May 24 21:44:33 athon kernel: sda6 sda7 sda8 sdb3: <bsd: sdb10 sdb11 sdb12 sdb13 >  
 May 28 19:39:09 athon kernel: sda5 sda6 sdb2: <bsd: sdb5 sdb6 sdb7 sdb8 sdb9 >  
 May 28 19:39:09 athon kernel: sda7 sda8 sdb3: <bsd: sdb10 sdb11 sdb12 sdb13 >  

What does this mean? sdb2, sdb3, sdb5, sdb6, sdb7, sdb8, sdb9, sdb10, sdb11, sdb12 and sdb13 are FreeBSD UFS partitions.

To mount a FreeBSD UFS partition:
  1. # mount -t ufs -o ufstype=ufs2,ro /dev/sdb2 /mnt/

In which -t ufs -o ufstype=ufs2,ro identify the UFS filesystem as being UFS2 and mounted as read-only.


Anonymous said...

How can you do this rw?

tangram said...


To my knowledge the module supplied by kmod-ufs has UFS in read-only mode.

You can however compile your own kernel by adding CONFIG_UFS_FS_WRITE=y to the kernel config and running the adequate make targets.

Explaining in further details is outside the scope for this post, however I can point you to for further information.

Note that UFS write support is experimental and might result in data loss.


Anonymous said...

Information contained in this article is incorrect. the epel repo does not contail kmod-ufs for centos 6.

tangram said...

Do you smoke crack or drink? Maybe you do both...

The article don't state EPEL anywhere. The blog clearly identifies the ELRepo repository.

Next time before posting check your facts.

kaolin fire said...

Thank you so much for this! Had to get an older rpm from elrepo for centos 5.8, but this got my from-a-failed-FreeBSD-machine drive up on a temporary server, to transfer files off.

tangram said...

Thanks for the feedback, glad it helped :)