Solved r/w access to UFS from Linux

balanga

Son of Beastie

Reaction score: 215
Messages: 4,011

Apparently openSUSE is the only Linux distribution which provides r/w access to UFS.
Can anyone confirm this?
 

Alain De Vos

Daemon

Reaction score: 347
Messages: 1,290

Once I had a Freebsd fsck running on an openbsd ufs partition and everything was gone. So far for a "standard ufs". Void-linux & debian-linux and mint-linux have not even read access to freebsd-ufs. And i never met a linux distro which has one.
As for reading openbsd-ufs or netbsd-ufs from linux, maybe.
 

ralphbsz

Son of Beastie

Reaction score: 2,097
Messages: 3,061

The kernel module for UFS access is in the Linux kernel, so anyone who can install a standard kernel (from kernel.org) can use it. I have no idea which distributions pre-compile that kernel module; it is possible that some distributions even remove it from the source tree. But if distributions ship a mostly standard kernel, then "modprobe ufs" should just work. I just checked on three random Linux machines: One runs Debian and has the module, but Raspbian and CentOS did not have it pre-compiled.

I would not attempt to write to a (current FreeBSD) UFS file system using the Linux kernel module. This is an extension of a general principle: do not trust third-party file system implementations, unless they are done from really good documentation, or with close cooperation with the real developers of the file system. Readonly might work, but it would at least be risk free.

And note that there are lots of file systems called UFS, many of which are related to each other (more or less remotely in some cases). This is one of the reasons support for UFS in Linux is difficult.
 

bsduck

Active Member

Reaction score: 67
Messages: 110

openSUSE has working (at your own risk) r/w support indeed, but you have to enable the corresponding module (see this post).
Maybe other distributions offer this too, but I have not met one yet. Everything else I tried had read support only.

Void-linux & debian-linux and mint-linux have not even read access to freebsd-ufs.
That's not correct. I use it on Debian and it works fine.
Just do mount -t ufs -o ufstype=ufs2
 

Vull

Well-Known Member

Reaction score: 150
Messages: 340

That's not correct. I use it on Debian and it works fine.
Just do mount -t ufs -o ufstype=ufs2
I didn't know I had this on Debian & derivatives. Thanks!
Code:
root@lenovo:~# mount -t ufs -o ufstype=ufs2 /dev/sda11 /mount
mount: /mount: WARNING: device write-protected, mounted read-only.
root@lenovo:~# ls /mount
bin   COPYRIGHT  entropy  gpt11  lib      media  net   rescue  sbin  tmp  var
boot  dev        etc      home   libexec  mnt    proc  root    sys   usr
root@lenovo:~#
 

Vull

Well-Known Member

Reaction score: 150
Messages: 340

You're welcome.


That's a lot of partitions! What do you do with so many of them?
Windows 10 and Lenovo used up 5 of them before I ever got started. Then I keep at least 4 FreeBSD installs up and running for MATE, a minimal plasma5-plasma DE, the full kde5 meta-package, and a headless server. Then I need at least 1 Debian boot manager install, so I can use grub2 to boot them all. Other than that I play around with Ubuntu and Linux Mint just to see what they've done with Debian. Best server platform IMO is easily the headless BSD, but I also like BSD with MATE, out of an old fondness for SCO Openserver 5, which was the first server I ever used which came with an X-windows console out of the box.
 

Machiaveli

Member

Reaction score: 22
Messages: 57

I have no problem mounting r/w an UFS (v2) under an openSUSE Tumbleweed with default kernel 5.12.9-1 bundled with 20210606 snapshot.

Kernel's config:
Code:
% zcat /proc/config.gz|grep -i ufs
CONFIG_SCSI_UFSHCD=m
CONFIG_SCSI_UFSHCD_PCI=m
# CONFIG_SCSI_UFS_DWC_TC_PCI is not set
CONFIG_SCSI_UFSHCD_PLATFORM=m
CONFIG_SCSI_UFS_CDNS_PLATFORM=m
# CONFIG_SCSI_UFS_DWC_TC_PLATFORM is not set
CONFIG_SCSI_UFS_BSG=y
CONFIG_SCSI_UFS_CRYPTO=y
CONFIG_UFS_FS=m
CONFIG_UFS_FS_WRITE=y
# CONFIG_UFS_DEBUG is not set
 
OP
B

balanga

Son of Beastie

Reaction score: 215
Messages: 4,011

I have no problem mounting r/w an UFS (v2) under an openSUSE Tumbleweed with default kernel 5.12.9-1 bundled with 20210606 snapshot.

Kernel's config:
Code:
% zcat /proc/config.gz|grep -i ufs
CONFIG_SCSI_UFSHCD=m
CONFIG_SCSI_UFSHCD_PCI=m
# CONFIG_SCSI_UFS_DWC_TC_PCI is not set
CONFIG_SCSI_UFSHCD_PLATFORM=m
CONFIG_SCSI_UFS_CDNS_PLATFORM=m
# CONFIG_SCSI_UFS_DWC_TC_PLATFORM is not set
CONFIG_SCSI_UFS_BSG=y
CONFIG_SCSI_UFS_CRYPTO=y
CONFIG_UFS_FS=m
CONFIG_UFS_FS_WRITE=y
# CONFIG_UFS_DEBUG is not set
No idea what any of that means, but I get the same thing here, but can't seem to mount a UFS partition using
mount -t ufs -o ufstype=ufs2 /dev/sda2 /mnt

