Giter VIP home page Giter VIP logo

gbd's Introduction

GBD

This is a python program that can use your google drive's space to create a virtual block device. Unlike gdrive or other projects, it doesn't provide a google-drive-integrated file system. Instead, it's just a block device that you may format into any format you like.

GBD is not yet stable and may cause issues (freezing your X window, etc), I'll be glad if you can send me a bug report (with debug output, plz) or even a patch.

Structure

GBD is splitted into back-end and front-end. The back-end is the part that manipulates your google drive and the front-end is the part that warps back-end into a block device.

Back-end

  • gbd.py is the core of GBD, it is capable of communicating with google drive and exports a block-based I/O interface.
  • cached_gbd.py is build upon gbd.py. It provides cache and a friendly (compares to gbd.py) I/O interface.

Front-end

  • nbd.py is the only front-end right now. It warps cached_gbd.py into a nbd server and you may connect it to a nbd device via nbd-client.

How to

Run nbd.py to launch the nbd server. Since GBD utilize OAuth, it will ask you to visit a link to get the code. You may just follow the instruction.

$ ./nbd.py

After the server starts, you'll use nbd-client to connect to our server. Remember to replace $WHATEVER_NAME_YOU_LIKE into whatever name your like.

$ sudo modprobe nbd
$ sudo nbd-client $WHATEVER_NAME_YOU_LIKE localhost 10809 /dev/nbd0

If this is the first time, nbd.py will ask you to enter desired block size / total size / cache size. You may use 64K/1G/128M if you're just trying it.

Your block device should be ready now, let's try to do something.

$ sudo mke2fs /dev/nbd0
$ sudo mount /dev/nbd0 /mnt
$ ls /mnt

If you want to disconnect the deivce from our server, you can use nbd-client again. However, remember to umount before disconnect, or something bad may happen.

$ sudo umount /dev/nbd0
$ sudo nbd-client -d /dev/nbd0

Yeah, have a good time!

Encryption

Since almost all your data will pass through the internet, it will be dangerous to store sensitive data on gbd. You could either store those files in an encrypted form or on your local disk. However, if your disk is too small to save all your files, it may be a good idea to encrypt to whole gbd transparently.

Under linux, you may use dm-crypt to do full disk encryption. As gbd is acting just like a block device, it can be encrypted, too.

sudo cryptsetup luksFormat /dev/nbd0
sudo cryptsetup luksOpen /dev/nbd0 gbd

After doing this, dm-crypt will map /dev/nbd0 to /dev/mapper/gbd. You may format/mount/umount it just like a normal block device except those data will be encrypted/decrypted after/before used.

Note that you must close dm-crypt before disconnect (and after umount) from our nbd server. Encrypted data will be much more harder to reccover, hence you may lost your data permanently if you forget to close dm-crypt first.

The whole closing process may looks like this:

sudo umount /dev/mapper/gbd
sudo dmsetup remove gbd
sudo nbd-client -d /dev/nbd0

Good luck!

Bugs

  • May freeze your X window
  • Broken pipe while syncing data

gbd's People

Contributors

coquelicot avatar

Stargazers

Cathal McCarthy avatar  avatar Saulius Krasuckas avatar  avatar  avatar  avatar Luis Garnica Guilarte avatar Nicola Sacchi avatar Key Zhang avatar Wangchong Zhou avatar hydai avatar zswu avatar shuhung avatar  avatar  avatar Chaowen Chang avatar

Watchers

James Cloos avatar  avatar  avatar Luis Garnica Guilarte avatar John White avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.