Problems loop mounting ufs filesystem on centos7

Issues related to applications and software problems
Post Reply
maxfisher
Posts: 5
Joined: 2017/09/18 13:38:47

Problems loop mounting ufs filesystem on centos7

Post by maxfisher » 2017/09/18 14:13:28

I am trying to mount a vmdk flat file which contains an ordinary msdos partition table with 2 ufs slices a 2GB root partition and a 200 MB swap partition. When mounted natively in FreeBSD the filesystem is shown to be ufs2.

file -sL /dev/ufsid/59b65b72848c9171
/dev/ufsid/59b65b72848c9171: Unix Fast File System [v2] (little endian) last mounted on / ...

The following commands are executed on the centos system.

modprobe ufs
kpartx -a -v UFS_fs.vmdk
add map loop0p1 (253:9): 0 4194225 linear /dev/loop0 63

mount -t ufs -o ro,ufstype=ufs2 /dev/mapper/loop0p1 /mnt

mount: wrong fs type, bad option, bad superblock on /dev/mapper/loop0p1,
missing codepage or helper program, or other error

In some cases useful info is found in syslog - try
dmesg | tail or so.

dmesg | tail
...
[ 7137.735075] ufs_read_super: bad magic number

partprobe /dev/loop0

fdisk -l | tail

Disk /dev/mapper/loop0p1: 2147 MB, 2147443200 bytes, 4194225 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x90909090

Device Boot Start End Blocks Id System
/dev/mapper/loop0p1p4 * 0 49999 25000 a5 FreeBSD


mount -t ufs -o ro,ufstype=ufs2 /dev/mapper/loop0p1p4 /mnt
mount: special device /dev/mapper/loop0p1p4 does not exist


partx -l /dev/mapper/loop0p1
# 1: 63- 4194287 ( 4194225 sectors, 2147 MB)


mount -r -t ufs -o loop,offset=32768,ufstype=ufs2 /dev/mapper/loop0p1 /mnt

mount: wrong fs type, bad option, bad superblock on /dev/loop1,
missing codepage or helper program, or other error

In some cases useful info is found in syslog - try
dmesg | tail or so.

dmesg | tail
...
[ 7482.023299] ufs_read_super: bad magic number
[ 7490.939276] ufs_read_super: bad magic number

partx -l /dev/loop0

# 1: 63- 4194287 ( 4194225 sectors, 2147 MB)
# 5: 3784625- 4194224 ( 409600 sectors, 209 MB)

mount -r -t ufs -o ufstype=ufs2 /dev/loop0p1 /mnt
mount: /dev/loop0p1 is already mounted or /mnt busy

mount -r -t ufs -o loop,ufstype=ufs2 /dev/loop0p1 /mnt
mount: wrong fs type, bad option, bad superblock on /dev/loop1,
missing codepage or helper program, or other error

In some cases useful info is found in syslog - try
dmesg | tail or so.


mount -r -t ufs -o ufstype=ufs2 /dev/loop0 /mnt
mount: /dev/loop0 is already mounted or /mnt busy


mount -r -t ufs -o loop,ufstype=ufs2 /dev/loop0 /mnt
mount: wrong fs type, bad option, bad superblock on /dev/loop1,
missing codepage or helper program, or other error

In some cases useful info is found in syslog - try
dmesg | tail or so.

I am especially confused as to why fdisk -l shows a FreeBSD partition but mount claims it doesn't exist. ls -l also fails to show it. Does fdisk use a different method of listing block devices? Any suggestions on what else I should try? I've tried everything I can think of at this point. It *should* work but doesn't.

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Problems loop mounting ufs filesystem on centos7

Post by TrevorH » 2017/09/18 15:38:42

Where did you get the kernel module to enable ufs support?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

maxfisher
Posts: 5
Joined: 2017/09/18 13:38:47

Re: Problems loop mounting ufs filesystem on centos7

Post by maxfisher » 2017/09/18 22:03:55

Good question Trevor! There is a package on epel called am-utils which claims to support ufs and includes kernel modules ufshcd.ko and ufshcd-pci.ko. However I also installed kmod-ufs from a 3rd party vendor called onapp that focuses on customized centos for cloud. This includes the ufs.ko module for centos 7. I only used this because I couldn't find the ufs.ko module in any official repo. Did I overlook something?

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Problems loop mounting ufs filesystem on centos7

Post by TrevorH » 2017/09/18 23:07:14

The kernel modules you're mentioning: ufshcd and ufshcd-pci are part of the CentOS kernel but they're not anything to do with ufs the filesystem. Run modinfo on them and they say they are for UFS controllers. That leaves the onapp kmod-ufs - though ELRepo used to have a kmod-ufs for CentOS 6.

I'm also not quite sure what you did to create a /dev/loop0p1p4 as /dev/loop0 would be the device for a loopback mounted file, p1 would be the first partition on it but p1p4 would be the fourth partition inside the first partition...
[ 7482.023299] ufs_read_super: bad magic number
I translate that as "this isn't a UFS filesystem".
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

maxfisher
Posts: 5
Joined: 2017/09/18 13:38:47

Re: Problems loop mounting ufs filesystem on centos7

Post by maxfisher » 2017/09/19 17:34:03

It's a shame elrepo no longer has a kmod-ufs for the current version. I can't really be sure the onapp version will work with a stock centos install.

/dev/mapper/loop0p1p4 is being created by kpartx. Kpartx creates both a /dev/loop device and /dev/mapper/loop. If I fdisk -l immediately after kpartx the loop0p1p4 shows up. The weird thing is only fdisk can see it. No other file utility can. It's definitely a good thing its there. In the bsd world they use both partitions and "slices" which is another word for partition, so there is a partition table inside a partition table. Loop0 looks like the outer and loop0p1p4 the inner. So that part of it seems to be working right except that mount can't see loop0p1p4 and fdisk can.

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Problems loop mounting ufs filesystem on centos7

Post by TrevorH » 2017/09/19 18:12:05

Maybe you need to kpartx twice to get it to add mappings for the "inner" partition table.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

maxfisher
Posts: 5
Joined: 2017/09/18 13:38:47

Re: Problems loop mounting ufs filesystem on centos7

Post by maxfisher » 2017/09/21 16:51:59

That was a nice idea but kpartx -a /dev/loop0 doesn't do anything. No error but no new devices either. I am starting to think mounting ufs on centos 7 is simply not possible.

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Problems loop mounting ufs filesystem on centos7

Post by TrevorH » 2017/09/21 18:37:05

Try on /dev/loop0p1
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

maxfisher
Posts: 5
Joined: 2017/09/18 13:38:47

Re: Problems loop mounting ufs filesystem on centos7

Post by maxfisher » 2017/09/25 22:46:22

Kpartx -a /dev/mapper/loop0p1 did show some interesting results. It successfully mapped the inner partition to /dev/mapper/loop0p1p4 in a way that mount could see it. However mount -ufs -o ro,ufstype=ufs2 /dev/mapper/loop0p1p4 /mnt gives the same "bad magic number" error as before. At this point the ufs.ko module looks to be the primary suspect.

Post Reply