Yesterday when I reached home, I received my Raspberry Pi camera which was ordered 2 weeks ago from RS UK. I was quite tired but I was very excited to try it out on my Arch Linux ARM. So I spent about 1 hour to get it worked, here is the result (pls notice that I didn't get to watch the live video so you can see the camera was pointing to random locations) :)

Received Raspberry Pi camera

Received Raspberry Pi camera 02

Here is how I get it works on my Arch Linux ARM:

Add /opt/vc/bin to PATH

echo 'export PATH=$PATH:/opt/vc/bin' >> ~/.bashrc

Then add the necessary setting to /boot/config.txt

...
...
##added for camera
gpu_mem=128
start_file=start_x.elf
fixup_file=fixup_x.dat

Reboot the Pi

To capture still image

raspistill -o testimage.jpg -hf

Take note that I need to use -hf to horizontal flip the image (otherwise the result image will be mirrored)

To capture 30s video

raspivid -o testvideo.h264 -t 30000 -hf

References

http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=44539 http://www.raspberrypi.org/archives/tag/camera-board

In this video I show you how I use my Galaxy Note 2 to connect to my Raspberry Pi via SSH.

Galaxy Note 2 connects to Raspberry Pi via SSH

Thank you for watching!

Sunday morning playing with my Raspberry Pi :)

Raspberry Pi with raspberry

This post represents the steps that I took to encrypt my ~ directory with ecryptfs.

Log in as root, then perform the following commands:

# mv /home/squallltt /home/squallltt.old
# mkdir -m 700 /home/squallltt
# chown squallltt:users /home/squallltt
# usermod -d /home/squallltt.old squallltt

Reboot, then:

# mkdir -p /home/.ecryptfs/squallltt/.Private
# chmod 755 /home/.ecryptfs
# chmod -R 700 /home/.ecryptfs/squallltt
# chown -R squallltt:users /home/.ecryptfs/squallltt
# ln -s /home/.ecryptfs/squallltt/.Private /home/squallltt/.Private
# chmod 500 /home/squallltt

Then, install ecryptfs-utils

# pacman -S ecryptfs-utils

Now mount:

# mount -t ecryptfs /home/squallltt/.Private /home/squallltt

Key type: passphrase

Passphrase: veryStrongPassphraseHere

Cypher: twofish

Key bytes: 32

Plaintext passthrough: no

Filename encryption: yes

Add signature to cache: yes

Then open file /etc/mtab with vim and copy the last line to /etc/fstab. The first line is originally from /etc/mtab, the second line is to be added to /etc/fstab with added user,noauto,exec. Replace the XXXXXXXXXXXXXXXX with your signature.

/home/.ecryptfs/squallltt/.Private /home/squallltt ecryptfs rw,nosuid,nodev,relatime,ecryptfs_sig=XXXXXXXXXXXXXXXX,ecryptfs_fnek_sig=XXXXXXXXXXXXXXXX,ecryptfs_cipher=twofish,ecryptfs_key_bytes=32,ecryptfs_unlink_sigs 0 0

/home/.ecryptfs/squallltt/.Private /home/squallltt ecryptfs rw,user,noauto,exec,relatime,ecryptfs_fnek_sig=XXXXXXXXXXXXXXXX,ecryptfs_sig=XXXXXXXXXXXXXXXX,ecryptfs_cipher=twofish,ecryptfs_key_bytes=32,ecryptfs_unlink_sigs 0 0

Then, continue:

# touch /root/.ecryptfs/auto-mount
# ecryptfs-wrap-passphrase /root/.ecryptfs/wrapped-passphrase
Passphrase to wrap: [enter mount passphrase]
Wrapping passphrase: [enter user login password]
# umount /home/squallltt

Now, move the necessary files to desired place:

# mv /root/.ecryptfs /home/.ecryptfs/squallltt
# chown -R squallltt:users /home/.ecryptfs/squallltt/.ecryptfs
# ln -s /home/.ecryptfs/squallltt/.ecryptfs /home/squallltt/.ecryptfs

Then, install pam_mount

# pacman -S pam_mount

Now, proceed to edit file /etc/pam.d/system-auth

# vim /etc/pam.d/system-auth

#%PAM-1.0

auth      required  pam_env.so
auth      required  pam_unix.so     try_first_pass nullok
#added 2 lines below
auth      optional  pam_mount.so
auth      required  pam_ecryptfs.so unwrap
auth      optional  pam_permit.so

account   required  pam_unix.so
account   optional  pam_permit.so
account   required  pam_time.so

#added 2 lines below
password  optional  pam_ecryptfs.so
password  optional  pam_mount.so
password  required  pam_unix.so     try_first_pass nullok sha512 shadow
password  optional  pam_permit.so

#added 1 line below
session   optional  pam_mount.so
session   required  pam_limits.so
session   required  pam_env.so
session   required  pam_unix.so
#added 1 line below
session   optional  pam_ecryptfs.so unwrap
session   optional  pam_permit.so

