Raspberry Pi 2 (Arch)

Notes

parted /dev/mmcblk0
unit mib
mklabel msdos
mkpart
p
fat32
2
130

mkpart
p
ext4
130
-1

mkfs.vfat /dev/mmcblk0p1
mkfs.ext4 /dev/mmcblk0p2

mount /dev/mmcblk0p2 /mnt
mkdir /mnt/boot
mount /dev/mmcblk0p1 /mnt/boot
cd /mnt
bsdtar -xpf ../ArchLinuxARM-rpi-2-latest.tar.gz

—BOOT RASPBERRY PI2—
ssh(root/root is the default for arch)

pacman -Syu
pacman -S vim-minimal
vim /etc/locale.gen

localectl set-locale LANG=en_GB.UTF-8
timedatectl set-timezone Asia/Tokyo
timedatectl set-local-rtc 0
timedatectl set-ntp true

vim /etc/systemd/timesyncd.conf
systemctl start systemd-timesyncd
systemctl enable systemd-timesyncd
systemctl start systemd-resolved
systemctl enable systemd-resolved
ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf

vim /etc/systemd/network/eth0.network

pacman -Rsn nano reiserfsprogs s-nail openresolv net-tools netctl

–GUI–
pacman -S xf86-video-fbdev xorg-server xorg-xinit xfce4-panel xfce4-session xfwm4 rxvt-unicode

Advertisements

Arch Linux Pure systemd installation with UEFI enabled

1. parted -a optimal /dev/sda
mklabel gpt
unit mib
mkpart esp fat32 2 262
mkpart primary btrfs 262 -1
quit
mkfs.fat -F32 /dev/sda1
mkfs.btrfs /dev/sda2
mount /dev/sda2 /mnt
mkdir -p /mnt/boot
mount /dev/sda1 /mnt/boot
vim /etc/pacman.d/mirrorlist
pacstrap -i /mnt base base-devel
genfstab -U -p /mnt >> /mnt/etc/fstab
vi /mnt/etc/fstab a
dd below to btrfs partition (for ssd)
noatime,discard,ssd,autodefrag,compress=lzo,space_cache
arch-chroot /mnt /bin/bash
passwd
pacman -S dosfstools efibootmgr gummiboot
gummiboot –path=/boot install
vi /boot/loader/entries/arch.conf
title Arch Linux linux /vmlinuz-linux
initrd /initramfs-linux.img
options root=/dev/sda2 rw
vi /boot/loader/loader.conf
default arch timeout 1
umount /mnt/boot umount /mnt
reboot

vi /etc/locale.gen
locale-gen
localectl set-locale LANG=en_GB.UTF-8
timedatectl list-timezones
timedatectl set-timezone Asia/Tokyo
timedatectl set-local-rtc 0
timedatectl set-ntp true

vi /etc/systemd/timesyncd.conf
[Time] NTP=ntp.nict.jp

systemctl start systemd-timesyncd
systemctl enable systemd-resolved
ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
hostnamectl set-hostname myhostname
localectl set-keymap jp106

2. GUI
pacman -S xf86-video-intel xorg-server xorg-xinit thunar xfce4-panel xfce4-session xfce4-settings xfdesktop xfwm4 rxvt-unicode

3.networking
cat /etc/systemd/network/wlp3s0.network
[Match]
Name=wlp3s0

[Network]
DHCP=v4

[DHCP]
RouteMetric=20

cat /etc/systemd/network/enp0s25.network
[Match]
Name=enp0s25

[Network]
[Match]
Name=meth0

[Network]
DHCP=v4

[DHCP]
RouteMetric=10

cat /etc/systemd/network/meth0.netdev
[NetDev]
Name=meth0
Kind=macvlan
MACAddress=f0:de:f1:66:a8:14

[MACVLAN]
Mode=bridge

cat /etc/wpa_supplicant/wpa_supplicant-wlp3s0.conf
#Home
network={
ssid=”ssid-name”
key_mgmt=WPA-PSK
psk=”password”
}

systemctl enable wpa_supplicant@wlp3s0
systemctl start wpa_supplicant@wlp3s0
systemctl start systemd-networkd
systemctl enable systemd-networkd

cat .xbindkeysrc

“pamixer –toggle-mute”
XF86AudioMute
“pamixer –decrease 5 –allow-boost”
XF86AudioLowerVolume
“pamixer –increase 5 –allow-boost”
XF86AudioRaiseVolume
“xfce4-screenshooter -f -s /home/users/pictures/screenshot/”
Print
“xfce4-screenshooter -w -s /home/users/pictures/screenshot/”
Alt + Alt_L + Print

cat .Xresources
URxvt*saveLines: 12000
URxvt*.depth: 32
URxvt*foreground: White
URxvt*background: [90]Black
URxvt*font: xft:fixed:pixelsize=14:antialias=true:hinting=true
URxvt*boldFont: xft:fixed:bold:pixelsize=14:antialias=true:hinting=true
URxvt*scrollBar: true
URxvt*scrollBar_right: true
URxvt*scrollstyle: rxvt
URxvt*color4: #2554C7
URxvt*color12: #2554C7
URxvt*perl-ext-common: default,clipboard

