Search:  
Gentoo Wiki

HOWTO_GmailFS

Contents

What is GmailFS?

Gmail Filesystem provides a mountable Linux filesystem which uses your Gmail account as its storage medium. Gmail Filesystem is a Python application and uses the FUSE userland filesystem infrastructure to help provide the filesystem, and libgmail to communicate with Gmail.

GmailFS supports most file operations such as read, write, open, close, stat, symlink, link, unlink, truncate and rename. This means that you can use all your favourite unix command line tools to operate on files stored on Gmail (e.g. cp, ls, mv, rm, ln, grep etc. etc.).

Install

FUSE

First of all you need to install package FUSE - tools for manupulating filesystems implemented in userspace.

Code: Install FUSE
emerge --ask --verbose sys-fs/fuse
chmod 666 /dev/fuse

libgmail

The next thing you need is libgmail which also is in portage but needs to be unmasked:

Code: Install libgmail
echo "net-libs/libgmail ~arch" >> /etc/portage/package.keywords
emerge --ask --verbose net-libs/libgmail

GMailFS

Unfortunately gmailfs is not in portage yet but there is already an ebuild. You can get the latest gmailfs ebuild from the http://gentoo.zugaina.org/sys-fs.html.en#gmailfs, place it in overlay and build digest.

Code: Download the ebuild
mkdir -p /usr/local/portage/sys-fs/gmailfs/
cd /usr/local/portage/sys-fs/gmailfs/

Create a file in the current directory named gmailfs-0.8.0.ebuild with these contents:

File: /usr/local/portage/sys-fs/gmailfs/gmailfs-0.8.0.ebuild
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
# This ebuild come from http://bugs.gentoo.org/show_bug.cgi?id=63785 - The site http://gentoo.zugaina.org/ only host a copy.

inherit eutils

KEYWORDS="~x86 ~ppc ~sparc ~mips ~alpha ~arm ~hppa ~amd64 ~ia64"
DESCRIPTION="GmailFS provides a mountable Linux filesystem which uses your Gmail account as its storage medium."
HOMEPAGE="http://richard.jones.name/google-hacks/gmail-filesystem/gmail-filesystem.html"
SRC_URI="http://richard.jones.name/google-hacks/gmail-filesystem/${P}.tar.gz"
RESTRICT="nomirror"
LICENSE="GPL-2"
SLOT="0"
IUSE=""

RDEPEND=">=dev-lang/python-2.3
	>=dev-python/fuse-python-0.1
	>=sys-fs/fuse-1.3
	>=net-libs/libgmail-0.1.3.3
	dev-python/fuse-python"

src_unpack() {
	unpack ${A}
	cd ${WORKDIR}
}

src_install() {
	dobin ${WORKDIR}/${P}/gmailfs.py || die "Can't dobin"
	insinto /sbin
	doins ${WORKDIR}/${P}/mount.gmailfs || die "Can't write to /sbin"
	insinto /etc
	doins ${WORKDIR}/${P}/gmailfs.conf || die "Can't write to /etc"
	dodoc README* ChangeLog
}

pkg_postinst() {
	einfo "You should now be able to mount gmailfs."
	einfo "To mount from the command line, do:"
	einfo "mount -t gmailfs /usr/bin/gmailfs.py /path/of/mount/point -o username=gmailuser,password=gmailpass,fsname=zOlRRa"
	einfo "To use fstab, create an entry /etc/fstab that looks something like:"
	einfo "/usr/bin/gmailfs.py /path/of/mount/point gmailfs noauto,username=gmailuser,password=gmailpass,fsname=zOlRRa"
	einfo " "
	ewarn "Remember to choose a very creative, unguessable fsname, else someone"
	ewarn "could manipulate your filesystem. Also remember that gmailfs is a"
	ewarn "cruel hack. So don't expect things like good performance"
	einfo " "
	einfo "You actually need to use libgmail from CVS. So do this:"
	einfo "cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/libgmail login"
	einfo "cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/libgmail co libgmail"
	einfo "then copy constants.py and libgmail.py to your"
	einfo "/usr/lib/python-<ver>/site-packages directory"
	chmod a+x /sbin/mount.gmailfs
}

Then build the digest files: ebuild *ebuild digest. Now you are ready to emerge gmailfs:

Code: Emerge the ebuild
echo "sys-fs/gmailfs ~x86" >> /etc/portage/package.keywords
emerge --digest --ask --verbose sys-fs/gmailfs

EncFS (optional)

EncFS allows you to keep your data encrypted. You can use EncFS on top of GmailFS for file storage which encrypts the files "on the fly". You can use your GMail account for example as a highly secure, offsite backup storage.

Code: Install EncFS
emerge --ask --verbose sys-fs/encfs

OpenSSL

And it is also a good idea to encrypt your logon information using SSL

emerge -av dev-python/pyopenssl

Unfortunetly gmail ebuild does not support this feature yet.

Preparation

The first thing you need is to create a new GMail account, preferably with some sort of random name. Generate this from a shell by running the following command: cat /dev/urandom | strings -n 8 | head -1. This will give you an randomized 8 character string which also ensures that your new storage account will not be messed up with spam mails.

The second one is fsname. The fsname is the name of this GMail filesystem. It is important to choose a hard-to-guess name here - because if others can guess the fsname, they can corrupt your Gmail filesystem by injecting spurious messages into your Inbox.You can generate fsname with command:

dd bs=12 count=1 if=/dev/urandom 2> /dev/null | base64

You also could just take a random string, preferably of at least 10 characters.

Usage

You can mount your Gmail filesystem either via fstab or manually using the command line.

To use fstab, create an entry /etc/fstab that looks something like this one:

/usr/local/bin/gmailfs.py /path/of/mount/point gmailfs noauto,username=gmailuser,password=gmailpass,fsname=zOlRRa

The username and password fields speak for themselves. The fsname is the name of this Gmail filesystem. It is important to choose a hard-to-guess name here - because if others can guess the fsname, they can corrupt your GMail filesystem by injecting spurious messages into your inbox.

To mount from the command line being root, do:

mount -t gmailfs /usr/bin/gmailfs.py /mountpoint -o username=gmailuser,password=gmailpass,fsname=zOlRRa 

But it is also possible to use gmailfs without root privileges:

/sbin/mount.gmailfs /usr/bin/gmailfs.py ~/gmail/

Therefore you need to get a local copy of /etc/gmailfs.conf to your home directory ~/.gmailfs and set the username and password inside:

cp /etc/gmailfs.conf ~/.gmailfs
vi ~/.gmailfs

In order to keep your account information secret do as follows:

chmod 600 ~/.gmailfs

You can unmount the mount using:

fusermount -u ~/gmail/

To check out the available space, execute:

df -h ~/gmail

The encryption can be achieved with EncFS:

encfs ~/gmail ~/gmailenc -- -o nonempty

See also

Retrieved from "http://www.gentoo-wiki.info/GmailFS"

Last modified: Sat, 04 Oct 2008 13:49:00 +0000 Hits: 18,578