Raspberry Pi Private Cloud (NAS), Time Machine OSX (Yosemite)

Raspberry Pi Private Cloud (NAS), Time Machine OSX (Yosemite)

The intention is to create a private cloud at home (Within the range of your router). The cloud hosts the TIme Machine and generic storage area for photos and documents. The generic storage should be read/write compatible to Linux and OSX.

The following are required:

Raspberry Pi (Model B) ( Running Raspbian Wheezy, connected to the network, with keyboard and monitor). The procedure to get your PI running is available here.

  1. External hard disk with power supply. (I have : Verbatim 1 TB)IMG_2617

I have two laptops one is a MacBook Pro ( running OSX Yosemite ) and the other is a Toshiba (running Fedora 20).

Procedure on the Mac : Connect the external hard disk to the MacBook Pro. I have made two partitions of size 333 GB (partition name : timemachine )and 666 GB (partition name : cloud) on my external Hard Drive. The partitioning is done using the “Disk Utility” application (OSX). The file system type chosen is “Mac OS extended (journaled)” (HFS+) for both the partitions.

Run the below command on the terminal to make the OSX recognize non AFP volumes.

defaults write com.apple.systempreferences TMShowUnsupportedNetworkVolumes 1

Procedure on the Pi :
Now connect the External Hard Drive to the Pi.
Install the hfs+ driver.

sudo apt-get install hfsprogs

Create two directories and mount the drives. In my case sda1 was created for Time Machine and sda2 for the generic storage. To find out device names of the external hard drive run the command “lsblk”.

sudo mkdir /home/timemachine
sudo chmod 777 /home/timemachine
sudo mkdir /home/cloud
sudo chomd 777 /home/cloud
sudo mount -t hfsplus -o remount,force,rw /dev/sda1 /home/timemachine
sudo mount -t hfsplus -o remount,force,rw /dev/sda2 /home/cloud

Update the fstab so that the mount happens automatically during boot.

sudo echo "/dev/sda1       /home/timemachine hfsplus  force,rw  0  0" >> /etc/fstab
sudo echo "/dev/sda2       /home/cloud   hfsplus    force,rw 0  0" >> /etc/fstab

Create a user (For egs: cloud), a group (For egs : mycloud) and choose a password (and remember them!!!).

sudo useradd cloud
sudo groupadd mycloud
sudo useradd -gmycloud cloud
sudo passwd cloud
sudo chown cloud /home/timemachine
sudo chown cloud /home/mycloud

Install samba and netalink:

sudo apt-get install samba samba-common-bin
sudo apt-get install netatalk

Configure samba client:

sudo nano /etc/samba/smb.conf

Add the below text at the end of the file. “valid users” should have the name of the group you created:

[cloud]
  comment = Cloud
  path = /home/cloud
  valid users = @mycloud
  read only = no

Configure the netatalk.

sudo nano /etc/afp.conf

Add the below text to afp.conf:

[Global]
 mimic model = TimeCapsule6,106
 log level = default:warn
 log file = /var/log/afpd.log

[TimeMachine]
 path = /home/timemachine/
 valid users = cloud
 time machine = yes
sudo echo "/home/timemachine \"Time Machine\" options:tm" >> /etc/netatalk/AppleVolumes.default

restart samba and netatalk and make it start at boot.

sudo service netatalk restart
sudo /etc/init.d/samba restart
sudo update-rc.d netatalk defaults

Now our private cloud is ready.

To access the private cloud from MacBook Pro:
To access the “general storage” disk on our private cloud open the Finder and select “connect to server”.
Screen Shot 2014-11-05 at 21.20.10
Next type in the IP address of the Raspberry Pi (The ifconfig command on the Pi should display the IP address). Do not forget the prefix “smb://” before the IP address. Type in the user name and the password that was created previously.

Screen Shot 2014-11-05 at 21.21.21

For time machine :
To access the “Time Machine” disk on our private cloud open the Finder and select “connect to server”.
Screen Shot 2014-11-05 at 21.20.10
Next type in the IP address of the Raspberry Pi (The ifconfig command on the Pi should display the IP address). Do not forget the prefix “afp://” before the IP address. Type in the user name and the password that was created previously.

