Howto mount ext4 (without FUSE), avoiding wrong permissions

tobiam

Member

Reaction score: 24
Messages: 87

This is going to be short. I write this tutorial, because a lot of tutorials mention ext4fuse. While it works for some things one experiences quite a few oddities.

Examples of problems I experienced:
  • everything has only read permissions
  • it is possible cd into non existing directories
  • things like recursive copies cause failures
  • sometimes stuff can't be read correctly
I wrote that everything has only read permissions. This DOES NOT mean that using this approach will give you write access, but that you SEE the right permissions. The effect is that copying over files via ext4fuse will cause you to have files that only be read-only. With this tutorial you will get the right permissions.

In other words: The file system will still be mounted read-only, but the permissions will be correct.

There is three things you need to take care of:
  • Load the ext2fs kernel module
  • Mount the partition with -t ext2fs (you need to specify it and it's ext2fs, not ext2!)
  • Mount it read-only! Trying to mount the partition without -o ro will not work


# Load the kernel module
kldload ext2fs

# mount
mount -t ext2fs -o ro /dev/<device/partition> <mountpoint>

# Exmaples:
mount -t ext2fs -o ro /dev/ad1s1 /mnt/

# Or on a different partition scheme (p vs s):
mount -t ext2fs -o ro /dev/ada0p1 /mnt/


So to repeat the important points. Load the kernel module! Make sure you always write ext2fs, both for the module AND the mount option. Don't forget about the fs part. And make sure to mount it read only.

You can of course add ext2fs to the list of automatically loaded kernel modules, so you don't have to load it over and over again.

In your /etc/rc.conf add:
Code:
kld_list="ext2fs"
This will make sure that the kernel module will be loaded on boot. If you already have a kld_list entry then just append ext2fs to it.
 

mercurial

New Member


Messages: 3

This does not work for me. I am using FreeBSD 12.0-CURRENT amd64. ext4fuse will mount the partition but the transfer rate is painfully slow. I have ext2fs module loaded. I've tried it with and without fuse. Any suggestions ?
 

aragats

Daemon

Reaction score: 610
Messages: 1,508

mercurial , have you looked into dmesg output?
I guess, the problem is that the latest Linux's mke2fs adds some new features to ext4, here is what I get after an unsuccessful mount:
Code:
$ dmesg
. . . . .
WARNING: mount of da0s1 denied due to unsupported optional features
 

mercurial

New Member


Messages: 3

I get the same thing. Thank You aragats. I used to use reiserfs for linux partitions but FreeBSD dropped support for reiserfs. I have slightly over 10 GB of data to transfer. It's actually 2 times faster to transfer via ethernet using NFS
 

islamux

Member

Reaction score: 4
Messages: 46

i can mount ext4 manualy by
ext4fuse /dev/ada0X /mnt

But for making it automatically mount in fstab i added ntfs and it's ok but when i added ext4
it dosn't load the system from boot and hung ?
i boot in single user and fsck the system and disable the automount of ext4 and it boot normaly
whatls the problem?
 

aragats

Daemon

Reaction score: 610
Messages: 1,508

Do you have late option for it? I have the following in my /etc/fstab:
Code:
/dev/da0s1   /mnt/sdcard   ext4   mountprog=/usr/local/bin/ext4fuse,allow_other,late,rw   0   0
Back to the original topic: when mounted with ext4fuse it doesn't show the correct permissions, which is very annoying...
 

islamux

Member

Reaction score: 4
Messages: 46

Do you have late option for it? I have the following in my /etc/fstab:
Code:
/dev/da0s1   /mnt/sdcard   ext4   mountprog=/usr/local/bin/ext4fuse,allow_other,late,rw   0   0
Back to the original topic: when mounted with ext4fuse it doesn't show the correct permissions, which is very annoying...
i used your options and it' ok :D
thanx for the second time friend aragats:)
 

Barney

Member

Reaction score: 10
Messages: 98

whats the device/option to compile ext2fs into the kernel as opposed to using a loadable module?
 

Phishfry

Son of Beastie

Reaction score: 1,962
Messages: 4,960

ext2fs(5)
Add to your kernconf:
options EXT2FS

The biggest problem I have found with ext3/ext4 is FS journaling.
If you disable it on Linux than FreeBSD ext2fs works great.
With journaling enabled I have found that FreeBSD can corrupt the journal.
Not hard fixing it on Linux but not seemless.
 

Barney

Member

Reaction score: 10
Messages: 98

ext2fs(5)
Add to your kernconf:
options EXT2FS

The biggest problem I have found with ext3/ext4 is FS journaling.
If you disable it on Linux than FreeBSD ext2fs works great.
With journaling enabled I have found that FreeBSD can corrupt the journal.
Not hard fixing it on Linux but not seemless.
I just occasionally need to mount a drive to change an IP address or interface name when I move a disk, so I'm not too worried about it. Linux has that great 3px font on the console so working on the console is a bit of a struggle. Thanks for the info.
 
Top