Daniel Ngu

Raspberry Pi 3

Backup

Backup SD Card Image
1
2
$ sudo dd bs=4M if=/dev/sde of=raspbian.img    # backup
$ sudo dd bs=4M if=raspbian.img of=/dev/sde    # restore

or

Backup SD Card Image With Compression
1
2
$ sudo dd bs=4M if=/dev/sde | gzip > rasbian.img.gz             # backup
$ gunzip --stdout rasbian.img.gz | sudo dd bs=4M of=/dev/sde    # restore

Reference: Backups

Media

ISO available via Arch download page.

Installation

Installation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ fdisk /dev/sde
$ o                      # Clear out any partitions on the drive
$ p                      # List partitions
$ n                      # New partition
$ p                      # Primary
$ 1                      # First partition on drive
$ Enter                  # Accept default first sector
$ +100M                  # 100MB for boot partition
$ t                      # Partition type
$ c                      # Set partition type to W95 FAT32 (LBA)
$ n                      # New partition
$ p                      # Primary
$ 2                      # Second partition on drive
$ Enter                  # Accept default first sector
$ Enter                  # Accept default last sector
$ mkfs.vfat /dev/sde1    # Create and mount the FAT filesystem
$ mkdir boot
$ mount /dev/sde1 boot
$ mkfs.ext4 /dev/sde2    # Create and mount the ext4 filesystem
$ mkdir root
$ mount /dev/sde2 root
Download and extract the root filesystem (as root, not via sudo)
1
2
3
4
5
$ wget http://os.archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz
$ bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C root
$ sync
$ mv root/boot/* boot    # Move boot files to the first partition
$ umount boot root       # Unmount the two partitions

Default:
user: alarm
password: alarm

user: root
password: root

Reference: ARMv7 Installation

Wireless

Setup Wireless Network
1
2
3
4
$ pacman -S dialog wpa_supplicant
$ wifi-menu
$ ls /etc/netctl/               # Find the wifi profile
$ netctl enable profile-name    # Substitute profile-name as obtained above

Create New User

Create New User
1
2
3
$ useradd -m -G wheel -s /bin/bash daniel
$ passwd daniel
$ usermod -a -G audio,network,power,scanner,storage,systemd-journal,video daniel

The above creates a new user with home directory, change password and add user to additional groups.

Sudo

Install Sudo
1
$ pacman -S sudo

Run visudo, edit it to restrict sudo to specific group or user.

Update

Update
1
2
$ sudo pacman -Syu
$ sudo pacman -Syy              # If above failed

Xfce

Install Xfce
1
2
3
4
$ sudo pacman -S xfce4
$ sudo pacman -S xorg-server xorg-server-utils xorg-xinit
$ sudo pacman -S xf86-video-fbdev
$ startxfce4                    # NOTE: To manually start Xfce

Additional Install

Additional Install
1
2
3
$ sudo pacman -S openssh
$ sudo pacman -S vim
$ sudo pacman -S tigervnc

dotfiles

Apply the dotfiles

VNC Setup

VNC Setup
1
2
$ vncserver                     # Create configs
$ vncserver -kill :1            # NOTE: To shutdown vncserver
~/.vnc/xstartup
1
2
3
#!/bin/sh

exec /bin/sh /etc/xdg/xfce4/xinitrc
/etc/systemd/system/vncserver@:1.service
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[Service]
Type=simple
User=daniel
PAMName=login
PIDFile=/home/daniel/.vnc/%H:%i.pid
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/bin/vncserver -geometry 1280x720 -alwaysshared -fg %i
ExecStop=/usr/bin/vncserver -kill %i

[Install]
WantedBy=multi-user.target
Enable vncserver@:1.service
1
$ sudo systemctl enable vncserver@:1.service

VNC Client

Use TightVNC
Port: 5901

Mount USB Drive

Mount USB Drive
1
$ sudo mount /dev/sda1 /mnt/usb -o uid=1000,gid=1000,utf8,dmask=027,fmask=137

sshfs

Install sshfs
1
2
$ brew cask install osxfuse
$ brew install sshfs