# fuse-ext2 -o rw+ /dev/da0p1 /mnt/a not working with zfs root freebsd 12



## azathoth (Apr 13, 2019)

I have a external hard drive ext4(I am 99% sure anyway)
I have zfs root freebsd 12 on a desktop.
I have /mnt/a owned by user g
I loaded the fuse module after installing fusefs-ext2 using pkg
It won't mount...

```
# history | grep kldload
    12  9:48    kldload ext2fs
    53  10:16   kldload fuse

# fuse-ext2 -o rw+ /dev/da0p1 /mnt/a
# df -h
Filesystem            Size    Used   Avail Capacity  Mounted on
zroot/ROOT/default     14G    4.9G    9.2G    35%    /
devfs                 1.0K    1.0K      0B   100%    /dev
zroot/tmp             9.2G    2.5M    9.2G     0%    /tmp
zroot/usr/home        886G    877G    9.2G    99%    /usr/home
zroot/usr/ports       9.2G     88K    9.2G     0%    /usr/ports
zroot/usr/src         9.2G     88K    9.2G     0%    /usr/src
zroot/var/audit       9.2G     88K    9.2G     0%    /var/audit
zroot/var/crash       9.2G     88K    9.2G     0%    /var/crash
zroot/var/log         9.2G    484K    9.2G     0%    /var/log
zroot/var/mail        9.2G    120K    9.2G     0%    /var/mail
zroot/var/tmp         9.2G     88K    9.2G     0%    /var/tmp
zroot                 9.2G     88K    9.2G     0%    /zroot


# gpart show /dev/da0
=>        6  976754420  da0  GPT  (3.6T)
          6        250       - free -  (1.0M)
        256  976754170    1  linux-data  (3.6T)
```

Why will this not work?


----------



## azathoth (Apr 13, 2019)

```
# fuse-ext2 -d /dev/da0p1 /mnt/a

fuse-ext2 0.0.9 29 - FUSE EXT2FS Driver

Copyright (C) 2008-2015 Alper Akcan <alper.akcan@gmail.com>
Copyright (C) 2009 Renzo Davoli <renzo@cs.unibo.it>

Usage:    fuse-ext2 <device|image_file> <mount_point> [-o option[,...]]

Options:  ro, force, allow_other
          Please see details in the manual.

Example:  fuse-ext2 /dev/sda1 /mnt/sda1

http://github.com/alperakcan/fuse-ext2/
```


----------



## twllnbrck (Apr 13, 2019)

azathoth said:


> I have a external hard drive ext4(I am 99% sure anyway)



Is your external drive ext2 or ext4? Although FreeBSD classifies all ext filesystems as ext2 there is a difference. ext2fs has full read and write support but ext4fs still just read only.
I never succeed to mount ext4 with sysutils/fusefs-ext2 and continue using sysutils/fusefs-ext4fuse:

```
# ext4fuse /dev/da0p1 /mnt/a
```


----------



## azathoth (Apr 13, 2019)

```
# ext4fuse /dev/da0p1 /mnt/a
Assertion failed: (pread_ret == 1024), function pread_wrapper, file disk.c, line 47.
```


----------



## Phishfry (Apr 13, 2019)

You can tell exactly what the filesystem is by using file(1)
For example:
`file -s /dev/ada0` << Partition Table Information
`file -s /dev/ada0s1a` << Partition Information
For GPT partitions:
`file -s /dev/ada0p1`


----------



## azathoth (Apr 14, 2019)

```
# file -s /dev/da0p1
/dev/da0p1: Linux rev 1.0 ext4 filesystem data, UUID=ff3a170b-2b07-41fb-9392-85c256c8cd9d (extents) (64bit) (large files) (huge files)
```


----------



## Wozzeck.Live (Apr 14, 2019)

There are a lot of confusions

*1) **FreeBSD kernel module ext2fs*

Since FreeBSD 12, FreeBSD is "theoretically" able to mount in RW ext2, ext3, ext4 using the kernel module ext2fs which is a generic module for all ext class filesystems.
It is true that FreeBSD is unable to differentiate which version of ext it is

Using `files -s /dev/...` or `fstyp /dev/...` will only report ext2 class linux filesystem under FreeBSD
The same `file` command under Linux will not send the same result, it will send the exact version of ext

I have tested on my FreeBSD system and confirm again that point. YOU CAN'T RELY on theses commands to guess the filesystem type
Moreover, xfs, btrfs,reiserfs won't be detected at all.
To define the exact linux filesystem, one must use linux `blkid` included in the package sysutils/e2fsprogs