yaourt urxvt-clipboard

Arch Linux Installation Command Notes.


parted -a optimal /dev/sda

mklabel msdos
unit mib
mkpart primary ext4 2 -1
set 1 boot on
quit

mkfs.btrfs /dev/sda1
mount /dev/sda1 /mnt

vi /etc/pacman.d/mirrorlist
pacstrap -i /mnt
genfstab -p -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt

passwd
useradd “username” -m -s /bin/bash
passwd “username”

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

exit
umount /mnt
reboot

vi /etc/locale.gen
locale-gen
localectl set-locale LANG=en_GB.UTF-8
timedatectl list-timezones
timedatectl set-timezone Asia/Tokyo
timedatectl set-local-rtc 0
hostnamectl set-hostname myhostname

vi /etc/systemd/network/enp0s3.network
[Match]
Name=enp0s3

[Network]
DHCP=v4

systemctl restart systemd-networkd
systemctl enable systemd-networkd

pacman -Rsn netctl nano reiserfsprogs dhcpcd xfsprogs s-nail

reboot
pacman -S xorg-server xorg-server-utils xorg-xinit mesa virtualbox-guest-utils xterm
pacman -S xmonad-contrib

Owncloud setup notes

How to set up owncloud with nginx, php-fpm, postgresql on Arch Linux.
This setup is without SSL and access control.

1. Installing necessary packages.


pacman -S owncloud nginx php-fpm php-pgsql postgresql

2. Setting up postgresql.


sudo su -
su - postgres -c "initdb --locale en_GB.UTF-8 -D '/var/lib/postgres/data'"
systemctl start postgresql
systemctl enable postgresql
psql -hlocalhost -Upostgres
CREATE USER username WITH PASSWORD 'password';
CREATE DATABASE owncloud TEMPLATE template0 ENCODING 'UNICODE';
ALTER DATABASE owncloud OWNER TO username;
GRANT ALL PRIVILEGES ON DATABASE owncloud TO username;
\q

3. Setting up php

Create a file /etc/php/conf.d/owncloud.ini with texts below


extension=gd.so
extension=iconv.so
extension=xmlrpc.so
extension=zip.so
extension=pdo_pgsql.so
extension=pgsql.so

[PostgresSQL]
pgsql.allow_persistent = On
pgsql.auto_reset_persistent = Off
pgsql.max_persistent = -1
pgsql.max_links = -1
pgsql.ignore_notice = 0
pgsql.log_notice = 0

Edit /etc/php/php.ini


open_basedir = /srv/http/:/usr/share/webapps/:/etc/webapps/owncloud/config/

post_max_size = 10G
upload_max_filesize = 10G

Start php-fpm


systemctl start php-fpm
systemctl enable php-fpm

3. Setting up nginx.

server {
listen 80;
server_name localhost;

# Path to the root of your installation
root /srv/http/;

client_max_body_size 10G; # set max upload size
fastcgi_buffers 64 4K;

rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;

index index.php;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location ~ ^/(data|config|\.ht|db_structure\.xml|README) {
deny all;
}

location / {
# The following 2 rules are only needed with webfinger
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;

rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;

rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;

try_files $uri $uri/ index.php;
}

location ~ ^(.+?\.php)(/.*)?$ {
try_files $1 = 404;

include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$1;
fastcgi_param PATH_INFO $2;
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
}

# Optional: set long EXPIRES header on static assets
location ~* ^.+\.(jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
# Optional: Don't log access to assets
access_log off;
}

}

service


systemctl enable nginx
systemctl start nginx

4. Setting up owncloud contents


ln -s /usr/share/webapps/owncloud /srv/http/
chown http:http -R /usr/share/webapps/owncloud/
chown http:http /srv/http/owncloud -R

5. Access 127.0.0.1/owncloud from your browser and finish the setup.

6. Remove the line with trusted domain in /etc/webapps/owncloud/config/config.php, and add below


'loglevel' => '4',
'updatechecker' => false,
'check_for_working_htaccess' => false,
'appstoreenabled' => false,
'check_for_working_webdav' => false,

Enabling Networking between KVM host and guests.

In this post, I describe how to realise L2 reachability between KVM host and guest on Arch Linux.
There are several interface mode on KVM guests. Here, I will use MacVTap (bridge mode).

0. Method 1, using ip command.


# Creating an macvlan interface binds to enp0s25.
sudo ip link add link enp0s25 macvlan0 type macvlan mode bridge

# Set an IP address.
# Make sure to use different IP address from physical interface's.
# or, just delete an IP address from physical interface.
sudo ip addr add 192.168.0.10/24 dev macvlan0

