# Mounting an USB flash drive that has Ventoy in it



## bluray (Oct 2, 2022)

I have a pen drive with Ventoy installed to where I want to move a Fedora ISO to. In /dev there are da0, da0s1, da0s2. I tried to mount da0, which is the right partition to move ISOs to, but it says invalid argument. The commands I used were:`mount_msdosfs /dev/da0 /media/pendrive` and `mount -v -t msdosfs /dev/da0 /media/pendrive` both exhibiting invalid argument. Please help.


----------



## ralphbsz (Oct 2, 2022)

So many things could be wrong. To begin with, Ventoy does something funny: while it is not an OS, in some fashion (which a 1-minute scan of the web doesn't explain) it takes over managing the file systems on the memory stick. But it doesn't seem to work under FreeBSD, at least not according to its documentation.

Next question: "Invalid argument" can have many causes. Most likely, /dev/da0 is the wrong thing, that would be the whole pen drive, but it is partitioned. If da0s1 and da0s2 exist, then da0 does not contain a file system you can mount. Try the above commands again with da0s1/da0s2 instead as the first argument. And before you do that, you should find out which of the two actually is the file system you want to write to, and what the file system type is. You can use for example the "file" utility to determine that.

Another possible failure: /pendrive or /media/pendrive may be missing, or may have the wrong permissions (if you are not root).


----------



## bluray (Oct 2, 2022)

ralphbsz said:


> So many things could be wrong. To begin with, Ventoy does something funny: while it is not an OS, in some fashion (which a 1-minute scan of the web doesn't explain) it takes over managing the file systems on the memory stick. But it doesn't seem to work under FreeBSD, at least not according to its documentation.
> 
> Next question: "Invalid argument" can have many causes. Most likely, /dev/da0 is the wrong thing, that would be the whole pen drive, but it is partitioned. If da0s1 and da0s2 exist, then da0 does not contain a file system you can mount. Try the above commands again with da0s1/da0s2 instead as the first argument. And before you do that, you should find out which of the two actually is the file system you want to write to, and what the file system type is. You can use for example the "file" utility to determine that.
> 
> Another possible failure: /pendrive or /media/pendrive may be missing, or may have the wrong permissions (if you are not root).


Sorry, I meant /media/pendrive for the two commands. I've created this directory and mounted on it as root. When I do
`mount -v -t msdosfs /dev/da0s1 /media/pendrive`, the output is:

```
mount_msdosfs: /dev/da0s1: Invalid argument
zroot/ROOT/default on / (zfs, local, noatime, nfsv4acls, fsid b54b080cde7b036e)
```
Btw, the system is able to successfully mount /dev/da0s2 on /media/pendrive but it's not the right partition to put the ISO in. Because I already have two ISOs (FreeBSD and ArchLinux) in this Ventoy setup and they don't show up in the /dev/da0s2 partition.


----------



## rawthey (Oct 3, 2022)

bluray said:


> Sorry, I meant /media/pendrive for the two commands. I've created this directory and mounted on it as root. When I do
> `mount -v -t msdosfs /dev/da0s1 /media/pendrive`, the output is:
> 
> mount_msdosfs: /dev/da0s1: Invalid argument
> zroot/ROOT/default on / (zfs, local, noatime, nfsv4acls, fsid b54b080cde7b036e)



That partition is usually an EXFAT filesystem. You'll need to install sysutils/fusefs-exfat
 from packages or ports and mount it with `mount.exfat /dev/da0s1 /media/pendrive`


----------



## bluray (Oct 4, 2022)

rawthey said:


> That partition is usually an EXFAT filesystem. You'll need to install sysutils/fusefs-exfat
> from packages or ports and mount it with `mount.exfat /dev/da0s1 /media/pendrive`


The result for that is:


```
root@bluray:/media # mount.exfat /dev/da0s1 /media/pendrive
FUSE exfat 1.3.0
WARN: volume was not unmounted cleanly.
fuse: failed to open fuse device: No such file or directory
```

I've given up and plugged my flash drive on a macbook to save the ISO.


----------



## freejlr (Oct 8, 2022)

Please show the output of this command:

`gpart list da0`


----------



## siguri (Dec 8, 2022)

May I join with my output of gpart list da0, please?
My output looks like this
Geom name: da0
modified: false
state: OK
fwheads: 255
fwsectors: 63
last: 976773167
first: 63
entries: 4
scheme: MBR
Providers:
1. Name: da0s1
   Mediasize: 500080574464 (466G)
   Sectorsize: 512
   Stripesize: 0
   Stripeoffset: 1048576
   Mode: r0w0e0
   efimedia: HD(1,MBR,0x7ad965e6,0x800,0x3a379000)
   rawtype: 7
   length: 500080574464
   offset: 1048576
   type: ntfs
   index: 1
   end: 976721919
   start: 2048
Consumers:
1. Name: da0
   Mediasize: 500107862016 (466G)
   Sectorsize: 512
   Mode: r0w0e0

I also have installt sysutils/fusefs-exfat an still I don|t get it right, is the Mode r0w0r0 part of the problem?


----------



## elgrande (Dec 8, 2022)

I think fuse requires loading of a kernel module.


----------



## BobSlacker (Dec 8, 2022)

rawthey said:


> That partition is usually an EXFAT filesystem. You'll need to install sysutils/fusefs-exfat
> from packages or ports and mount it with `mount.exfat /dev/da0s1 /media/pendrive`


Beside that, if you put `vfs.usermount=1` in /etc/sysctl.conf and


```
root@FreeBaSeD-T430:~ # cat /etc/devfs.rules
[system=10]
add path 'ad[0-9]\*'        mode 666 group operator
add path 'ada[0-9]\*'        mode 666 group operator
add path 'da[0-9]\*'        mode 666 group operator
add path 'acd[0-9]\*'        mode 666 group operator
add path 'cd[0-9]\*'        mode 666 group operator
add path 'mmcsd[0-9]\*'        mode 666 group operator
add path 'pass[0-9]\*'        mode 666 group operator
add path 'xpt[0-9]\*'        mode 666 group operator
add path 'ugen[0-9]\*'        mode 666 group operator
add path 'usbctl[0-9]\*'    mode 666 group operator
add path 'usb/\*'            mode 666 group operator
add path 'fd[0-9]\*'        mode 666 group operator
add path 'uscan[0-9]\*'        mode 666 group operator
add path 'video[0-9]\*'        mode 666 group operator
add path 'lpt[0-9]\*'        mode 666 group cups
add path 'ulpt[0-9]\*'        mode 666 group cups
add path 'unlpt[0-9]\*'        mode 666 group cups
```

And


```
root@FreeBaSeD-T430:~ # tail -20 /etc/devfs.conf
perm    vboxnetctl 0660

# Permit users to acess various devices
perm    /dev/acd0    0666
perm    /dev/acd1    0666
perm    /dev/cd0    0666
perm    /dev/da0    0666
perm    /dev/da1    0666
perm    /dev/da2    0666
perm    /dev/da3    0666
perm    /dev/da4    0666
perm    /dev/da5    0666
perm    /dev/pass0    0666
perm    /dev/uscanner0    0666
perm    /dev/video0    0666

# In order for wireshark be able to capture packets when used by unprivileged
# user, /dev/bpf should be in network group and have read-write permissions.
own  bpf* root:network
perm bpf* 0660
```

You can mount using graphical file manger with a mouse click.


----------



## siguri (Dec 12, 2022)

wow, you guys pr0duced a whole lot of advices, thank you!
so far I managed with ntfs-3g, that did it. That last entry I did not swallow yet, but it looks interessting too :9


----------



## siguri (Dec 13, 2022)

Y:
ou can mount using graphical file manger with a mouse click.                  
:: this is an idea I rilly like a lot...

still... ok, so <root> is doing well, however <user> is not allowed to do mount_fusefs, hm. <vfs.usermount=1 in /etc/sysctl.conf> yes, I did...


----------



## rawthey (Dec 13, 2022)

siguri said:


> still... ok, so <root> is doing well, however <user> is not allowed to do mount_fusefs, hm. <vfs.usermount=1 in /etc/sysctl.conf> yes, I did...



Did you edit /etc/devfs.conf and add the following lines?

```
own     da*     root:operator
perm    da*     0660
```
I think you need to reboot, or `service devfs restart` for it to take effect


----------



## smithi (Dec 13, 2022)

siguri said:


> Y:
> ou can mount using graphical file manger with a mouse click.
> :: this is an idea I rilly like a lot...



If there are any users apart from yourself using this system, you need to be very careful about granting user access - especially read/write access - to a wide range of devices.  Some of those listed above horrify me, e.g. /dev/ada* ...



siguri said:


> still... ok, so <root> is doing well, however <user> is not allowed to do mount_fusefs, hm. <vfs.usermount=1 in /etc/sysctl.conf> yes, I did...



Please read chapter (now) 19 of the Handbook, particularly 19.4 on USB devices.  Some advice given in this thread contradicts that; I'd bet on the Handbook.



rawthey said:


> Did you edit /etc/devfs.conf and add the following lines?
> 
> ```
> own     da*     root:operator
> ...



Section 19.4 rather recommends adding to /etc/devfs.rules: 
	
	



```
[localrules=5]
add path 'da*' mode 660 group operator
```
and to /etc/rc.conf:

```
devfs_system_ruleset="localrules"
```



rawthey said:


> I think you need to reboot, or `service devfs restart` for it to take effect



The latter should be sufficient.

However you also need the user concerned to own the directory being mounted upon. Either use a local directory e.g. ~/mymnt (easiest) or have root add user's subdirectories to system mountpoints e.g. /media


```
# mkdir -p /media/siguri
# chown siguri /media/siguri
```


----------



## siguri (Dec 13, 2022)

Hello Smithi, thank You for your reply. The recommendation reflect my path of doing, so I get the feeling I am on the right track...


----------



## siguri (Dec 15, 2022)

Now, that I  tried this and that  with the stuff you guys put here I still find <user> to be not permitted to do <code: ntfs-3g /dev/da0s1 /mnt/user>. And yes, /mnt/user is chown and yes, <user> is in group operator...?hm What do say to that, if I  may ask.


----------



## BobSlacker (Dec 15, 2022)

siguri said:


> Y:
> ou can mount using graphical file manger with a mouse click.
> :: this is an idea I rilly like a lot...
> 
> still... ok, so <root> is doing well, however <user> is not allowed to do mount_fusefs, hm. <vfs.usermount=1 in /etc/sysctl.conf> yes, I did...



Sorry, I forgot about the groups.
Here are the ones I'm in:


----------



## siguri (Dec 15, 2022)

By the way... instead of opening another thread. May I ask here how-to mount an .iso file. I used to this in linux with <mount -o loop Freud.iso /media>. How are you doing this in freebsd, please?


----------



## smithi (Dec 15, 2022)

siguri said:


> By the way... instead of opening another thread. May I ask here how-to mount an .iso file. I used to this in linux with <mount -o loop Freud.iso /media>. How are you doing this in freebsd, please?


Sorry, fatfingered 'post' ... back soon

Study mdconfig(8)


```
# mdconfig Freud.iso
md0      # result, or md1 etc
 # mount_cd9660 /dev/md0 /media
 % mount -p       # to check ...
```

or as a one-liner:


```
# mount_cd9660 /dev/$(mdconfig Freud.iso) /media
```


----------



## smithi (Dec 15, 2022)

siguri said:


> Now, that I  tried this and that  with the stuff you guys put here I still find <user> to be not permitted to do <code: ntfs-3g /dev/da0s1 /mnt/user>. And yes, /mnt/user is chown and yes, <user> is in group operator...?hm What do say to that, if I  may ask.



You need to show, not tell.  I can't tell what you mean by "with the stuff" or "is chown" or what commands you are issuing or what responses the OS gives.

Try cut n paste from real sessions, posted in \[code\] blocks, for practice; it will make it easier for others to help you. Cheers


----------



## smithi (Dec 15, 2022)

smithi said:


> or as a one-liner:
> 
> ```
> # mount_cd9660 /dev/$(mdconfig Freud.iso) /media
> ```



Sigh .. only correct under sh(1), e.g. in a script; under csh(1) only the backtick version works, and that works under either shell, so better:


```
# mount_cd9660 /dev/`mdconfig Freud.iso` /media
```


----------

