FreeBSD 10: Mounting USB Drive with ext4 Filesystem
I have been configuring FreeBSD 10 on my HP Pavilion laptop for a while now. On and off, I tried to mount a USB drive formatted with ext4 filesystem but failed with below messages:
# mount /dev/da0s1 /mnt
mount: /dev/da0s1: Invalid argument
# mount -t ext4 /dev/da0s1 /mnt
mount: /dev/da0s1: Operation not supported by device
Hmm... the device is not available?
# dmesg | grep da0
...
da0 at umass-sim0 bus 0 scbus1 target 0 lun 0
da0: <HITACHI_ DK23ES-20 00K5> Fixed Direct Access SCSI-0 device
da0: Serial Number 0B02011C050FB0DC
da0: 40,000MB/s transfers
da0: 19077MB (39070080 512 byte sectors: 255H 63S/T 2432C)
da0: quirks=0x2<NO_6_BYTE>
# gpart show da0
=> 63 39070017 da0 MBR (19G)
63 1985 - free - (993K)
2048 39068032 1 linux-data (19G)
# ls /dev/da0*
/dev/da0 /dev/da0s1
I have no idea why it's not working so I followed the handbook, 18.5. USB Storage Devices (and I also made a regular user mountable).
Edit /etc/devfs.rules to allow the operator group to be able to read and write the device:
# vi /etc/devfs.rules
--------------------------------------------
[localrules=5]
add path 'da*' mode 0660 group operator
Then edit /etc/rc.conf to enable the devfs.rules(5) ruleset:
# vi /etc/rc.conf
--------------------------------------------
devfs_system_ruleset="localrules"
Next allow regular user to mount file system:
# vi /etc/sysctl.conf
--------------------------------------------
vfs.usermount=1
Also execute sysctl to make the update available now:
# sysctl vfs.usermount=1
vfs.usermount: 0 -> 1
Create a directory which a regular use can mount to:
# mkdir /mnt/ubyt3m3
# chown ubyt3m3:ubyt3m3 /mnt/ubyt3m3
Now return to a regular user and try to mount the USB drive:
$ mount -t ext4 /dev/da0s1 /mnt/ubyt3m3
mount: /dev/da0s1: Invalid argument
I got Invalid argument instead of Operation not permitted but this did not resolve my original issue. Hmm... does this mean FreeBSD does not support mounting ext4 filesystem? A bit of googling found that FreeBSD supports ext2/ext3 with ext2fs type but not ext4. However, I found that FreeBSD base system comes with the fuse implementation. Indeed, there is sysutils/fusefs-ext4fuse. Let's try installing this.
# cd /usr/ports/sysutils/fusefs-ext4fuse
# make install clean
Well, will mounting work now? Let's see...
$ ext4fuse /dev/da0s1 /mnt/ubyt3m3
fuse: failed to open fuse device: No such file or directory
So, it's still not working, huh? A further googling led me to some hints. It looks like there is a kernel module for fuse, fuse.ko, and this needs to be loaded to the kernel.
# kldload fuse.ko
Lastly, edit /boot/loader.conf to load the module each boot:
# vi /boot/loader.conf
--------------------------------------------
fusefs_load="YES"
Now mounting USB drive with ext4 filesystem is working!
$ ext4fuse /dev/da0s1 /mnt/ubyt3m3
$ ls /mnt/ubyt3m3
lost+found
$
Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. It is solely used for my purpose and may not be suitable for others. I will NOT take any responsibility of end result after following these steps (although I will try to help if you send me your questions/problems).
That's all!
-gibb
Very useful post 🙂
Thanks!
Great tutorial. Thank you!
I read a lot of interesting articles here.
Probably you spend a lot of time writing, i know how to save you a lot of work, there is an online tool
that creates readable, SEO friendly posts in seconds, just search in google
– laranitas free content source
> What is the exact model of your laptop HP Pavillion where you have installed
> FreeBSD 10. ?
> Thanks
Hi Carles,
Sorry for my late reply. The model of my laptop is Pavilion dm3-1130us. I couldn’t get zfs working on it but UFS was working well as expected.
-gibb
Hello, I think this:
# vi /boot/sysctl.conf
vfs.usermount=1
need to be:
# vi /etc/sysctl.conf
vfs.usermount=1
Am I right?
Marcos, thanks for your comment. Yes, you are right. The file should have been /etc/sysctl.conf. I fixed my typo. Thanks again! -gibb
Thank you for the information. Nice post! 😀
You can mount it with the system driver just fine but you must specifically mount it read-only.
That’s what I’m looking for so long! THANKS!!!
To load the “fuse.ko” permanently you need to add
fuse_load=”YES”
to your “/boot/loader.conf” (instead of fusefs_load (which was used for /etc/rc.conf when using the fuse kmod pkg from the ports)) (below freebsd 10).
@Andreas – thank you for your info. -gibb
So many thanks, my first BSD tutorial because I need access to my linux partitions, worked flawless and enjoyable to read, cheers !
I’ll definitely give a look at your other texts.
Curious, is it possible to specify it in fstab? All my data HDD is ext4 as read-only, I am wondering to install PCBSD/FreeBSD, but somehow not mountable at boot.
Thanks for this guide. I am looking to migrate from FreeNAS9.2 to OMV. I want to use ext4 on the new set up, and this guide will help with data migration. Do you know if it is read-only or read-and-write to the ext4 drive.
Thanks in advance!
COol. It works on FreeBSD 12.1