So using the FreeBSD kernel module, there is no need to install a fuse port, just the need to load the kernel module that in most case should auto load. We mount the partition with a simple command

`mount -t ext2fs -o rw /dev/... /mountpoint`

The option "allow-other" is not available because "allow-other" is a fuse option.
In this case we don't use fuse.

*But* : it is not recommended to use FreeBSD kernel module to mount ext3/ext4 in RW mode and in most of case mounting fails. ext2fs kernel module only handles correctly Ext2 in RW mode (that was already the case long time ago now ) .

- FreeBSD kernel module doesn't support EXT3/4 journaling. As long as journaling is activated on ext3/ext4 (which is the behavior by default on this class of filesystem, as opposed to ext2 which has no journalization option), it is not recommended to use FreeBSD kernel module. And even if you deactivate journaling, reconnecting this media on a Linux machine, and Linux tends to reactivate the journal.

- In most of case mounting operations terminate with an error if a journal is present . If the filesystem is not flagged clean (such thing happens often when media hasn't been disconnected cleanly), it is required to replay the ext3/ext4 journal before mounting to reflag the filesystem as clean. FreeBSD is unable to do that by default. If no journal is present, it seems that FreeBSD can mount ext3/ext4 filesystem even if the filesystem is marked "unclean". This may be potentially dangerous....

Repairing and reflagging to clean state can only be done by the Linux program `e2fsck` also included in the e2fsprogs package.

RW operations can be handled by sysutils/fusefs-ext2 and sysutils/fusefs-lkl
syustils/fusefs-ext4fuse only supports RO mode

*2) Fusefs-ext2*

For fusefs-ext2, it is specified in the man page that RW support for ext3, ext4 is only experimental so it is not recommended to use it for RW operations.

I don't exactly know if it really supports journaling, but anyway if the system is flagged dirty, we should call e2fsck first, this could be the reason why some people experience problems in the mounting process.

The command to use is :

`fuse-ext2 -o rw+ /dev/... /mountpoint`


*3) Fusefs-lkl*

Fusefs-lkl is finally THE PREFERED solution to mount in RW mode ANY linux filesystem
It handles ext2, ext3, ext4, xfs, btrfs

If filesystem is not clean, it generally calls automatically the non interactive pre-command `e2fsck -p /dev/....`  (e2fsprogs package being a dependency), so mounting operation rarely fails... except if filesystem is more severely corrupt and can't be repaired with a one pass non interactive e2fsck.
Sometimes we need to pass several times e2fsck to get the filesystem repaired (exactly the same thing for FreBSD UFS `fsck`), and sometimes the filesystem is definitively corrupt and can't be mounted neither in FreeBSD neither in Linux

"LKL" means "Linux Kernel as a Library", so it uses the official Linux Kernel, and we can consider that it brings a quasi native support of Linux Filesystems. I am quite sure that fusefs-lkl fully and securely handles ext3/ext4 journalization, I have some doubts regarding fusefs-ext2

The command to use for ext4 filesystem is :

`lklfuse -o type=ext4 /dev/... /mountpoint`

By default it mounts filesystem in RW mode, and you will notice that fusefs-lkl requires the exact filesystem type.
If you have a doubt, use before `blkid /dev/....`
In a script you can use `blkid -o value -s TYPE /dev/...` to get a straightforward answer


----------



## azathoth (Jun 26, 2019)

I should try this now.


----------



## aragats (Dec 13, 2019)

Wozzeck.Live said:


> Fusefs-lkl is finally THE PREFERED solution to mount in RW mode ANY linux filesystem
> It handles ext2, ext3, ext4, xfs, btrfs


Why the filesystem mounted with sysutils/fusefs-lkl is not listable by regular users?
All other variants are.


----------



## aragats (Dec 13, 2019)

Wozzeck.Live said:


> I have some doubts regarding fusefs-ext2


I have strong evidences it's screws up (at least) symlinks and cannot handle large number of files (50k+).


----------



## T-Daemon (Dec 13, 2019)

aragats said:


> Why the filesystem mounted with sysutils/fusefs-lkl is not listable by regular users?


Add allow_other option:
`lklfuse -o type=ext4,allow_other /dev/.. /mountpoint`.
For more options run `lklfuse --help`


----------



## aragats (Dec 13, 2019)

T-Daemon said:


> Add allow_other option:
> lklfuse -o type=ext4,allow_other /dev/.. /mountpoint.


Thanks for the hint.
However, it doesn't answer my question:
If I see that a directory is traversable/listable for ALL, but actually it is NOT, that's really bad: how can I trust other files/dirs permissions that time?


----------