Screen Shot 2014-11-06 at 21.35.22
Open Time Machine and press “select disk”. The Time Machine created on our private cloud should be visible. Now you can backup your Mac to this Time Machine Disk on the cloud. It should start creating a sparse bundle. The first backup takes a long time (more than a day) but the next ones will be faster.

Access the private cloud from Fedora :

Open  “Files” window and click on “connect to server”.

Screenshot from 2014-11-07 08:47:44

Put in the Raspberry Pi IP address followed by “smb://”. Type in the user name and the password that was created previously.

Mountain Lion OSX : Features

Mountain Lion OSX : Features

In this post I mention some of the features that I really like in the Mountain Lion OSX. I use a MacBook Pro from early 2011.Hence most of the stuff I mention here are trackpad relevant.

For the ones who are used to other operating systems there is a tendency to use the OSX as windows or Linux or any other OS.The below mentioned features make you use the OSX as a OSX.Some features are existing in the previous versions of OSX and some are new in the Mountain Lion OSX. The list is not exhaustive , I will keep adding new stuff regularly.

Launchpad :

Pinch the trackpad with the thumb and the other 3 fingers.The Launchpad comes up.Here you will find all the programs. You can do a two finger swipe to move between different pages of the Launchpad.

Mission Control:

You can have a birds-eye view of all the open windows by doing a 3 finger swipe upwards. If the three finger swipe does not work then check for the “System Preferences -> Trackpad -> More Gestures -> Mission Control”. The mission control can also be accessed using the key F3.

Scrolling:

The Mountain Lion OSX is as close as it gets to an IPhone experience on a Mac. And with every new version of OSX the gap will be smaller than the previous.So if you had used a previous version of the OSX the default scroll direction in the Mountain Lion OSX will not be natural. But if you have been a Iphone user then the default scroll direction would feel natural. Anyways you can change the scroll direction by going to “System Preferences -> Trackpad -> Scroll & Zoom -> Scroll Direction: Natural”. Unchecking this box will make you go back to the scroll direction of the previous OSXs.

Fullscreen for programs:

Its always pleasant to have the program content on the full screen rather than share space with the tool bar,address bar,Menu Bar. To make a full screen click on the opposite pointing arrows at the top right corner of the program window.To exit the full screen move the mouse pointer to the top of the screen and click on the inward pointing arrows.If you have multiple fullscreen programs open then you can browse through them by doing a three finger swipe on the trackpad.If the three finger swipe does not work then check for the “System Preferences -> Trackpad -> More Gestures -> Swipe between fullscreen apps”.

Window Resizing:

In Mountain Lion now you can resize the windows by dragging any of its edges. This was not the case in the previous OSXs where the resizing was only possible by dragging the lower right corner of the window.

Quick Look:

You can have a quick look of any files by selecting the file and then hitting the space key. This gives a quick preview of the selected file.

Finder background:

Although of only aesthetic relevance you can change the background of the finder window when in icon view. First select the icon view. Then go to “view -> show view options”. Here you get an option to select a background. You can make this to be default  for your entire Mac by clicking the “Use as default ” button.

Select files or folders in Finder using keyboard:

In the Finder window you can directly select a folder or a file by typing its name.

Spring loaded folders:

There is a easy way of moving files between folders. You just drag and drop into the folders. The spring loaded feature helps in moving files between nested folders. You just need to drag the file onto a folder and wait until it opens the inner folder and do the same until you get to the required folder.

Do and Undo delete :

To delete a file a folder the keyboard shortcut is Command + Delete. To undo a delete the keyboard shortcut is Command + z. The Mac remembers 4 levels of deletes. Hence Command + z can undo 4 previous deletes.

search your mac using spotlight :

A complete blog page can be dedicated to the spotlight feature of the OSX. But I will mention only certain favourites of mine.

First get the spotlight field active by using the keyboard shortcut Command + Space.

