My URXVT, and VIMRC conf on openSUSE

For URXVT (Don’t forget to run xrdb -load .Xresources)

URxvt*saveLines: 12000
URxvt*.depth: 32
URxvt.background: [90]#000000
URxvt*foreground: White
URxvt*background: Black
URxvt*scrollBar: true
URxvt*scrollBar_right: true
URxvt*scrollstyle: rxvt
URxvt*color4: #2554C7
URxvt*color12: #2554C7
Xcursor.theme: aero-drop-left
URxvt*font: xft:Ricty:size=13:antialias=true:hinting=true
URxvt*letterSpace: -2
URxvt*keysym.Home: \033[1~
URxvt*keysym.End: \033[4~
URxvt*perl-ext-common: selection-to-clipboard

for /etc/tmux.conf
set -g default-command "${SHELL}"
set -g default-terminal "screen-256color"

set -g default-command “${SHELL}”
set -g default-terminal “screen-256color”
bind-key -t emacs-copy M-w copy-pipe “xsel -i -p -b”
bind-key C-y run “xsel -o | tmux load-buffer – ; tmux paste-buffer”

for bashrc
alias ssh='TERM=xterm-256color ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'

For vimrc


syntax on
set nobackup
set noswapfile
set clipboard=unnamed,unnamedplus
set guifont=Inconsolata\ 14
set iminsert=0
set imsearch=0
set bs=2
set nowrapscan
set number
set list
set hlsearch
set cursorline
set mouse=a
colorscheme badwolf

For attaching to a existing tmux session or creating a new tmux session on SSH.
TERM=screen-256color ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null 10.0.0.1 -t ‘. /etc/profile; tmux at’ || TERM=screen-256color ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null 10.0.0.1 -t ‘. /etc/profile; tmux’

Advertisements

IPIP tunnel with Linux (IP in IP)

ip tunnel add tun0 mode ipip local “GLOBAL IP “remote “GLOBAL IP”
ip link set tun0 up
ip addr add “LOCAL IP” dev tun0

nginx, python3, uwsgi, django stack on Arch Linux (Raspberry Pi2)

1. Install necessary packags from repo.
sudo pacman -S python sqlite nginx python-pip python-django

2. Install uwsgi.
sudo pip install uwsgi

3. Set up uwsgi emperor
mkdir /etc/uwsgi
mkdir /etc/uwsgi/vassals

vim /etc/uwsgi/emperor.ini
[uwsgi]
emperor = /etc/uwsgi/vassals
#uid = http
#gid = http

vim /etc/systemd/system/emperor.uwsgi.service
[Unit]
Description=uWSGI Emperor
After=syslog.target

[Service]
ExecStart=/usr/bin/uwsgi –ini /etc/uwsgi/emperor.ini
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -INT $MAINPID
Restart=always
Type=notify
StandardError=syslog
NotifyAccess=all
KillSignal=SIGQUIT

[Install]
WantedBy=multi-user.target

4. Create first site.
django-admin.py startproject mysite

5. Place configuration files in the project directory
cd mysite
cp /etc/nginx/uwsgi_params ./

vim mysite_nginx.conf
upstream django {
#server unix:///path/mysite.sock; # for using unix socket
server 127.0.0.1:8001;
}

server {
listen 80;
server_name 10.0.0.5;
charset utf-8;

location / {
uwsgi_pass django;
include /path/uwsgi_params;
}
}

vim /etc/nginx/nginx.conf and add below to http directive
include /etc/nginx/sites-enabled/*;

mkdir /etc/nginx/sites-enabled/
sudo ln -s /path/mysite/mysite_nginx.conf /etc/nginx/sites-enabled/

vim mysite_uwsgi.ini
[uwsgi]

chdir = /home/users/www/mysite/
module = mysite.wsgi
master = true
processes = 4
socket = 127.0.0.1:8001

sudo ln -s /path/mysite_uwsgi.ini /etc/uwsgi/vassals/

5. start the services
systemctl start emperor.uwsgi
systemctl start nginx

6. django
cd mypage
python manage.py migrate
python manage.py createsuperuser

Access http://127.0.0.1/admin

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

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

CentOS 7 Minimal GUI installation (Gnome)

1. Install CentOS from a minimal CD provided in one of the mirror sites.

2. After installation, remove unnecessary packages. Mine are like below.
NetworkManager is totally unnecessary in my opinion. It just creates and modifies network related files
without us knowing. Creating network-script files and editing the resolv.conf file directly gives us
better control over the system


yum remove NetworkManager
yum remove NetworkManager-glib
yum remove selinux-policy selinux-policy-targeted
yum remove postfix
yum remove audit
yum remove firewalld
yum remove tuned

3. Install GUI


yum groupinstall x11
yum install gdm
yum install gnome-session-xsession

systemctl start gdm

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,

PCI passthrough in KVM

1.  make sure to add “iommu=on” in the grub otion.

e.g. /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT=”iommu=on”

2.  unbind pci from the host

find the pci id by “lscpi”  and “lspci -n” command, and do something like below.

e.g.

echo "1033 0194" > /sys/bus/pci/drivers/pci-stub/new_id
echo "0000:0d:00.0" > /sys/bus/pci/drivers/xhci_hcd/unbind
echo "0000:0d:00.0" > /sys/bus/pci/drivers/pci-stub/bind
echo "1033 0194" > /sys/bus/pci/drivers/pci-stub/remove_id

3. Attach the pci to the VM before booting, and boot the VM.

Install Windows Server 2012 R2 in UEFI Mode on USB

0. Here I leave notes on how to install windows server 2012 R2 on a USB attached HDD. I did all of below from Windows 8.1 Enterprise Evaluate edition on Virtualbox. 1. Run CMD as an administrator. 2. Partitioning


# Start diskpart.exe
diskpart.exe
# Show available disks
list disk
# Choose the disk
select disk 1
# Change label to gpt
convert gpt
# Create EFI partition of 100MB
create partition efi size=100
# Format as fat32
format quick fs=fat32 label="BOOT"
# Assign a windows drive letter of your preference.
assign letter=B
# Create OS partition of 128GB
create partition primary size=128000 format quick fs=ntfs label="OS"
assign letter=O
list volume
exit

3. Installing the OS on USB


# Find available index number of edition.
dism /Get-WimInfo /WimFile:c:\install.wim
# Extract install.wim from the OS media, and place it on C drive root, and then run command below.
dism /apply-image /imagefile:c:\install.wim /index:2 /applydir:o:\

4. Install bootmgr on efi partion.

o:\windows\system32\bcdboot o:\windows /f ALL /s b:

5. Boot the PC from the USB drive, and finish the setup.