Like every other website on the planet, SmallNetBuilder uses cookies. Our cookies track login status, but we only allow admins to log in anyway, so those don't apply to you. Any other cookies you pick up during your visit come from advertisers, which we don't control.
If you continue to use the site, you agree to tolerate our use of cookies. Thank you!

NAS How To

{mospagebreak toctitle=Introduction, Debian install, Mount volume}

Introduction

Updated 11/23/2011: System prompts removed from commands to prevent line truncation.

Virtual Windows Time Capsule

Welcome back. In Part 1, we gave you a turnkey Linux-based virtual appliance to turn any Windows machine into a Time Machine backup target. We also started to provide the details on how to make your own appliance. We're going to finish that up this time.

Debian Installation

We assume that you have followed Part 1 and have installed VirtualBox and created your VM. Now start up your VM and after a couple of seconds you should see the Debian installation screen.

Debian Installation Screen
Debian Installation Screen

Despite being in the UK, I am going to be creating this for my American cousins since I figure this is the largest SNB audience. But if you reside elsewhere, you can make the appropriate selections on the installation screens.

  1. Installation Screen: Install
  2. Select a language: English
  3. Select your location: United States
  4. Select a keyboard layout: American English
  5. Hostname: MyTimeCapsule
  6. Domain name: blank
  7. Root Password: tmroot
  8. New user’s name: tmuser
  9. User name: tmuser
  10. User password: tmuser
  11. Timezone: Eastern
  12. Partition disks: Guided Use entire disk
  13. Select Disk: SCSI1 (should be 1.1 GB)
  14. Partitioning Scheme: All files in one partition
  15. Partition disks: Finish Partioning and write changes
  16. Write changes: Yes

Now the system should start to extract and install packages.

  1. Kernel to install: linux-image-3.0.0-1-486 (or whichever package you downloaded)
  2. Scan another CD or DVD: No
  3. Use a network mirror: Yes
  4. Debian Archive mirror country: United States
  5. Proxy: none
  6. Participate in usage Survey: yes
  7. Choose Software to Install: Select Standard system utilities, SSH Server
  8. Install Grub on partition
  9. Reboot!

Once the system reboots you should be presented with a login. We are going to log in as root because we are going to be a bit of initial administration. However, in general, you should not remain logged in as root.

You could just type the commands contained in this article into the VirtualBox window. However, it doesn’t supporting pasting to a terminal and there are some long commands. So even though we don’t really need it, we installed SSH.

Once you have rebooted and logged in as root, type in ifconfig to find your IP address. You are looking for inet addr:X.X.X.X where the Xs represent your IP address.

Once you have this use Putty to connect to it via SSH, logging in again as root.

I have shown the full prompt in the commands below. So be sure to omit root@MyTimeCapsule:~# in each command when copy and pasting

Mount the data volume

We need to partition, format and mount the 100 GB data volume we created earlier. Commands that you must type have been italicized and bolded. System prompts have been removed to prevent line truncation.

fdisk /dev/sdb
Command (m for help):  n
Command action
  e  extended
  p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-13054, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054):
Using default value 13054

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Now you need to format it.

mkfs.ext4 /dev/sdb1

Now you need to create a place for it to be mounted and then mount it. (Prompts have been removed to prevent command truncation.)

mkdir /mnt/MyTimeCapsuleData
chmod 777 /mnt/MyTimeCapsuleData/
echo /dev/sdb1 /mnt/MyTimeCapsuleData ext4 defaults 0 0 >> /etc/fstab
mount /mnt/MyTimeCapsuleData

If you receive no errors, your drive will now be mounted.


Avahi and Netatalk Installation

Avahi is the open source implementation of what Apple calls Bonjour. It means that your new DIY Time Capsule will be advertised on your network and your Mac will know about it. So it’s good to install.

For Leopard and Snow Leopard, we need Netatalk 2.0.5 or above. However, in order to maintain compatibility with Lion we need version 2.2 or above for full AFP 3.3 support.

Debian Stable currently has version 2.1.2, which isn’t enough. But Debian Testing has 2.2 which is what we are after. So while our entire installation comes from the Stable repositories, we need to pick up Netatalk from the Testing repositories.

 nano /etc/apt/sources.list

This will load the file up in a text editor called nano. Paste the following lines into the bottom

deb http:/ftp.us.debian.org/debian/ wheezy main
deb-src http:/ftp.us.debian.org/debian/ wheezy main

