( linux )


Contents

  1. Raspberry Pi

Fri, Feb 02, 2017

RASPBERRY PI

Backup

$ sudo dd bs=4M if=/dev/sde of=raspbian.img    # backup
$ sudo dd bs=4M if=raspbian.img of=/dev/sde    # restore

or

$ 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

$ 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
$ 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

$ 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

$ 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

$ pacman -S sudo

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

Update

$ sudo pacman -Syu
$ sudo pacman -Syy              # If above failed

Xfce

$ 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

Updated

xorg-server-utils has been replaced by xorg-apps

Additional Install

$ sudo pacman -S openssh
$ sudo pacman -S vim
$ sudo pacman -S tigervnc

Apply dotfiles.

VNC Setup

$ vncserver                     # Create configs
$ vncserver -kill :1            # NOTE: To shutdown vncserver

~/.vnc/xstartup

#!/bin/sh

exec /bin/sh /etc/xdg/xfce4/xinitrc

/etc/systemd/system/vncserver@:1.service

[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

$ sudo systemctl enable vncserver@:1.service

VNC Client

Use TightVNC
Port: 5901

Mount USB Drive

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

sshfs

$ brew cask install osxfuse
$ brew install sshfs