The spotlight can act as a calculator. just type for example 5 + 2. You will see the answer appear next to the calculator.

To search for files and file contents with exact phrases surround the phrase words with double quotes. For example type “Comfortably numb” and the spotlight will list all the entries having this exact phrase.

To search in file with a particular type use the keyword kind. For example to search the the word hello in pdf file type

hello kind:pdf

The spotlight also accepts boolean searches. To search for files having the words Hello and How. Type

Hello AND How.

Arch Linux and Mountain Lion:VirtualBox Part 3

Arch Linux and Mountain Lion:VirtualBox Part 3

Install Arch Linux on the virtual hard drive:

The steps below are the ones I followed by referring the beginners guide.

1)After the 12 steps mention in my other post,you will be presented with a shell prompt. I have an US keyboard hence I will skip the part which is required for other language keyboards.For other keyboards refer the part “Change the language” in the beginner’s guide.

2)I had an internet connection by default hence did not need to configure the same.To find out if there is an internet connection run the command:

 ping -c 3 www.google.com

If you don’t get the below error then you are doing fine else check the beginner’s guide.

ping: unknown host

3)Now we will partition and format the virtual hard drive.We will create 3 partitions Root,Home and BIOS.Run the following command

cgdisk /dev/sda

4)Now we are presented with a table which has no partition entries.

Create the Root partition first.

Choose New (or press N)
Press Enter for the first sector (2048)
Type in 10G 
Press Enter again for the default hex code (8300)
Press Enter again for a blank partition name.
This creates a new Root partition.

Now to create the home partition:
Press the down arrow a couple of times to move to the larger free space area.

Choose New (or press N)
Press Enter for the first sector
Type in the remaining 10G
Press Enter for the default hex code (8300)
Press Enter for a blank partition name.
This creates our home partition.

Now to create the BIOS partition:
There should be third entry in the table with 1007.0 KiB size.Press the up or down arrow and select this entry.

Choose New (or press N)
Press Enter for the first sector.
Press Enter again for selecting the remaining size.
Type EF02 for the partition type
Press Enter for a blank partition name.
This creates our BIOS partition.

5)Create a file system.Run the following commands.

mkfs.ext4 /dev/sda1
mkfs.ext4 /dev/sda2

6)Mount the partitions:Run the following commands.

mount /dev/sda1 /mnt
mkdir /mnt/home
mount /dev/sda2 /mnt/home

7)Install the base system.Run the following commands.

pacstrap -i /mnt base

8)Generate a FSTAB (File System Table).Run the following commands.

genfstab -U -p /mnt >> /mnt/etc/fstab
nano /mnt/etc/fstab

Press Control X followed by Y and enter to save the file and exit nano (The default command line editor).
9)Chroot(Change the root directory) and configure the base system.Run the following commands.

arch-chroot /mnt

10)Setting the Locale.
Run the following command:

nano /etc/locale.gen

Uncomment (Remove the # at the beginning of the line) the lines that are relevant.I only needed en_US.UTF-8 UTF-8.Press Control X followed by Y and enter to save the file and exit nano.
Run the following command:

locale-gen

Run the following command:

echo LANG=en_US.UTF-8 > /etc/locale.conf
export LANG=en_US.UTF-8

If you has set a different keyboard than the US layout then refer the “Console font and keymap” section in the beginner’s guide.

11)Set the Time Zone.
For Berlin, Germany I ran the following command:

ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime

To find the allowed Zones run the following commands:

ls /usr/share/zoneinfo/

To get a subzone for a zone.Here Europe is taken as an example.

ls /usr/share/zoneinfo/Europe

12)Set the hardware clock to UTC:

hwclock --systohc --utc

13)Set the host name:I set it to oopra.

echo oopra > /etc/hostname

14)Configure the wired network:

systemctl enable dhcpcd.service

15)Set the root password and remember it.

passwd

16)Install Bootloader: We will install Grub(Grand Unified Bootloader) for our Arch Linux:

pacman -S grub
grub-install --recheck /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

17)Now the Arch Linux is installed in the Virtual hard drive.Shutdown the Linux system.
Run the command:

