# Ext4 on FreeBSD



## guillaje (Oct 6, 2011)

Hello,

I'm a Linux user, quite new to FreeBSD.
I recently installed FreeBSD 8.2-RELEASE amd64 as a backup server. These backups consist of the synchronisation between SAN snapshots of the FS I want to backup and ZFS filesytems.

In order to mount my Linux FS, I installed the port of e2fsprog, and it works great for EXT2/3, but not for EXT4:

I can *fsck* it :

```
endor# fsck_ext2fs /dev/da1s2
e2fsck 1.41.14 (22-Dec-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/da1s2: 63569/657072 files (0.2% non-contiguous), 498732/2624256 blocks
```

But I can't *mount* it:

```
endor# mount -t ext2fs /dev/da1s2 /mnt
mount: /dev/da1s2 : Invalid argument
```

In dmesg:

```
WARNING: mount of da1s2 denied due to unsupported optional features
```

I tried to deactivate some ext4 features of this fs on a Debian box, but I can't disable all of them:

```
root@xen0adm1:~# tune2fs -O ^flex_bg /dev/iscsi/xen0adm1-2011-09-30-14p2
tune2fs 1.41.12 (17-May-2010)
Clearing the flex_bg flag would cause the the filesystem to be
inconsistent.
root@xen0adm1:~# tune2fs -O ^uninit_bg /dev/iscsi/xen0adm1-2011-09-30-14p2
tune2fs 1.41.12 (17-May-2010)
root@xen0adm1:~# tune2fs -O ^dir_index /dev/iscsi/xen0adm1-2011-09-30-14p2
tune2fs 1.41.12 (17-May-2010)
root@xen0adm1:~# tune2fs -O ^extents /dev/iscsi/xen0adm1-2011-09-30-14p2
tune2fs 1.41.12 (17-May-2010)
Clearing filesystem feature 'extent' not supported.
```
And after that, the error is the same when I try to mount it on FreeBSD.

So my question is, is it a way to mount an EXT4 filesystem on FreeBSD? Even in ro, without journal.

Thank you,
jC


----------



## pkubaj (Oct 6, 2011)

Unfortunately, there's currently no way to mount an EXT4 slice. The original driver was created for EXT2, still, it somehow works also with EXT3, but not with EXT4.


----------



## guillaje (Oct 6, 2011)

I read that it was not possible, but this page made me think I missed something...

"This project implements preallocation in ext2fs and update ext2fs to be able to read ext4 file systems and possibly add other functionality, such as write ext4 file systems."


----------



## fluca1978 (Oct 6, 2011)

Aren't EXT3 and EXT4 back compatible with EXT2?


----------



## adamk (Oct 6, 2011)

EXT3 mostly is, EXT4 mostly is not 

Adam


----------



## davidgurvich (Oct 7, 2011)

EXT3 is forward compatible with EXT4.  An EXT4 system can be mounted as EXT3 if extents aren't enabled.  Is the ext2fs feature complete for EXT3?


----------



## phoenix (Oct 8, 2011)

You can mount an EXT3 filesystem on FreeBSD by mounting it as EXT2.

Last I checked, you could not mount an EXT3 filesystem as EXT3.


----------



## ddreamer (Nov 23, 2013)

To @fluca1978 and @adamk: EXT2 and EXT3 filesystems are compatible with the ext4 driver but the EXT4 filesystem isn't compatible with the ext2 or ext3 driver.

It seems OK to mount EXT4 in FreeBSD. See
http://pasha.spb.su/arch/483
http://forums.freebsd.org/showthread.php?t=29217&highlight=ext4 last post by @desshi


----------



## Nukama (Nov 25, 2013)

Get rid of this *L*inux file system and use ZFS  for your external and backup medium on Linux and FreeBSD.


----------



## user00 (Apr 1, 2014)

After reading the above link, I experimentally found what device and what partitions contained the Linux mounts I wanted to use under FreeBSD by issuing commands and created the below script.


```
#!/bin/sh

ext4fuse /dev/ada0s6 /mnt/f19home
ext4fuse /dev/ada0s5 /mnt/f19root
ext4fuse /dev/ada0s2 /mnt/FileDump1TB
```

