Solved Mounting a logical ext4 partition in FreeBSD

usakhncit

Active Member

Reaction score: 32
Messages: 241

Hi
I want to mount my ext4 partition in FreeBSD. It is a logical partition (/dev/sda5 in linux). In FreeBSD it is shown as:
Code:
[root@pc ~]# gpart show ada0s3
=>         0  1251235840  ada0s3  EBR  (597G)
           0  1251235840       1  linux-data  (597G)
I have tried following:
Code:
[root@pc~] mount -t ext2fs -o ro /dev/ada0s3 /home/user/linux-data
mount: /dev/ada0s3: Invalid argument
and
Code:
[root@pc~] mount -t ext2fs -o ro /dev/ada0s3p1 /home/user/linux-data
mount: /dev/ada0s3p1: No such file or directory
How can I mount this partition?
Regards
 
OP
U

usakhncit

Active Member

Reaction score: 32
Messages: 241

The above issue is resolved, but there is another attached issue. I want to mount this drive automatically at boot with write-permission. So, I have placed following:
Code:
/dev/ada0s5    /home/user/linux-home  ext2fs  late,rw  0       0
in /etc/fstab. But still it is mounting with read-only persmissions. How can I make it read-write?
Thanks
 

twllnbrck

Well-Known Member

Reaction score: 206
Messages: 275

I guess using sysutils/fusefs-lkl is the recommended way to mount any Linux FS in rw mode.
Note that it requires the exact filesystem type, in your case

Code:
lklfuse -o type=ext4 /dev/ada0s5 /home/user/linux-home
 
OP
U

usakhncit

Active Member

Reaction score: 32
Messages: 241

I guess using sysutils/fusefs-lkl is the recommended way to mount any Linux FS in rw mode.
Note that it requires the exact filesystem type, in your case

Code:
lklfuse -o type=ext4 /dev/ada0s5 /home/user/linux-home
It is giving error:
Code:
[root@pc ~]# lklfuse -o type=ext4 /dev/ada0s5 /home/user/linux-home/
fuse: failed to open fuse device: No such file or directory
Some forums has suggested to put following in /etc/fstab:
Code:
/dev/ada0s5 /home/user/linux-home fuse mountprog=/usr/local/bin/lklfuse,type=ext4,opts=space_cache,compress=no,discard 0 0
But it is giving following error:
Code:
[root@pc ~]# mount /dev/ada0s5
fstab: /etc/fstab:9: Inappropriate file or format
fstab: /etc/fstab:9: Inappropriate file type or format
mount: /dev/ada0s5: unknown special file or file system
Kindly guide me to solve this?
Thanks
 
OP
U

usakhncit

Active Member

Reaction score: 32
Messages: 241

Have you loaded the fuse.ko kernel module via /etc/rc.conf or /boot/loader.conf?
No, I did not load the module. Now, after loading the module, I can mount with following command:
Code:
lklfuse -o type=ext4 /dev/ada0s5 /home/user/linux-home/
but with read-only permissions. How can I mount with read-writer permission?
 
OP
U

usakhncit

Active Member

Reaction score: 32
Messages: 241

sysutils/fusefs-lkl should mount in rw mode by default. Is your user allowed to mount and what does your /etc/devfs.conf look like? Have you specified any rules in /etc/devfs.rules?
Following is the content of /etc/devfs.conf (last few lines):
Code:
# Examples:

# Commonly used by many ports
#link    cd0    cdrom
#link    cd0    dvd

# Allow a user in the wheel group to query the smb0 device
#perm    smb0    0660

# Allow members of group operator to cat things to the speaker
own    speaker    root:operator
perm    speaker    0660
I am a member of 'operator' group. Here is the output of /etc/devfs.rules
Code:
[localrules=5]
add path 'da*' mode 0660 group operator
 

twllnbrck

Well-Known Member

Reaction score: 206
Messages: 275

Mmh. It worked for me with a similar devfs.rules. Maybe there is a permission problem with the owner/group of your ext4 disk. You can try lklfuse with the -o allow_other option.
Or try to add
Code:
perm    /dev/da0    0666
to your /etc/devfs.conf.
 
OP
U

usakhncit

Active Member

Reaction score: 32
Messages: 241

Mmh. It worked for me with a similar devfs.rules. Maybe there is a permission problem with the owner/group of your ext4 disk. You can try lklfuse with the -o allow_other option.
Or try to add
Code:
perm    /dev/da0    0666
to your /etc/devfs.conf.
Thanks. (-o allow_other) worked. Now how can I use it in /etc/fstab? Because, following entry in /etc/fstab is not working:
Code:
/dev/ada0s5 /linux-home        fuse    mountprog=/usr/local/bin/lklfuse,type=ext4,opts=space_cache,compress=no,discard,allow_other 0 0
It gives error: (Inappropriate file type or format). Kindly guide me that what should I use in 'fstab'?
Thanks
 

twllnbrck

Well-Known Member