shutdown

18)Now in the virtualBox window select the “Settings tab” uncheck the CD/DVD ROM.

Screen Shot 2013-07-20 at 11.05.53 AM

19)Start the Arch Linux virtual machine again.
Now we are booting the Arch Linux that is installed in the virtual hard drive.
Again it presents us a shell prompt.Now its time to create another user.Until now we were running as a root user.But for our day-to-day work another user name has to be created.I created a new user oopra.

useradd -m -g users -s /bin/bash oopra

Add some for information about the user. In my case the user is oopra:

chfn oopra

Choose a new password for the new user.oopra in my case:

passwd oopra

20)Now the time has finally arrived to create a Graphical User Interface.
Run the following commands for installing the X window system:

pacman -S xorg-server xorg-server-utils xorg-xinit
pacman -S mesa

21)Install Guest additions:

pacman -S virtualbox-guest-utils
modprobe -a vboxguest vboxsf vboxvideo
nano /etc/modules-load.d/virtualbox.conf

Add the following lines in virtualbox.conf

vboxguest
vboxsf
vboxvideo

Press Control X followed by Y and enter to save the file and exit nano.

22) Test X Window System:
Install the default environment:

pacman -S xorg-twm xorg-xclock xterm

Remove the default xinitrc file.

rm ~/.xinitrc

23)Install SLIM for starting a desktop manager:

pacman -S slim

Enable SLIM:

systemctl enable slim.service

Create a .xinitrc file:

cp /etc/skel/.xinitrc ~/.xinitrc
nano ~/.xinitrc

The .xinitrc should look like:

#!/bin/sh

if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi
exec startxfce4

Press Control X followed by Y and enter to save the file and exit nano.

The .xinitrc file should be created for all users. The above step only creates the .xinitrc file for the root. For the other user I created (oopra in my case) the same file has to be created.

su oopra

Create a .xinitrc file:

cp /etc/skel/.xinitrc ~/.xinitrc
nano ~/.xinitrc

The .xinitrc should look like:

#!/bin/sh

if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi
exec startxfce4

Press Control X followed by Y and enter to save the file and exit nano.

 

Do not forget to exit.

exit

24)Install the desktop manager xfce4.

pacman -S xfce4

25)Now you have a basic Arch Linux with GUI support.Time to enable the sound :
Install Alsa running the following commands:

pacman -S alsa-utils

Unmute running the following command:

amixer sset Master unmute

Initialise Alsa control in Virtual Box running the following command:

alsactl init

26) Install flash plugins:

pacman -S flashplugin

27)Now you have a basic Arch Linux with GUI support.Now reboot using the following command:

reboot

Once it presents the login window. Login with the username and password that was created before. You can add anything more you want but running the

 pacman -S PackageNameYouWant

command.

Arch Linux and Mountain Lion:Why (Arch) Linux Part 1

Arch Linux and Mountain Lion:Why (Arch) Linux Part 1

My first choice for an OS is GNU/Linux. But the performance of the MacBook pro is irresistible. So I went ahead and bought a Mac.The question that will I be able to run GNU/Linux on Mac was on the back of my mind.As with other things I thought I will figure it out someway or another.

The MacBook Pro is an amazing machine.As the OS X is specifically designed for the hardware it runs on.It makes the OS X fast,efficient and pleasant for the user.The battery and the display are the other things that make the MacBook Pro a good buy.

All said I was still missing GNU/Linux.The mere possibility that I could configure it to exactly my requirements makes it a favourite.Added to this for me it is the best environment for software development.Hence not having GNU/Linux is not an option.And buying another machine was not an option either.After spending nearly 65,000 INR on the MacBook Pro,I was almost broke :-).

So I set out to install GNU/Linux on my Mac Book Pro.The first thing that came to my mind was to dual-boot with Linux Mint.The Mac boot loader Boot Camp is known to support dual-boot with Linux.But it was too restrictive for me.Also Apple does not officially state that it supports dual-boot with Linux.Hence the next step was to use rEFIt.But it was never smooth for me.Hence I uninstalled rEFIt.I also had problems upgrading the OS X to Mountain Lion after doing this.Although I am not certain my suspicions are towards the rEFIt.So I decided not to mess with the boot of the Mac.