I get uknown filesystem type 'ufs'.
 

Tieks

Member

Reaction score: 35
Messages: 80

Unknown filesystem type: Looks like you have to yum or rpm for the package that is needed to use ufs2 with Linux.
 
OP
B

balanga

Son of Beastie

Reaction score: 215
Messages: 4,011

I have no problem mounting r/w an UFS (v2) under an openSUSE Tumbleweed with default kernel 5.12.9-1 bundled with 20210606 snapshot.
Can you show me the command you used to mount the UFS partition? And did you need to install anything first or was support already built in?
 

Machiaveli

Member

Reaction score: 22
Messages: 57

Can you show me the command you used to mount the UFS partition? And did you need to install anything first or was support already built in?

No need to install anything, the ufs kernel module is available by default by the supplied kernel of openSUSE Tumbleweed and configured as a loadable kernel module as per /proc/config.gz I posted in my previous post.

I should be more precise in my previous message, sorry.
Code:
CONFIG_UFS_FS=m

Tells that the ufs kernel module should be available as a loadable module and:
Code:
CONFIG_UFS_FS_WRITE=y

Allows writing on an ufs filesystem.

To use, it's as simple as that:

# modprobe ufs
# mount -t ufs -o ufstype=ufs2 /dev/sdb1 ~/mnt


Kernel's ufs module loaded:
Code:
% lsmod|grep ufs
ufs                    94208  0

Like bsduck posted on his Debian box. To have the ufs kernel module started at boot, unblacklist it by editing /etc/modprobe.d/60-blacklist_fs-ufs.conf

Content of the above file:
Code:
  1 # The ufs file system is blacklisted by default because it isn't actively
  2 # supported by SUSE, not well maintained, or may have security vulnerabilites.
  3 # To enable autoloading the ufs file system module, comment out the
  4 # "blacklist ufs" statement below. ENABLE AT YOUR OWN RISK.
  5 #
  6 # File system modules loaded at installation time of the suse-module-tools package
  7 # are not blacklisted. This is achieved by commenting out the blacklist
  8 # line in the post-installation script. To prevent the post-installation
  9 # script from modifying this file, delete the line containing "THIS FILE MAY
10 # BE MODIFIED" at the bottom.
11 blacklist ufs
12 # __THIS FILE MAY BE MODIFIED__

As you can see the warning, I wouldn't use the ufs kernel module for anything critical but more for a mean of convenience to share files between FreeBSD and GNU/Linux.
 
OP
B

balanga

Son of Beastie

Reaction score: 215
Messages: 4,011

Many thanks for this detailed explanation. It's not very intuitive, and I wouldn't have been able to figure it out for myself, but it's working now.

The reason I wanted to try it was to see if I could get Grub installed on a UFS partition. Hopefully I'll find out shortly...
 

Machiaveli

Member

Reaction score: 22
Messages: 57

The counter intuitiveness comes from the numerous GNU/Linux distributions having their own kernel configuration but once you know what the kernel supports (either via loadable modules or builded ones directly onto the kernel) things got clearer.

As what bsduck already stated, modprobe(8), lsmod(8), rmmod(8) and modinfo(8) are tools to do what we're used to on FreeBSD with (by order) kldload(8), kldstat(8) and kldunload(8).
 
OP
B

balanga

Son of Beastie

Reaction score: 215
Messages: 4,011

The counter intuitiveness comes from the numerous GNU/Linux distributions having their own kernel configuration but once you know what the kernel supports (either via loadable modules or builded ones directly onto the kernel) things got clearer.

As what bsduck already stated, modprobe(8), lsmod(8), rmmod(8) and modinfo(8) are tools to do what we're used to on FreeBSD with (by order) kldload(8), kldstat(8) and kldunload(8).
AFAIAC Linux is just a mess. FreeBSD is so much simpler and cleaner.

Incidentally I have now installed Grub on a UFS partition and am able to boot from it.
 

Machiaveli

Member

Reaction score: 22
Messages: 57

Once you stick to a unique distro, things are simpler (been using SuSE and now openSUSE since 1999 and changes are still easy to follow from successive upgrades) but I still prefer how FreeBSD is designed though.

Regarding the systemd introduction, as an old Mac OS X user, transition was kinda smooth thanks to the switch to launchd init system.
 

Vull

Well-Known Member

Reaction score: 150
Messages: 340

Along a similar vein, FreeBSD's ext2fs module allows FreeBSD users to mount the GNU/Linux filesystem types ext2, ext3, and ext4, but it has precautionary warnings too. From man ext2fs, "It currently implements most of the features required by ext3 and ext4 file systems. Support for Extended Attributes in ext4 is experimental. Journalling and encryption are currently not supported." I use ext2fs at my own risk to share files between the two systems, but, just like Machiaveli said above about the Linux ufs module, I couldn't recommend it for anything critical.
 

Alain De Vos

Daemon

Reaction score: 347
Messages: 1,290

Yeah, you best stick with O.S. and filesystem the same.
Even using zfs on both linux and freebsd you must be carefull.
There is one exception. FAT32-Windows works on everything. But it is a minimalistic filesystem.
PS: You can also read-write linux-XFS partition from freebsd.
 
Top