<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>patrik.cqure.net &#187; Howto</title>
	<atom:link href="http://patrik.cqure.net/wordpress/category/howto/feed/" rel="self" type="application/rss+xml" />
	<link>http://patrik.cqure.net/wordpress</link>
	<description>random thoughts about random things</description>
	<lastBuildDate>Fri, 27 Nov 2009 23:09:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
		<item>
		<title>Backing your NAS to Humyo</title>
		<link>http://patrik.cqure.net/wordpress/2009/09/27/backing-your-nas-to-humyo/</link>
		<comments>http://patrik.cqure.net/wordpress/2009/09/27/backing-your-nas-to-humyo/#comments</comments>
		<pubDate>Sun, 27 Sep 2009 08:50:28 +0000</pubDate>
		<dc:creator>patrik</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bubba]]></category>
		<category><![CDATA[davfs2]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[fuse]]></category>
		<category><![CDATA[humyo]]></category>
		<category><![CDATA[storage]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://patrik.cqure.net/wordpress/?p=211</guid>
		<description><![CDATA[I have written about my Bubba&#124;Two NAS before and I am still very happy with it. It&#8217;s not a performance beast but so quiet that it&#8217;s not noticeable in our living room which has always been the most important for me. Even though it runs RAID-1 and mirrors the 1TB internal disk to an external [...]]]></description>
			<content:encoded><![CDATA[<p>I have written about my <a href="https://www.excito.com/bubba/products/overview.html">Bubba|Two </a>NAS before and I am still very happy with it. It&#8217;s not a performance beast but so quiet that it&#8217;s not noticeable in our living room which has always been the most important for me. Even though it runs RAID-1 and mirrors the 1TB internal disk to an external eSata disk I wanted to add some additional security by moving some of the most important files off-site. This article will describe some of the challenges and my final solution. The setup can be used on any Debian or Ubuntu based distribution.</p>
<p><span id="more-211"></span><strong>Finding a storage service provider</strong></p>
<p>First off I needed to find someplace where I could upload my files. The most obvious choices were <a href="http://www.getdropbox.com/">Dropbox</a>, <a href="https://spideroak.com/">SpiderOak</a> or one of the alternatives found here: <a href="http://alternativeto.net/desktop/dropbox/">http://alternativeto.net/desktop/dropbox/</a>. Even though some of the clients were possible to setup without a GUI and provided Linux clients, they did so for the x86 or x86_64 architecture. The problem is that the Bubba|Two runs Debian on a PPC architecture which I couldn&#8217;t find any single client for. Needing a proprietary client was kind of annoying anyway so I started looking for alternative solutions such as backing up over Rsync, Scp, Ftp or WebDav. I finally found two providers allowing me to connect to my storage area using WebDav: <a href="http://humyo.com/">Humyo</a> and <a href="http://www.bingodisk.com/">BingoDisk</a>. During my, not that scientific tests, I had better luck with performance on Humyo and as they were the (minimally) cheaper alternative I opened a trial account there.</p>
<p><strong>Setting up the storage access</strong></p>
<p>In order to access the storage using webdav we need a webdav client. Preferably the client should allow for easy mirroring of an entire directory of files. The natural choice would be the webdav FUSE filesystem <a href="http://savannah.nongnu.org/projects/davfs2">davfs2</a>. FUSE stands for file system in user space and allows developers to implement file systems that can be accessed from userspace with FUSE rather than being implemented in the Linux kernel. There are today several great FUSE filesystems such as davfs2, sshfs, ftpfs, encfs and many many more. Once the file system is mounted it appears as any other file system. FUSE also allows for file system chaining so that encfs can run on top of eg. davfs2 to provide file encryption on top of a remote WebDav file system.</p>
<p>The davfs2 package exists in both Debian and in Ubuntu but unfortunately with old versions which I had some trouble getting to work with Humyo. The problem I was experiencing was that all uploaded files would be of zero size and empty. This was solved as soon as I installed a more current version (1.4.1). As the upcoming Ubuntu Karmic release ships with this version I used the package source to build a new package for my Bubba|Two which worked out great. This is what I did:</p>
<p><em>Preparing the build environment</em></p>
<p>First off I needed a compiler and build environment to build from source, I installed it by issuing the following command:</p>
<pre lang="bash">sudo apt-get install build-essential make gcc</pre>
<p>Then the davfs2 package requires libneon to build. In order to install this I did:</p>
<pre lang="bash">sudo apt-get install libneo26-gnutls-dev</pre>
<p><em>Downloading the source code</em></p>
<p>Once these prerequisites were in place I downloaded the source code, decompressed it and patched it using the following:</p>
<pre lang="bash">mkdir $HOME/src
cd $HOME/src
wget http://archive.ubuntu.com/ubuntu/pool/universe/d/davfs2/davfs2_1.4.1.orig.tar.gz
wget http://archive.ubuntu.com/ubuntu/pool/universe/d/davfs2/davfs2_1.4.1-1.diff.gz
tar xvzf davfs2_1.4.1.orig.tar.gz
zcat davfs2_1.4.1-1.diff.gz | patch -p0</pre>
<p><em>Building the package from source</em></p>
<p>Now we can start to build the package by issuing:</p>
<pre lang="bash">cd $HOME/src/davfs2-1.4.1
chmod +x debian/rules
sudo debian/rules binary</pre>
<p>This should give us a complete deb package in the parent directory ($HOME/src). The name of this package depends on the architecture which it was built for, in my case the name was: davfs2_1.4.1-1_powerpc.deb</p>
<p><em>Installing the package</em></p>
<p>The package can be installed by issuing the following command:</p>
<pre lang="bash">sudo dpkg -i $HOME/src davfs2_1.4.1-1_powerpc.deb</pre>
<p><strong>Setting up davfs2 to access Humyo</strong></p>
<p>With the davfs2 package installed we now have to do some minor changes to a couple of files in order to mount the file system without the need for root access and prompting for credentials. Also as Humyo doesn&#8217;t seem to support file locking, we need to disable this to in order to avoid a warning each time we mount a file system.</p>
<p><em>Adding your Humyo username and password to davfs2</em></p>
<p>In order to add our credentials to davfs2 we need to add the following file to the /etc/davfs2/secrets file:</p>
<p>https://dav.humyo.com    <username>    &#8221;
<password>&#8221;</p>
<p>So if your username is foo@bar.com and your password is foobar the line should look like this:</p>
<p>https://dav.humyo.com    foo@bar.com    &#8221;foobar&#8221;</p>
<p>Don&#8217;t forget that the server should be accessed over SSL, hence the https://dav.humyo.com</p>
<p><em>Disabling file locking</em></p>
<p>As Humyo doesn&#8217;t support file locking we need to disable this in order to remove the annoying warning each time a file system is mounted. This can be done either on a per-system, per-user level or in a custom configuration file. As I&#8217;m not running any other WebDav file system on the server I changed this in the global /etc/davfs2/davfs2.conf file. Consult the mount.davfs manual page (man mount.davfs) for information how this can be changed on a per-user or in a custom configuration file. To change it on a per-system level set the use_locks option to 0 (zero) in the /etc/davfs2/davfs2.conf file.</p>
<p><strong>Importing the SSL certificate</strong></p>
<p>We&#8217;re now almost all set to mount the remote WebDav file system. However, if you try to mount the file system now, you would most likely get the following message:</p>
<blockquote><p>/sbin/mount.davfs: the server certificate is not trusted<br />
issuer:      US, New Jersey, Jersey City, OptimumSSL CA, OptimumSSL CA<br />
subject:     OptimumSSL Wildcard, Domain Control Validated, OptimumSSL Wildcard, Domain Control Validated, *.humyo.com<br />
identity:    *.humyo.com<br />
fingerprint: bf:28:74:8e:63:96:bf:07:9d:99:ed:f7:bf:44:cc:ad:f8:7b:c6:a7<br />
You only should accept this certificate, if you can<br />
verify the fingerprint! The server might be faked<br />
or there might be a man-in-the-middle-attack.<br />
Accept certificate for this session? [y,N]</p></blockquote>
<p>The error occurs due to OpenSSL not being able to verify the SSL certificate chain. In order to get rid of this message we need to provide davfs2 with the root certificate. We do this by issuing the following command:</p>
<pre lang="bash">wget -O - "https://support.comodo.com/index.php?_m=downloads&#038;_a=downloadfile&#038;downloaditemid=10" | \
sudo tee /etc/davfs2/certs/addtrust_ab.pem</pre>
<p>Then we need to instruct davfs2 to read this pem file when mounting our file system by adding the following line to /etc/davfs2/davfs2.conf:</p>
<p>servercert /etc/davfs2/certs/addtrust_ab.pem</p>
<p>So, now we should be all set!</p>
<p><strong>Creating a mount point and adding it to fstab</strong></p>
<p>We&#8217;re now ready to create a mount point. I chose to mount my Humyo storage to /mnt/humyo. In order to be able to do this I created the directory by issuing:</p>
<pre lang="bash">sudo mkdir /mnt/humyo</pre>
<p>Once we have the mount point in place we can try to mount our file system by issuing the following command:</p>
<pre lang="bash">sudo mount -t davfs https://dav.humyo.com /mnt/humyo/</pre>
<p>If all went well we should not have gotten any error messages and we can test whether it works by copying any file to /mnt/humyo. You can check whether the file actually made it to Humyo by checking their web interface. If it works your good to go, if not well, you need to start checking what went wrong.</p>
<p><strong>Adding the mount point to fstab</strong></p>
<p>The current setup only allows root to mount the file system and requires you to issue the above command to do so. In order to allow users to mount the file system you need to add a line into /etc/fstab.</p>
<p>https://dav.humyo.com    /mnt/humyo    davfs    user,noauto,rw    0    0</p>
<p>If you want the file system to be mounted at boot change the <em>noauto</em> to <em>auto</em> instead.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpatrik.cqure.net%2Fwordpress%2F2009%2F09%2F27%2Fbacking-your-nas-to-humyo%2F&amp;title=Backing%20your%20NAS%20to%20Humyo"><img src="http://patrik.cqure.net/wordpress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://patrik.cqure.net/wordpress/2009/09/27/backing-your-nas-to-humyo/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Samba directories keep getting 755 permissions</title>
		<link>http://patrik.cqure.net/wordpress/2009/09/11/samba-directories-keep-getting-755-permissions/</link>
		<comments>http://patrik.cqure.net/wordpress/2009/09/11/samba-directories-keep-getting-755-permissions/#comments</comments>
		<pubDate>Fri, 11 Sep 2009 21:45:30 +0000</pubDate>
		<dc:creator>patrik</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[ACL]]></category>
		<category><![CDATA[Directories]]></category>
		<category><![CDATA[Fail]]></category>
		<category><![CDATA[Incorrect]]></category>
		<category><![CDATA[leopard]]></category>
		<category><![CDATA[MAC]]></category>
		<category><![CDATA[OS X]]></category>
		<category><![CDATA[Permissions]]></category>
		<category><![CDATA[Samba]]></category>
		<category><![CDATA[Snow Leopard]]></category>

		<guid isPermaLink="false">http://patrik.cqure.net/wordpress/?p=126</guid>
		<description><![CDATA[I just came across a really strange and *annoying* problem on one of our servers. A while ago I swapped my PC for a Macbook. Up until now I hadn&#8217;t noticed that all my files created on our common Samba server could not be modified by others. Once a colleague pointed this out I started [...]]]></description>
			<content:encoded><![CDATA[<p>I just came across a really strange and *annoying* problem on one of our servers. A while ago I swapped my PC for a Macbook. Up until now I hadn&#8217;t noticed that all my files created on our common Samba server could not be modified by others. Once a colleague pointed this out I started investigating the smb.conf file to figure out what was happening.</p>
<p>However, in the configuration file all looked fine and dandy: <strong>create mode</strong>, <strong>directory mode</strong> and <strong>inherit permissions</strong> were all still set. To make really sure I added some of the force options as well. Still, all folders were created with 0755 (drwxr-xr-x) permissions (I had it setup and expected 0750). I thought I was going nuts until I found some other articles outlining the exact same problems and pointing their finger at Mac OS X.</p>
<p><a href="http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg657971.html">http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg657971.html</a><br />
<a href="http://lists.samba.org/archive/samba/2009-June/148518.html">http://lists.samba.org/archive/samba/2009-June/148518.html</a></p>
<p>Apparently the servers incorrect setting of ACLs on the directories was due to the umask value on Mac OS X. Going through the article, I found that the following suggested settings fixed the problem for me.</p>
<p><strong>unix extensions = no<br />
force directory security mode = 0770</strong></p>
<p>Once setting unix extensions to <strong>no</strong>, I had to disconnect and re-connect to the server in order to access my files and from then all directories were created with the correct permissions.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpatrik.cqure.net%2Fwordpress%2F2009%2F09%2F11%2Fsamba-directories-keep-getting-755-permissions%2F&amp;title=Samba%20directories%20keep%20getting%20755%20permissions"><img src="http://patrik.cqure.net/wordpress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://patrik.cqure.net/wordpress/2009/09/11/samba-directories-keep-getting-755-permissions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>bubba two and raid-1</title>
		<link>http://patrik.cqure.net/wordpress/2009/01/21/bubba-two-and-raid-one/</link>
		<comments>http://patrik.cqure.net/wordpress/2009/01/21/bubba-two-and-raid-one/#comments</comments>
		<pubDate>Wed, 21 Jan 2009 20:25:23 +0000</pubDate>
		<dc:creator>patrik</dc:creator>
				<category><![CDATA[Howto]]></category>
		<category><![CDATA[bubba server]]></category>
		<category><![CDATA[bubba two]]></category>
		<category><![CDATA[eSata]]></category>
		<category><![CDATA[Excito]]></category>
		<category><![CDATA[raid]]></category>
		<category><![CDATA[raid-1]]></category>

		<guid isPermaLink="false">http://patrik.cqure.net/wordpress/?p=97</guid>
		<description><![CDATA[I recieved my bubba two storage solution from Excito today! I must say that I was both surprised and impressed once I unwrapped and pluged it in to my network. It was both smaller and quiter than I expected! I also purchased an additional 1TB eSata drive, also from Excito, which looks almost the same [...]]]></description>
			<content:encoded><![CDATA[<p>I recieved my bubba two storage solution from Excito today! I must say that I was both surprised and impressed once I unwrapped and pluged it in to my network. It was both smaller and quiter than I expected!</p>
<p>I also purchased an additional 1TB eSata drive, also from Excito, which looks almost the same as the server. Knowing from their specs that the device did not yet support raid-1 I was nevertheless hoping to get this running with the additional disk I bought. So far I have synced 39.2% of the new raid array I created and things are looking very promising. For anyone intrested, these are the steps I took:</p>
<p><span id="more-97"></span></p>
<p>First of all I setup a new account through which I could access the server through SSH. I then connected to the system over SSH to look at the partition table. Fortunately the layout was quite good and required only little work to adapt it for mirroring. The bubba two server I bought came with a 1TB disk partitioned like this:</p>
<p>/dev/sda1          0+   1216    1217-   9775521   83  Linux<br />
/dev/sda2       1217  121456  120240  965827800   8E  Linux LVM<br />
/dev/sda3     121457  121600     144    1156680   82  Linux swap / Solaris</p>
<p>My concern was to mirror the &#8220;storage&#8221; partition (sda2) where I will be keeping my data. This partition was currently mounted as /home which was in use as it contained my home directory. So in order to start building the RAID array I had to do some small preparations. All of the commands should be executed as root.</p>
<p>To be able to unmount the partition I first created a new &#8220;home&#8221; directory</p>
<pre lang="bash">mkdir /home2</pre>
<p>I then copied all of the contents from /home to /home2</p>
<pre lang="bash">cp -a /home/* /home2/</pre>
<p>With the home contents in the new directory I opened the passwd file and changed my home-directory from home to home2</p>
<pre lang="bash"> nano -w /etc/passwd</pre>
<p>In order to minimize the chance of screw-up I opened a new terminal window after saving the passwd file to verify that I could still SSH to the box. Once this was done I unmounted the old /home partition, which should no longer be busy.</p>
<pre lang="bash">umount /home</pre>
<p>Now we&#8217;re ready to start removing volume-groups, logical volumes and other disk mappings I did this by executing the following commands:</p>
<pre lang="bash">lvremove bubba/storage
vgremove bubba
pvremove /dev/sda2</pre>
<p>Once this was done I needed to change the partition type for the second partition from LVM to RAID. I did this by starting cfdisk, selecting the second partition and then chose types. The type needs to be changed from 8E to FD. After this I simply copied the partition table from /dev/sda to /dev/sdb using sfdisk using:</p>
<pre lang="bash">sfdisk -d /dev/sda | sfdisk /dev/sdb</pre>
<p>With the partitions in place I created the raid-1 mirror array by issuing:</p>
<pre lang="bash">mdadm --create /dev/md0 --level=raid1 --raid-devices=2 /dev/sda2 /dev/sdb2</pre>
<p>In order to minimize the changes needed in the bubba configuration I simply created the same volume group and logical volume as before.</p>
<pre lang="bash">pvcreate /dev/md0
vgcreate bubba /dev/md0</pre>
<p>In order to determine the size of the logical volume group I did</p>
<pre lang="bash">vgdisplay | grep 'Total PE'</pre>
<p>In my case this value was 235797, so this gives us:</p>
<pre lang="bash">lvcreate -l 235797 -n storage bubba</pre>
<p>I then created an ext3 file system by issuing the following command:</p>
<pre lang="bash">mkfs.ext3 /dev/mapper/bubba-storage</pre>
<p>When this finnished, I was ready to mount the home partition back, but this time as a raid-1 mirror:</p>
<pre lang="bash">mount /home</pre>
<p>Now I copied all file from /home2 back to /home</p>
<pre lang="bash">cp -a /home2/* /home/</pre>
<p>I started nano again to edit /etc/passwd to change home2 back to home</p>
<pre lang="bash">nano -w /etc/passwd</pre>
<p>Again, tried to ssh from a new terminal window in order to verify that it worked. Once I verified that it did, I issued a reboot just to see that it was all working. Which it did once the server was back on line. To check the state of the re-sync of the array I issued the following command:</p>
<pre lang="bash">cat /proc/mdstat</pre>
<p>Now, it&#8217;s at 58.6% and will hopefully finish soon&#8230;.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fpatrik.cqure.net%2Fwordpress%2F2009%2F01%2F21%2Fbubba-two-and-raid-one%2F&amp;title=bubba%20two%20and%20raid-1"><img src="http://patrik.cqure.net/wordpress/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://patrik.cqure.net/wordpress/2009/01/21/bubba-two-and-raid-one/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

