# Mount Amazon s3 bucket to directory



## heximal (Aug 24, 2011)

Hello.
I can't figure out, how to do the subject?
I suspect, the fusefs-s3fs port is required to be installed, but how to configure it? Where should i put my Access Key ID & Secret Access Key? Or may be there is some other solution?

Thanks in advance!


----------



## Anonymous (Aug 24, 2011)

Here come all the answers to your questions:

http://code.google.com/p/s3fs/wiki/FuseOverAmazon


----------



## heximal (Aug 25, 2011)

I've downloaded the latest version of this project and have tried to compile it. It's failed with the message:

```
configure: error: Package requirements (fuse >= 2.8.4 libcurl >= 7.0 libxml-2.0 >= 2.6 libcrypto >= 0.9) were not met:
```
As I understand, it requires fusefs-libs package of version 2.8.4 and higher. But for FreeBSD there exists only 2.7.4.

What should I do now? Will it help if I download earlier version of FuseOverAmazon that is compatible with current fusefs-libs?


----------



## Anonymous (Aug 26, 2011)

heximal said:
			
		

> What should I do now?



I recommend to do:

[CMD=""]cd /usr/ports/sysutils/fusefs-s3fs[/CMD]
[CMD=""]make install clean[/CMD]

Then use the description at http://code.google.com/p/s3fs/wiki/FuseOverAmazon for getting started on using the s3fs.


----------



## heximal (Aug 26, 2011)

I've installed fusefs-kmod.
It installed fuse.ko module and s3f3.
But now there appear another problem. In the output of kldstat command i see no fuse.ko.
I tried to load it manually with 
`# kldload fuse.ko`
but it generated an error "Operation not permitted".
I've added fuse_enable=YES to the rc.conf but still getting the error "Operation not permitted" when trying to load fuse module.


----------



## Anonymous (Aug 26, 2011)

heximal said:
			
		

> I've installed fusefs-kmod.
> It installed fuse.ko module and s3f3.
> But now there appear another problem. In the output of kldstat command i see no fuse.ko.
> I tried to load it manually with
> ...



My interpretation of what you are telling is, that you installed fusefs-s3fs/fusefs-kmod from the ports using the commands given in  my previous message. Is that correct? If NO, then please forget the following - and I am out of any more answers.

If YES, you should have seen the following two instructional messages right after building and installation of fusefs-kmod and fusefs-s3fs has been completed, respectively.

*Usage instructions for fusefs-kmod*

```
In order to automatically load the fuse module on startup, you need to:

 - Add fusefs_enable="YES" to your /etc/rc.conf.
 - Run "/usr/local/etc/rc.d/fusefs start" (for the first time).

Set "sysctl vfs.usermount=1" if you want to be able to mount fuse devices as
an ordinary user.

Now fuse filesystems (sysutils/fusefs-*) can be mounted at startup from
/etc/fstab with the "late" parameter. This requires a symlink in /usr/sbin
named "mount_<fstype>", which is not created by all the fusefs ports.

Note that the rc.d script will unmount all fuse filesystems when called with
"stop" (in reverse order in case of nested mounts), so it can unload the
kernel module.
```

First, you have to add *fusefs_enable="YES"* AND NOT *fuse_enable="YES"* in /etc/rc.conf.

Second, mount s3fs as root, or enable:
[CMD=""]sysctl vfs.usermount=1[/CMD].

Third, you do not manually load the kernel module, but Run for the first time:
[CMD=""]/usr/local/etc/rc.d/fusefs start[/CMD]


```
server:~ root# kldstat
Id Refs Address    Size     Name
 1   26 0xc0400000 c2b6b8   kernel
 2    1 0xc102c000 9970     aio.ko
 3    1 0xc1036000 c108     ahci.ko
 4    1 0xc6333000 139000   zfs.ko
 5    1 0xc646c000 3000     opensolaris.ko
 6    1 0xc6e77000 4000     ng_socket.ko
 7    2 0xc6e7b000 b000     netgraph.ko
 8    1 0xc6ef6000 4000     ng_mppc.ko
 9    1 0xc6efa000 2000     rc4.ko
10    1 0xd58ce000 e000     fuse.ko
```


*Usage instructions for fusefs-3sfs*

```
The usage of s3fs can be found at http://code.google.com/p/s3fs/wiki/FuseOverAmazon if you want to understand it.
```

See there.


----------



## heximal (Aug 26, 2011)

yes, i've install fusefs from ports.
now i've done all the process you've described.
and after all
`# sysctl vfs.usermount=1`
finishes with 

```
vfs.usermount: 0
sysctl: vfs.usermount: Operation not permitted
```
error
the same for 
`# /usr/local/etc/rc.d/fusefs start`
fusefs_enable="YES" is added to /etc/rc.conf
I have no idea anymore. So does not the Google ((


----------



## Anonymous (Aug 26, 2011)

heximal said:
			
		

> yes, i've install fusefs from ports.
> now i've done all the process you've described.
> and after all
> `# sysctl vfs.usermount=1`
> ...



Didn't you perform all the installations and commands as the superuser root, did you?

If you didn't do everything as root, then it is best to deinstall the fusefs ports and start over again after loging in as root.


----------



## heximal (Aug 27, 2011)

no, everything was done with the root credentials (logged in as root).
may it be connected with the fact that FreeBSD is running in virtual environment? I forgot to mention that I was trying to do all of this on VPS.


----------



## Anonymous (Aug 27, 2011)

heximal said:
			
		

> no, everything was done with the root credentials (logged in as root).
> may it be connected with the fact that FreeBSD is running in virtual environment? I forgot to mention that I was trying to do all of this on VPS.



If I login as the unprivileged user rolf, and then try to set vfs.usermount, then I get exactly the same error as you:


```
server:~ rolf$ sysctl vfs.usermount=1
vfs.usermount: 0
sysctl: vfs.usermount: Operation not permitted
```

And now the same as user root:

```
server:~ root# sysctl vfs.usermount=1
vfs.usermount: 0 -> 1
```

Somehow the privileges of your root user seems to be spoiled. Is your root user member of the operator group? Login as root and check this with the following command:
`id`

Then compare the output with mine:


```
server:~ root# id
uid=0(root) gid=0(wheel) groups=0(wheel),5(operator)
```


Can your root user execute other privileged commands? For example try this one (which would restart FreeBSD):
`shutdown -r now`


----------



## heximal (Aug 27, 2011)

thank you for your patience...
so, the output of id command is exactly the same with your one:
`# id`

```
uid=0(root) gid=0(wheel) groups=0(wheel),5(operator)
```
on the other hand, 
`# shutdown -r now`
Performs well - the system reboots


----------



## Anonymous (Aug 27, 2011)

heximal said:
			
		

> I forgot to mention that I was trying to do all of this on VPS.



The inability of root doing certain tasks, may well be related to the global settings of the virtual machine.

For example with OpenVZ you can set the capabilities of changing system settings within the VPS container by the way of vzctl.

That said, and beyond that, I cannot be of any further help.

Best regards

Rolf


----------



## heximal (Aug 28, 2011)

Damn, the technical support has confirmed my suspicions. The virtualization type I use does not support loading kernel modules.
What's the point? If amazon s3 is simple web storage and the operating system has access to the internet, it may easy bypass this restriction.
Is there some other solution?
Maybe some workaround?


----------



## heximal (Sep 4, 2011)

Finally I was tired to fight with my hosting provider since it was pointless and moved myself to other one who provided me FreeBSD server based on XEN virtualization.
After installing fusefs kernel module I've got s3fs working.


----------