and comment out the line at the top that starts with deb cdrom, i.e. insert a ‘#’ symbol at the beginning of the line.

Save and exit by pressing control+o then control+x.

Set the default repository to use:

echo APT::Default-Release "squeeze"\; >> /etc/apt/apt.conf

Then update the list of the available packages

apt-get update

There are some dependencies and other packages that we must install first

apt-get install avahi-daemon libnss-mdns

Select the default option for any questions asked.

Now install Netatalk, specifying the Wheezy/testing repository.

apt-get install netatalk libc6-dev -t wheezy

This will install the testing version of netatalk and a load of required dependencies.

Netatalk Configuration

Now we need to tell Netatalk to share the volume we created and mounted earlier. Type the following at the command prompt. Make sure it is entered as one line.

echo /mnt/MyTimeCapsuleData MyTimeCapsule allow:tmuser cnidscheme:dbd options:tm >> /etc/netatalk/AppleVolumes.default

That’s it!

Avahi Configuration

Now we must configure Avahi so it knows which services it should advertise.

We need to edit a file now, so type in the following:

 nano /etc/nsswitch.conf

Use the cursor keys to navigate down to the line that looks like this:

hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 

and add ‘mdns’ at the end

Press control+o to save and then control+x to exit

Now we have to create the file that tells Avahi that our machine offers an AFP service (which happens to be a Time Capsule).

nano /etc/avahi/services/afpd.service

And then paste in the following


<?xml version="1.0" standalone='no'?><!--*-nxml-*-->

<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
  <service-group>
    <name replace-wildcards="yes">%h</name>
    <service>
      <type>_afpovertcp._tcp</type>
      <port>548</port>
    </service>
    <service>
      <type>_device-info._tcp</type>
      <port>0</port>
      <txt-record>model=TimeCapsule</txt-record>
    </service>
  </service-group>

Note how we specify the txt-record to be TimeCapsule, so that we get the correct icon.

Again press control+o and control+x.

Now restart Netatalk and Avahi.

/etc/init.d/netatalk restart
/etc/init.d/avahi-daemon restart

Now check that your DIY Time Capsule is working. With a little luck, if you go back to your MacOS X machine in your side bar you will see a network machine called MyTimeCapsule with a little Time Capsule icon.

If you go into Time Machine, you should now be able to select the virtual machine.

Cleanup

I’m going to do a bit of cleanup of this virtual machine to reduce the size for downloading. This will remove different languages, manual pages and packages that we won’t need.

This section is entirely optional. Type or copy/paste the following,

apt-get install localepurge deborphan debfoster
localepurge

This next one all goes on one line:

apt-get remove --purge manpages manpages-dev vim-common vim-tiny traceroute man-db gcc-4.3 cpp-4.3 info eject tasksel tasksel-data xfonts-base xserver-xorg nfs-common exim4 rpcbind debian-faq doc-debian doc-linux-text ftp

Then a few more lines:

deborphan | xargs apt-get -y remove --purge
rm -rf /usr/share/doc/
rm -rf /usr/share/doc-base/
rm -rf /usr/share/man/
rm -fr /var/lib/apt/lists/*

I also removed SSH (via the VirtualBox window) since we won’t need it anymore. Leaving it installed is a bit of a security risk, because I just know that some people won’t change the password!

apt-get remove openssh-server --purge
apt-get autoremove --purge; apt-get clean all

At this point my Debian installation is using 350 MB.

Now if we ‘zero out’ the free space on the disk, it will compact and compress better:

dd if=/dev/zero of=TEMP bs=1M; rm TEMP

Now we have finished creating the appliance, so shut it down with the command

shutdown --hP now

Once it has shut down, I am going to compact the virtual disks.

In the Windows command line on the host type in:

vboxmanage modifyhd MyTimeCapsule.vdi --compact
vboxmanage modifyhd MyTimeCapsuleData.vdi --compact

Create a Downloadable Appliance

Now make an appliance by selecting File: Export Appliance, which will result in a compressed .ova file that you can load into VirtualBox, as shown in Part 1.

It is interesting to note that the export actually creates .vmdk disks (the VMware format) instead of .vdi because the .ova format was created by VMware. However, it doesn’t really affect the outcome of this article.

I hope you enjoy your new Time Machine backup server.

Discuss this in the Forums