Now, mount the private home folder and copy the old content into new private home folder and encrypt them on the fly

# ecryptfs-insert-wrapped-passphrase-into-keyring /home/squallltt/.ecryptfs/wrapped-passphrase
Passphrase: [enter user login password]
# mount -i /home/squallltt
# rsync -aP /home/squallltt.old/ /home/squallltt/

Then, unmount the encrypted directory and change user's home folder:

# umount /home/squallltt
# usermod -d /home/squallltt squallltt

Finally, edit file /etc/security/pam_mount.conf.xml. Here are some changes:

...

<luserconf name=".pam_mount.conf.xml" />

...

<!--
<mntoptions deny="suid,dev" />
<mntoptions allow="*" />
<mntoptions deny="*" />
<mntoptions require="nosuid,nodev" />
-->

...

<mntoptions require="" />

...

<mkmountpoint enable="1" remove="true" />
<lclmount>mount -i %(VOLUME) "%(before=\"-o\" OPTIONS)"</lclmount>
<volume noroot="1" fstype="ecryptfs" path="/home/.ecryptfs/squallltt/.Private" mountpoint="/home/squallltt"/>

The full content of my /etc/security/pam_mount.conf.xml is:

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE pam_mount SYSTEM "pam_mount.conf.xml.dtd">
<!--
    See pam_mount.conf(5) for a description.
-->

<pam_mount>

        <!-- debug should come before everything else,
        since this file is still processed in a single pass
        from top-to-bottom -->

<debug enable="0" />

        <!-- Volume definitions -->


        <!-- pam_mount parameters: General tunables -->

<luserconf name=".pam_mount.conf.xml" />

<!-- Note that commenting out mntoptions will give you the defaults.
     You will need to explicitly initialize it with the empty string
     to reset the defaults to nothing. -->
<mntoptions allow="nosuid,nodev,loop,encryption,fsck,nonempty,allow_root,allow_other" />
<!--
<mntoptions deny="suid,dev" />
<mntoptions allow="*" />
<mntoptions deny="*" />
<mntoptions require="nosuid,nodev" />
-->

<mntoptions require="" />

<!-- requires ofl from hxtools to be present -->
<logout wait="0" hup="0" term="0" kill="0" />


        <!-- pam_mount parameters: Volume-related -->

<!-- <volume user="squallltt" fstype="auto" path="/dev/sda2" mountpoint="/home" options="fsck,noatime" /> -->
<mkmountpoint enable="1" remove="true" />
<lclmount>mount -i %(VOLUME) "%(before=\"-o\" OPTIONS)"</lclmount>
<volume noroot="1" fstype="ecryptfs" path="/home/.ecryptfs/squallltt/.Private" mountpoint="/home/squallltt"/>


</pam_mount>

Reboot, once logged in, you should see your encrypted home directory auto mounted :)

References:

https://wiki.archlinux.org/index.php/ECryptfs http://sysphere.org/~anrxc/j/articles/ecryptfs/index.html

By default, the Arch Linux ARM image for Raspberry Pi only has 2GB capacity. So in order to use the full capacity of my SD card (16GB), I have to re-size my root partition. Here is what I did.

First, backup my SD card using dd command

(this is done with the SD card plugged in to my laptop). Take note that sdc is my SD card device, you can find out what your SD card device name by using lsblk -f command.

sudo dd if=/dev/sdc  of=~/raspberrypi_backup_20130514.img

Show a list of partition available on your SD card:

ls /dev/mmcblk0

Then the result should be something like this: (take note that: earlier I already created a data partition on mmcblk0p3

mmcblk0    mmcblk0p1    mmcblk0p2    mmcblk0p3

Then run the following command

# fdisk /dev/mmcblk0

Type p to list partition table. Here is the result:

Resize_Root_Partition_Raspberry_Pi_Arch_Linux_01

Next, type d to delete partition 2 and 3. Take note that, we need to keep the Boot partition which is number 1

Resize_Root_Partition_Raspberry_Pi_Arch_Linux_02

Now I'm able to resize the main partition:

  • Type n to create a new partition

  • Then p to set it as primary

  • Type 2 for partition number.

  • Enter 186368 for First sector (which is the End of the Boot partition + 1

  • For Last sector: hit Enter to use the default.

  • Finally type w to write changes.

Resize_Root_Partition_Raspberry_Pi_Arch_Linux_03

Next reboot the Raspberry Pi

# reboot

Resize new boot root partition

Once the Raspberry Pi has booted, log in as root and run this command:

# resize2fs /dev/mmcblk0p2

sit back and relax until it's done.

Enjoy the full size of your new root partition :)

Resize_Root_Partition_Raspberry_Pi_Arch_Linux_04

References

This post is based on an answer on stackexchange.com