# Erasing all routing tables.
sudo ip route flush dev enp0s25
sudo ip route flush dev macvlan0

# Adding routes
sudo ip route add 192.168.0.0/24 dev macvlan0 src 192.168.0.10 metric 0
sudo ip route add default via 192.168.0.1 dev macvlan0

2. Using netctl to make it permanent.


vim /etc/netctl/macvlan0

Description='macvlan0 for kvm'
Interface=macvlan0
Connection=macvlan
# The variable name is plural, but needs precisely one interface
BindsToInterfaces=enp0s25
# MACVLAN Mode
Mode="bridge"
# Optional static MAC Address for MACVLAN interface
MACAddress="26:39:c8:6f:c6:37"
IP=dhcp

netctl disable enp0s25
netctl enable macvlan0

That’s all

NFS Setup Note

NFS Setup on Arch Linux

NFS server on Arch Linux
1. Get nfs-utils from repo

2. Edit domain section of /etc/idmapd.conf.

3. Edit /etc/exports and decide your pseudo-root directory (Can be anywhere)
/srv/nfs4 192.168.11.0/24(rw,no_subtree_check,insecure,no_root_squash,no_wdelay)
Change the permission of the directories to your preference with chmod.
Explanations are available in man exports

4. mount the directory you want to share via nfs
mount –bind /mnt/hdd /srv/nfs4
in /etc/fstab
/mnt/hdd /srv/nfs4 none bind 0 0

5. Apply /etc/exports configuration.You must run the command below everytime you make changes to a exports file
exportfs -rav

6. Open ports for nfs, if you use iptables
specify mount port in /etc/conf.d/nfs-server.conf
e.g.
MOUNTD_OPTS=”–port 4444″

Client Settings
From MacOS
Read man mount_nfs, man nfs.conf, man mount
To specify mount port use mountport=4444.

# It seems nfsv4 does not work well on Mavericks, even though MacOS is supposed to be Unix.
SMB will probably perform better.

# Updates
NFSv3 with certain options works very well.
Read the Time Machine via NFS article.

Arch Linux Installation Command Notes

Recently I installed Arch Linux on virtualbox, however, as of 1/1/2014 cfdisk was not working right
and I could not boot the OS by both grub and syslinux. Here is what I did.

1.Partitioning. (Just one logical partition is enough for me. No boot partition, no swap partition…)
cgdisk /dev/sda
#first sector = 2048(default)
#type = 8300(linux)

2. Boot Flagging
parted /dev/sda set 1 boot on

3. Formatting
mkfs.ext4 /dev/sda1

4. Installing packages and etc (follow the begginers guide of arch wiki)
vi /etc/pacman.d/mirrorlist
# bring up mirror site of your favourite location.
mount /dev/sda1 /mnt
pacstrap -i /mnt
genfstab -p -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt
vi /etc/locale.gen
# uncomment en_GB.UTF8
locale-gen
echo LANG=en_GB.UTF8 > /etc/locale.conf
ln -s /usr/share/zoninfo/Japan /etc/localtime
hwclock -w -u
echo “your_hostname” >> /etc/hostname
passwd
useradd “username” -m -s /bin/bash
passwd “username”

5. Configuring grub
pacman -S grub
vi /etc/default/grub
append GRUB_DISABLE_SUBMENU=y
grub-mkconfig -o /boot/grub/grub.cfg
grub-install —force /dev/sda

6. Reboot
exit
umount /mnt
reboot

GUI setup on Virtualbox(xfce4 & slim)
pacman -S xorg-server xorg-server-utils xorg-xinit mesa
cp /etc/skel/.xinitrc ~/.xinitrc
pacman -S ttf-dejavu
pacman -S xfce4
pacman -S slim
vi /etc/slim.conf and specify default user and enable auto login
localectl set-x11-keymap layout jp106 to set jp106 keymap

Resource usage
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 7.8G 1.7G 5.8G 23% /
dev 248M 0 248M 0% /dev
run 250M 300K 250M 1% /run
tmpfs 250M 192K 250M 1% /dev/shm
tmpfs 250M 0 250M 0% /sys/fs/cgroup
tmpfs 250M 12K 250M 1% /tmp

free -h

total used free shared buffers cached
Mem: 499M 476M 22M 2.8M 15M 379M
-/+ buffers/cache: 81M 417M
Swap: 0B 0B 0B

top
455 user 9 -11 98860 6000 4256 S 6.7 1.2 1:34.90 pulseaudio
385 user 20 0 9536 1524 960 S 0.6 0.3 0:12.77 VBoxClient
96 root 20 0 0 0 0 S 0.1 0.0 0:01.71 kworker/0:2
136 root 20 0 11252 1656 1256 S 0.1 0.3 0:01.24 VBoxService
338 root 20 0 39696 4164 3376 S 0.1 0.8 0:00.19 upowerd
1 root 20 0 4704 2636 1980 S 0.0 0.5 0:00.77 systemd