So the other option is to use Linux on a Virtual Machine.Below are the steps I followed to install Arch Linux.I choose Arch Linux as it is the most customisable distro I know and the documentation is excellent.I had tried ubuntu as a virtual machine but it made my Mac horribly slow.You can refer the Wiki of the Arch Linux or follow the below steps as I did.Mine is a MacBook Pro 13-inch,Early 2011,connected to the internet with the ethernet cable.

Check my other post for installation of  VirtualBox on Mac and running Arch Linux as guest.

Mountain Lion:VirtualBox Arch Linux ISO image w/o burning CD/DVD Part 2

Mountain Lion:VirtualBox Arch Linux ISO image w/o burning CD/DVD Part 2

Install VirtualBox and Boot Arch Linux from the iso image:

1) Download VirtualBox disk image from here or the official link.Also download the Arch Linux ISO image for here.

2) Install VirtualBox by double clicking on the disk image and following window is displayed.Click on the VirtualBox.pkg and follow the instructions that are displayed. (For windows 8 users just click on the downloaded exe file and follow the below instructions)Image

3)Once installed, start the VirtualBox application from the “Applications folder” and click on the “New” button at the top left corner.

4) Give any name for your virtual machine.Select the type as “Linux” and the version as “Arch Linux”.

5) Set the RAM size to 1024MB.I found it to be of the right size so that the Mac OS X (or windows 8) can have the remaining 3 GB for itself.If you increase it above 1024 MB then the Mac OS X performance decreases considerably.

6)Select “Create a virtual Hard Drive now”,”VDI” hard drive type,Fixed Size of minimum 20GB in the next windows.

7)Now in the main window there should be an entry of the virtual machine that was created with the above steps.

Screen Shot 2013-07-20 at 12.10.58 PM

8)Select the newly created virtual machine and click on the settings button.

9)In the new window select the system tab.Rearrange the boot order so that the CD/DVD ROM is before the Hard Disk and check both of them. Let the chipset be “PIIX3” and in the extended features check “Hardware clock in UTC time” and “Enable absolute pointing device”.

Image

10)Next select the storage tab.Here you should find the already created VDI.Now right-click outside the VDI entry and add a “IDE controller”.After that right click on the newly created IDE controller and select “add CD/DVD device”.Here in the new window select “choose disk” and select the Arch Linux ISO image that was downloaded before.

Image

11) Now start the virtual machine and it should boot the Arch Linux from the ISO image.The Arch Linux presents a shell prompt instead of a GUI.This is because Arch Linux is very minimal and it allows you to choose and install the desktop manager you prefer.

12)The next step is to install the Arch Linux on the VDI virtual hard drive that was created.Check my other post here for the installation.

Mac OSX “This disk cannot be used to startup your computer”

This is my step by step ordeal of upgrading my MacBook Pro 13-inch ( model early 2011).

 Upgrade to Mountain Lion

At the start of installation I get the Mountain Lion initial window with the Macintosh HD as the only target to install (My Mac has only one partition).  Beside the target HD a message saying “This disk cannot be used to startup your computer”.  I did a quick google search for this message. The top hits were from the Apple forums and Apple Support. The suggestions here about using the Disk Utility to decrease the partition size and retrying the installation did not work.  I remembered that I had an Ubuntu installation with the virtual box and had also tried to dual boot Linux using rEFIt. This I think might have messed up my file system.

What what worked for me

I just created a new partition using the Disk Utility.  Now I had two partitions of equal size. Then I tried the install of the Mountain Lion on the same partition as the Snow Leopard and it worked. The previous message about the disk not able to start-up was gone. So at least for my Mac a creation of a new partition was necessary. Also since its not a clean install of the Mountain Lion I still had all the applications from my previous Snow Leopard.

After the successful installation of the Mountain Lion I removed the other partition and extended the size of the partition where my new Mountain Lion was installed.