{"id":12,"date":"2012-01-14T08:12:00","date_gmt":"2012-01-14T08:12:00","guid":{"rendered":"http:\/\/blog.maclawran.ca\/s3-compatible-storage-as-a-linux-filesystem"},"modified":"2012-01-14T08:12:00","modified_gmt":"2012-01-14T08:12:00","slug":"s3-compatible-storage-as-a-linux-filesystem","status":"publish","type":"post","link":"https:\/\/blog.maclawran.ca\/?p=12","title":{"rendered":"cloud storage as a linux filesystem"},"content":{"rendered":"<p><strong>[Updated 22 feb 2012 &#8211; updated and clarified process]<\/strong><\/p>\n<p>I need space.&nbsp; Lots of space.&nbsp; Like an amazon S3 amount of space,  spread out over a pile of little linux machines running Ubuntu.<\/p>\n<p>My cloud is made up of many cheap VPS providers, some costing as  little as $7 a month; for that you get some CPU, a little disk and some  bandwidth&#8230; the idea being to allow for total node failures and be able  to move machines quickly and pretty painlessly.<\/p>\n<p>Persistent disk would allow me to drop and replace nodes really quickly, essentially I&#8217;d only be using CPU.<\/p>\n<p>Amazon is expensive for disk.&nbsp; So expensive I can&#8217;t stand it.&nbsp; Amazon  will charge me $150 a month to store 1 TB, or $1800 a year.&nbsp; I can buy a  1 TB disk for $99&#8230; for life.&nbsp; Then I get to pay for bandwidth,  something like $0.15 per gb again.&nbsp; Then to add insult to injury they  charge me for almost every transaction (GET\/PUT\/etc)&#8230; only DELETE&#8217;s  are free.&nbsp; It adds up fast.<\/p>\n<p>Along comes Connectria&#8230; $15 a month gets me 100gb  <a href=\"https:\/\/www.mh.connectria.com\/rp\/order\/cloud_storage_index\">https:\/\/www.mh.connectria.com\/rp\/order\/cloud_storage_index<\/a> of S3  compatible storage, which includes the first 100gb of transfer.&nbsp; Good  news is it&#8217;s cheaper than Amazon, transfer is after the first  100gb$0.09\/gb and transactions are free.&nbsp;&nbsp; You can set up unlimited  users, and each user can have up to 100 buckets, and no speed limits.&nbsp;  In my testing they were much, much faster than Amazon, so much so that  the speed itself caused it&#8217;s own set of strange problems.<\/p>\n<p>If you&#8217;re going to mount a disk like this, there may or may not be a  lot of disk usage, but you are likely to have a lot of transactions!&nbsp;  Using Amazon would be death here.<\/p>\n<p>So now I want to use this S3 storage on my linux box.<\/p>\n<p>1. Sign up for Connectria &#8211; <a href=\"https:\/\/www.mh.connectria.com\/rp\/order\/cloud_storage_customer\">https:\/\/www.mh.connectria.com\/rp\/order\/cloud_storage_customer<\/a><\/p>\n<p>2. Get s3cmd: <a href=\"http:\/\/s3tools.org\/s3cmd\">http:\/\/s3tools.org\/s3cmd<\/a><\/p>\n<p>3. <code>s3cmd --configure put the keys from Connectria in there.<\/code><\/p>\n<p>Edit ~\/.s3cfg &#8211; change the following 2 lines from referencing amazon to connectria:<\/p>\n<p>host_base = rs2.connectria.com<br \/>host_bucket = %(bucket)s.rs2.connectria.com<\/p>\n<p>4.<code> Make a bucket:&nbsp; s3cmd mb s3:\/\/testbucket<br \/><\/code><\/p>\n<p>5. s3cmd ls &#8211; you should see <code>testbucket<\/code><\/p>\n<p>Cool.&nbsp; You&#8217;re in.&nbsp; Now we get funky.&nbsp; You want to mount this bucket as a filesystem under linux.&nbsp;<\/p>\n<p>For this we&#8217;re going to need a really nice bit of software called  s3backer: <a href=\"http:\/\/code.google.com\/p\/s3backer\/\">http:\/\/code.google.com\/p\/s3backer\/<\/a> which creates a FUSE-based  filesystem.&nbsp; There are other programs that do this, including s3ql, but  in live testing they created a horrible load on the system.&nbsp; In addition  during my &#8220;hammer the disk and reboot the system&#8221; tests the results  were ugly, ugly, ugly.<\/p>\n<p>Archie, the author, does a nice job of explaining how to install and  test here: <a href=\"http:\/\/code.google.com\/p\/s3backer\/wiki\/RunningTheDemo\">http:\/\/code.google.com\/p\/s3backer\/wiki\/RunningTheDemo<\/a><\/p>\n<p>I&#8217;m going to assume you&#8217;ve gotten it running from that.&nbsp;<\/p>\n<p>Next  step is actually choosing a filesystem type to create.&nbsp; Again, in this  case, the newest isn&#8217;t necessarily the best.&nbsp; I tested a number of  filesystems, ext2, ext3, ext4, XFS, and ReiserFS.&nbsp; Because we were going  to have a large number of small files (like 1K), ReiserFS worked best  architecturally and passed all my tests as well.<\/p>\n<p>Note: ReiserFS is technically great, it&#8217;s author is in jail for  killing his wife which kinda put a kink in the development efforts:  <a href=\"http:\/\/en.wikipedia.org\/wiki\/ReiserFS\">http:\/\/en.wikipedia.org\/wiki\/ReiserFS<\/a><\/p>\n<p>Make the directories we&#8217;re going to need, somewhere to mount it, a  cache directory and the loop directory for the FUSE filesystem.<\/p>\n<p>mkdir \/mnt\/s3<\/p>\n<p>mkdir \/bbs3<\/p>\n<p>mkdir \/bbs3\/cache<br \/>mkdir \/bbs3\/testbucket<\/p>\n<p>Run s3backer&#8230;. assuming the password for Connectria lives in \/root\/.s3backer_passwd<\/p>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s3backer &#8211;accessFile=\/root\/.s3backer_passwd  &#8211;filename=testbucket  &#8211;minWriteDelay=1800&#8211;blockCacheFile=\/bbs3\/cache\/testbucket  &#8211;blockCacheThreads=8 &#8211;baseURL=https:\/\/rs2.connectria.com\/  &#8211;blockSize=4k &#8211;size=1g &#8211;listBlocks testbucket\/bbs3&nbsp; \/testbucket<\/p>\n<p>There are a couple of funky parameters here, size=1g makes a 1 gb  filesystem which you can extend later, minWriteDelay=1800 makes s3backer  wait 1.8 seconds before re-writing a block that it just wrote &#8211; this  gives Connectria a bit of time to get the block actually written and was  the only wierdness I encountered.&nbsp; Using a blocksize of 4k is natural  since the filesystem&#8217;s blocksize is 4k and those are the blocks we&#8217;ll be  writing.<\/p>\n<p>Next we make our reiserFS and mount it.&nbsp; Only wierdness here is the  &#8216;noatime&#8217; flag that helps reduce the number of blocks written to the  filesystem.<\/p>\n<p>If you&#8217;re on Ubuntu &#8211; the programs needed to use reiserfs can be installed with:<br \/>apt-get install reiserfsprogs<\/p>\n<p>mkreiserfs -ff -b 4096 -s 513 \/bbs3\/testbucket\/testbucket<br \/>mount -o loop,noatime&nbsp; \/bbs3\/testbucket\/testbucket \/mnt\/s3<\/p>\n<p>If all goes well, you now have a 1 gb filesystem sitting out there in  the cloud&#8230; At this point there are about 30 filesystems running  simultaneously on 8 different machines, and they&#8217;re working great.<\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">[Updated 22 feb 2012 &#8211; updated and clarified process] I need space. Lots of space. Like an amazon S3 amount of space, spread out over a pile of little linux machines running Ubuntu. My cloud is made up of many cheap VPS providers, some costing as &#8230;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/blog.maclawran.ca\/?p=12\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[16],"class_list":["post-12","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-linuxcloudstorages3amazonreiserfss3backer"],"_links":{"self":[{"href":"https:\/\/blog.maclawran.ca\/index.php?rest_route=\/wp\/v2\/posts\/12","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.maclawran.ca\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.maclawran.ca\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.maclawran.ca\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.maclawran.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12"}],"version-history":[{"count":0,"href":"https:\/\/blog.maclawran.ca\/index.php?rest_route=\/wp\/v2\/posts\/12\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.maclawran.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.maclawran.ca\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.maclawran.ca\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}