Reaction score: 206
Messages: 275

Im not sure, never tried it. But I think you may succed with late option and ext4 as FStype.
I have no ext4 device at hand to test it. But this is my presumption

Code:
/dev/ada0s5 /linux-home   ext4    mountprog=/usr/local/bin/lklfuse,type=ext4,opts=space_cache,compress=no,discard,allow_other,late 0 0
 
OP
U

usakhncit

Active Member

Reaction score: 32
Messages: 241

Im not sure, never tried it. But I think you may succed with late option and ext4 as FStype.
I have no ext4 device at hand to test it. But this is my presumption

Code:
/dev/ada0s5 /linux-home   ext4    mountprog=/usr/local/bin/lklfuse,type=ext4,opts=space_cache,compress=no,discard,allow_other,late 0 0
No, not working. Giving following error:
Code:
[user@pc ~]$ sudo mount /dev/ada0s5
fstab: /etc/fstab:5: Inappropriate file type or format
fstab: /etc/fstab:5: Inappropriate file type or format
mount: /dev/ada0s5: unknown special file or file system
[user@pc ~]$ sudo mount -a
fstab: /etc/fstab:5: Inappropriate file type or format
 

Alain De Vos

Daemon

Reaction score: 613
Messages: 2,073

I found a few problems with lkl.
One, you cannot mount read only.
Two, you cannot mount with other user credentials.
I personally consider it "alpha" :).
I would use ext4fuse.
 

T-Daemon

Daemon

Reaction score: 829
Messages: 1,697

One, you cannot mount read only.
mount -t fuse -o ro,mountprog=/usr/local/bin/lklfuse,type=ext4,allow_other /dev/xxx /xx
I found a few problems with lkl.
Same here. I observed on my system, when creating a file in the lklfuse mounted ext4 partition, the file is created sometimes with a correct timestamp, but mostly with a Jan 1 1970 timestamp.
 
OP
U

usakhncit

Active Member

Reaction score: 32
Messages: 241

Add: rw, remove: opts=space_cache,compress=no,discard
Code:
/dev/ada0s5 /linux-home        fuse    rw,mountprog=/usr/local/bin/lklfuse,type=ext4,allow_other 0 0
Although, this solved my problem, but as you mentioned about wrong timestamp, so, should I avoid using lkl?
 
OP
U

usakhncit

Active Member

Reaction score: 32
Messages: 241

I found a few problems with lkl.
One, you cannot mount read only.
Two, you cannot mount with other user credentials.
I personally consider it "alpha" :).
I would use ext4fuse.
Hmm... thinking about trying ext4fuse, lets see... :)
 

Wozzeck.Live

Member

Reaction score: 129
Messages: 78

Please read this thread
https://forums.freebsd.org/threads/...g-with-zfs-root-freebsd-12.70401/#post-424036

For RW operation THERE IS NO OTHER WAY than lklfuse, all other way may be hazardous for your data

As long a you need RO mode, there are many other solutions, but in any case EXT4FUSE doesn't support RW mode.

Regarding the wrong timestamp, I have also noticed that, except that this is not specially linked to lklfuse.
Even with kernel module extf2fs (so NOT fuse related), sometimes timestamp is good, sometimes timestamp is wrong

In fact my policy is to automount ext4 through autofs in RO mode only using kernel module ext2fs
BUT if an ext4 device is found to have a journal activated (in fact the behaviour by default), I have an autofs script that auto select lklfuse.

ext2fs kernel module doesn't support ext4 journal. When the device is in a dirty state, YOU CANNOT mount ext4 partition, even in read only mode, ext2fs, and also other fuse based mounters run into error... the thread explain why.
 

Wozzeck.Live

Member

Reaction score: 129
Messages: 78

I have just made a quick test

In root mode
lklfuse -o ext4,ro /dev/da3s3 /mnt/hdd1

Ext4 partition is correctly mounted in Read Only mode.
I have checked with mount -l and I have also tried to write on it

In user mode
lklfuse -o ext4,ro /dev/da3s3 ~/test

Also works, device is protected
"test" is a directory I have created in the home directory of the user.

in sysctl.conf, in order to authorize filesystem mount by a user
Code:
vfs.usermount=1

But be carefull, mount can only occur in a directory owned by the given user

in rc.conf
Code:
devfs_system_ruleset="system"

Note that :
devfs.conf handles authorizations for device present at boot
devfs.rules handles different set of authorizations for devices connected after boot
This is the reason whit rc.conf must instruct the system which is the ruleset name to use for the system

In devfs.rules, to authorize mobile drive mounting connected after boot
Code:
[system=20]
.....
....
add path 'da[0-9]' mode 0660 group operator
....
...

[jail_base=17]
....
....

So, in my example user account must be included in the "operator" group
If a usb device is connected at boot and we wish to authorize further mounting/dismounting by the user so set in devfs.conf

Code:
....
....
own /dev/da* root:operator
perm /dev/da* 0660
 
Top