Then I rebooted... Now instead of mounting the partitions, the command throws an error:


```
# ./f19mnt.sh
fuse: failed to open fuse device: No such file or directory
fuse: failed to open fuse device: No such file or directory
fuse: failed to open fuse device: No such file or directory
```

Fuse FS is enabled in rc.conf just as it was when it worked. What could I possibly break?


----------



## user00 (Apr 1, 2014)

Turns out, I was not loading fuse module in /boot/loader.conf and that's why ext4fuse was not working. Added a line and loaded the module on command line and EXT4 can be mounted again.


----------



## Ldak (Mar 9, 2016)

You guys got me working, thanks...


----------



## HD Scania (Jan 22, 2018)

The same issue here (my /dev/ada0p23 is surely not ext4),

```
[hd_scania@trueos] ~% sudo fsck_ext2fs /dev/ada0p23
sudo: fsck_ext2fs: command not found
[hd_scania@trueos] ~% sudo fsck -t ext2fs /dev/ada0p23
fsck: exec fsck_ext2fs for /dev/ada0p23 in /sbin:/usr/sbin: No such file or directory
[hd_scania@trueos] ~% sudo mount -t ext2fs /dev/ada0p23 /data && ls -la /data
mount: /dev/ada0p23: Operation not permitted
[hd_scania@trueos] ~% sudo fuse
sudo: fuse: command not found
[hd_scania@trueos] ~% sudo ext2fuse /dev/ada0p23 /data && ls -la /data
sudo: ext2fuse: command not found
[hd_scania@trueos] ~% sudo gpart show /dev/ada0
=>       34  976773101  ada0  GPT  (466G)
         34       2014        - free -  (1.0M)
       2048   58484736     1  freebsd-zfs  (28G)
   58486784     235520        - free -  (115M)
   58722304   16777216     2  freebsd-swap  (8.0G)
   75499520   58720256     3  freebsd-zfs  (28G)
  134219776    2097152     4  efi  (1.0G)
  136316928   33554432     5  linux-data  (16G)
  169871360   33554432     6  linux-data  (16G)
  203425792   33554432     7  linux-data  (16G)
  236980224   33554432     8  linux-data  (16G)                                                                                                                                                
  270534656   16777216     9  linux-swap  (8.0G)                                                                                                                                                
  287311872   33554432    10  linux-data  (16G)                                                                                                                                                
  320866304   33554432    11  linux-data  (16G)                                                                                                                                                
  354420736   33554432    12  linux-data  (16G)                                                                                                                                                
  387975168   33554432    13  linux-data  (16G)                                                                                                                                                
  421529600   16777216    14  linux-swap  (8.0G)                                                                                                                                                
  438306816   33554432    15  linux-data  (16G)
  471861248   33554432    16  linux-data  (16G)
  505415680   33554432    17  linux-data  (16G)
  538970112   33554432    18  linux-data  (16G)
  572524544   57200640    19  freebsd-zfs  (27G)
  629725184     235520        - free -  (115M)
  629960704    1048576    24  freebsd-swap  (512M)
  631009280     235520        - free -  (115M)
  631244800    2097152    20  freebsd-boot  (1.0G)
  633341952   58720256    21  freebsd-zfs  (28G)
  692062208   16777216    22  freebsd-swap  (8.0G)
  708839424  267933696    23  linux-data  (128G)
  976773120         15        - free -  (7.5K)

[hd_scania@trueos] ~%
```
By having run all the commands I’ve searched online they’re made of nonsense.


----------



## HD Scania (Jan 22, 2018)

Unsure for ext3 but ext4 ones are surely read-only and most of the needed drivers are missing other than ext2.


adamk said:


> EXT3 mostly is, EXT4 mostly is not
> Adam


----------



## ShelLuser (Jan 23, 2018)

A solid way to gain access to ext4 is by using sysutils/fusefs-ext2. Despite it's name it also provides access to EXT4. First make sure you have FUSE enabled in your kernel (`# kldload fuse`) then use fuse-ext2 to actually mount the filesystem. See also fuse-ext2(1).

Instead of randomly trying out commands in hopes they work (what made you think that fuse is an actual command?) it helps to check up on basics first.


----------

