Box

From Things and Stuff Wiki
Revision as of 00:11, 12 March 2017 by Milk (talk | contribs) (→‎Misc)
Jump to navigation Jump to search


A box, yer computer, physical (or abstract) box. [1]

These are the steps that I follow (and create) when I set-up Arch Linux. They are incomplete.

See also Stack, *nix#Configuration 2, Server, Distros

Arch Linux install

Initial setup

Install instance config, format, bootstrap, chroot.

# arch linux install from archiso usb drive
# requires network connectivity to be available, preferably wired (for speed).

# set keyboard for UK qwerty
loadkeys /usr/share/kbd/keymaps/i386/qwerty/uk.map.gz

# check for potentially failed services (i.e. network dhcp)
systemctl --failed


### for wifi
vim /etc/wpa_supplicant/base.conf

  ctrl_interface=/run/wpa_supplicant
  update_config=1

# get wifi interface name
ip a

# start wpa_supplicant
wpa_supplicant -B -i interfacename -c /etc/wpa_supplicant/base.conf

# establish wifi data link
wpa_cli

  scan
  scan_results

  add_network
  set_network 0 ssid "MYSSID"
  set_network 0 psk "passphrase"
  enable_network 0

  # or for open wifi
  set_network 0 key_mgmt NONE
  enable_network 0

  save_config
  q


### for wifi and ethernet
# establish ip link
dhcpcd interface

# turn ntp time updates on
timedatectl set-ntp true


# if not done already, create drive partitions - http://www.tldp.org/HOWTO/IBM7248-HOWTO/cfdisk.html

# see also https://wiki.archlinux.org/index.php/Partitioning
# there can be only 4 'primary' partitions
# make the fourth 'extended' so it can contain further 'logical' partitions
# only primary and logical partitions are formatted

# / - root partition, will contain /usr (includes installed programs) - 20/25/40Gb - Bootable - Type: linux (83)
# /boot - contains boot kernel images, 100Mb for no extra kernel images, 200Mb safer for additional images (linux-ck, linux-lts, etc.) - Type: linux (83)
# /var - contains misc. including spools, logs, packages downloaded for installation. separate to avoid running out of space. 10Gb
# /home - contains user home folders, where media will be stored - size: remainder Type: linux (83)
# [swap] - swap partition - 1Gb - Type: linux swap (82)

# check drive partitions
lsblk

# format drive partitions
mkfs.ext4 /dev/[partition]
# repeat for each partition, excluding swap partition

# create swap partition
mkswap /dev/[swappartition]
swapon /dev/[swappartition]

# mount partitions
mount /dev/sda1 /mnt

mkdir /mnt/boot
mount /dev/sda2 /mnt/boot

mkdir /mnt/var
mount /dev/sda3 /mnt/var

mkdir /mnt/home
mount /dev/sda5 /mnt/home

# use geographically close arch package mirror
vim /etc/pacman.d/mirrorlist
# put selected mirror at top of the list. this is copied across in the next step

# bootstrap including the installation of pacman and a few extras
pacstrap /mnt base base-devel systemd-sysvcompat zsh vim git tmux htop atop inxi tree pm-utils pkgfile 

# generate file system configuration info
genfstab -p /mnt >> /mnt/etc/fstab

# chroot into new system
arch-chroot /mnt

Configuration

# set root user password
passwd

# add your own user account and set a password
useradd -m [USERNAME]
passwd [USERNAME]

# let wheel group use sudo for root permission
visudo
# uncomment %wheel      ALL=(ALL) ALL

## USERNAME HOST_NAME= NOPASSWD: /usr/bin/halt,/usr/bin/poweroff,/usr/bin/reboot,/usr/bin/pacman -Syu

# add user to wheel group for sudo/etc, access
gpasswd -a [USERNAME] wheel


# set a hostname
echo computer_name > /etc/hostname

# set timezone
ln -s /usr/share/zoneinfo/Europe/London /etc/localtime

# uncomment en_GB.UTF-8 or appropriate locale
vim /etc/locale.gen
/#en_GB
xZZ

# generate locale
locale-gen

# set locale conf
echo LANG=en_GB.UTF-8 > /etc/locale.conf

# set persistant console keymap and font preferences in /etc/vconsole.conf
vim /etc/vconsole.conf
i
KEYMAP=uk
[esc]ZZ

Kernel images

# uncomment COMPRESSION="xz" in /etc/mkinitcpio.conf
vim /etc/mkinitcpio.conf

# build boot image
mkinitcpio -p linux

# install long term support kernel
pacman -S linux-lts


# install bootloader: syslinux
pacman -S syslinux

# Arch specific autosetup
syslinux-install_update -i -a -m


# install bootloader: GRUB
# syslinux is easier to manage than GRUB
#pacman -S grub
#grub-install --recheck --target=i386-pc /dev/sdx

# allow for saving the last booted kernel, edit /etc/default/grub, set
#GRUB_DEFAULT=saved
# and add
#GRUB_SAVEDEFAULT=true

# generate/regenerate config file
#grub-mkconfig -o /boot/grub/grub.cfg


# reboot
# ctrl-alt-del is quickest

Network

pacman -S iotop bind-tools

# set network interface device names in relation to their MAC (media access control) address.
#vim /etc/udev/rules.d/10-network.rules

ip a

echo 'SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="$(cat /sys/class/net/**ethernetinterfacename**/address)", NAME="eth0"' > /etc/udev/rules.d/10.network.rules
echo 'SUBSYSTEM=="net", ACTION=="add", ATTR{address}=="$(cat /sys/class/net/**wifiinterfacename**/address)", NAME="wlan0"' >> /etc/udev/rules.d/10.network.rules

# enable dhcp
# multiple network management methods are available
# https://wiki.archlinux.org/index.php/Network_configuration#Dynamic_IP_address


# dhcpcd for all interfaces
systemctl enable dhcpcd
systemctl start dhcpcd


# netctl (arch dev grown systemd interface)
cp /etc/netctl/examples/ethernet-dhcp /etc/netctl
cp /etc/netctl/examples/wireless-wpa /etc/netctl
vim /etc/netctl/wireless-wpa
# change essid and key

# test netctl ethernet profile
netctl start ethernet-dhcp
ip a
ping bbc.co.uk
netctl stop ethernet-dhcp

# test netctl wireless-wpa profile
netctl start ethernet-dhcp
ip a
ping bbc.co.uk
netctl stop wireless-wpa

# make ethernet profile persistant
netctl enable ethernet-dhcp


# local DNS caching
pacman -S dnsmasq
systemctl enable dnsmasq

# either use straight DNS
# set dns resolver (router)
# see https://wiki.archlinux.org/index.php/Resolv.conf#Alternative_DNS_servers for a pair of public DNS server address to set
#vim /etc/resolv.conf

# or use encrypted DNS
# install dnscrypt
pacman -S dnscrypt-proxy

# setup dnsmasq config to listen to port 40 instead of 53
vim /etc/dnsmasq.conf

  no-resolv
  server=127.0.0.1#40
  listen-address=127.0.0.1
  proxy-dnssec

# make a network socket for dnscrypt to use port 40
systemctl edit dnscrypt-proxy.socket

  [Socket]
  ListenStream=
  ListenDatagram=
  ListenStream=127.0.0.1:40
  ListenDatagram=127.0.0.1:40

# create a unit file for dnscrypt with your chosen resolver
cp /usr/lib/systemd/system/dnscrypt-proxy.service /etc/systemd/system
vim /etc/systemd/system/dnscrypt-proxy.service

   # following [https://github.com/jedisct1/dnscrypt-proxy/blob/master/dnscrypt-resolvers.csv resolver] works
   dnscrypt.eu-dk

# make sure dnsmasq doesn't fall over due from dnscrypt not responding while it starts up
cp /usr/lib/systemd/system/dnsmasq.service /etc/systemd/system/multi-user.target.wants
vim /etc/systemd/system/multi-user.target.wants

   # edit to load After=dnscrypt-proxy.service
 
systemctl daemon-reload

# um.. could be above? edit file after auto copy rather than before?
systemctl enable dnscrypt-proxy.service

 vim /etc/resolv.conf

   nameserver 127.0.0.1

Video drivers

# find out graphics chipset
lspci | grep -e VGA -e 3D

# find gfx chipset drivers to install
pacman -Ss xf86-video | grep ##something##

# install gfx drivers
pacman -S xf86-video-ati # or whatever package

# hardware video acceleration, framebuffer support
pacman -S libva-mesa-driver xf86-video-fbdev

AUR and Git

# bootstrap AUR access with AUR helper yaourt
# https://www.digitalocean.com/community/tutorials/how-to-use-yaourt-to-easily-download-arch-linux-community-packages

echo "[archlinuxfr]" >> /etc/pacman.conf
echo "SigLevel = Never" >> /etc/pacman.conf
echo "Server = http://repo.archlinux.fr/$arch" >> /etc/pacman.conf

# install required basic commands
pacman -Sy yaourt

# now remove last three pacman.conf lines

# and make yourself non-root

X11

# if you want a graphical login, install a display manager # https://wiki.archlinux.org/index.php/display_manager
#yaourt -S --noconfirm lightdm lightdm-gtk-greeter
#systemctl enable lightdm.service


# install basic X11 related
yaourt -S --noconfirm xorg-server xorg-xinit xorg-xsetroot xorg-xrdb xorg-xset xorg-xev rxvt-unicode-fontspacing-noinc-vteclear-secondarywheel terminus-font urxvtcd


# set X11 keyboard layout
sudoedit /etc/X11/xorg.conf.d/20-keyboard.conf

 Section "InputClass"
    Identifier "keyboard"
    MatchIsKeyboard "yes"
    Option "XkbLayout" "gb"
    Option "XkbVariant" "nodeadkeys"
 EndSection


# install X11 window manager
# bspwm-git sxhkd-git - using i3 now.

yaourt -S --noconfirm i3-gaps


# install other X11 related
yaourt -S --noconfirm autocutsel xscreensaver compton dunst hsetroot feh dmenu pnmixer-git redshift unclutter radiotray lxappearance workrave xorg-xdpyinfo xdotool glxinfo systemd-numlockontty

#lightson-git - doesn't work?

# dlaunch chicken chicken-make
# https://github.com/AlxHnr/chicken-builder
# https://github.com/AlxHnr/dlaunch
# https://github.com/AlxHnr/dlaunch-plugins



# enable numlock for ttys and X
systemctl enable numLockOnTty
# doesn't work?

Misc

# install software
yaourt -S --noconfirm friendly-find links-g-directfb smartmontools dtrx

# set Git config
git config --global user.name USERNAME

git config --global user.email MAILADDRESS

#to do, add more..

SSH and dotfiles

# Generate [[SSH]] key
 ssh-keygen -t rsa -b 4096 -C "your_email@example.com" [https://help.github.com/articles/generating-a-new-ssh-key/]

eval "$(ssh-agent -s)"
# Ensure ssh-agent is enabled for this shell instance

ssh-add ~/.ssh/id_rsa
# Add your SSH key to the ssh-agent


# install; vcsh myrepos
yaourt -S --noconfirm  vcsh-git myrepos

# bootstrap vcsh
vcsh clone git://github.com/milkmiruku/vcsh_mr.git

# edit config.d symlinks to available.d
cd .config/mr/available.d
etc.

# mr bootstrap
mr up

### er, this should work. to switch to another system, maybe with just vcsh as the vcsh+mr combo is popular but I don't see the full point

=== Sync ===
to check

<pre>

yaourt -s syncthing syncthing-gtk syncthing-inotify

systemctl --user enable syncthing.service

syncthing-gtk
# to get api key

mkdir /etc/systemd/user/syncthing-inotify.service.d/

sudoedit /etc/systemd/user/syncthing-inotify.service.d/start.conf

  [Unit]
  ExecStart=
  ExecStart=/usr/bin/syncthing-inotify -logflags=0 -api="0M6ubcgtcy7KBLucu0jeXrgqB8U7YKp9"
  RuntimeDirectory=syncthing-inotify

  edit api

systemctl --user enable syncthing-inotify.service


sudo ln -s /home/milk/.zshrc /root/.zshrc
sudo ln -s /home/milk/.zsh /root/.zsh
sudo ln -s /home/milk/.vimrc /root/.vimrc
sudo ln -s /home/milk/.vim /root/.vim

Backup

to actually sort

See also Backup

yaourt -S pakbak-git

sudo mkdir -p /var/backup/pakbak

sudoedit /etc/pakbak.conf

 # edit backup folder to /var/backup/pakbak

systemctl enable pakbak

* tar -cjf pacman_database.tar.bz2 /var/lib/pacman/local


### Borg


# list intentionally installed packages
#pacman -Qqe



# Backup paths;
#
# /home/*
# /etc
# /var
# /boot
# /opt?
# etc..?

# Exclude
#/var/tmp

Virtual machine

yaourt -S linux-headers virtualbox virtualbox-host-dkms

sudoedit /etc/mkinitcpio.conf

  vboxdrv
    # add to end of modules (not hooks!)

sudo mkinitcpio -p linux

sudo modprobe vboxdrv

virtualbox

Laptop

# Set up ACPI
yaourt -S apci acpid vattery wicd wicd-gtk tlp

systemctl enable acpid.service
# https://wiki.archlinux.org/index.php/Acpid

sudoedit /etc/udev/rules.d/99-lowbat.rules

  # Suspend the system when battery level drops to 5% or lower
  SUBSYSTEM=="power_supply", ATTR{status}=="Discharging", ATTR{capacity}=="[0-5]", RUN+="/usr/bin/systemctl hibernate"

# add vattery and wicd-gkt --tray to .xinitrc

# Set up touchpad

yaourt -S xf86-input-libinput


# intel video chipset?
sv /etc/X11/xorg.conf

Section "Device"
    Identifier  "Card0"
    Driver      "intel"
    Option      "Backlight"  "intel_backlight"
EndSection


sv /etc/X11/xorg.conf.d/30-touchpad.conf

Section "InputClass"
        Identifier "MyTouchpad"
        MatchIsTouchpad "on"
        Driver "libinput"
        Option "Tapping" "on"
EndSection

Audio

# install some apps
yaourt -S jack2 pulseaudio-jack cadence-git carla-git helm-git 

slim (old)

i'm using lightdm now

yaourt -S slim slim-themes 

# make slim login desktop manager start automatically
systemctl enable slim.service

# edit slim config - default_user, focus_password, current_theme sleep-openbox
vi /etc/slim.conf

Config management

??? b0rken?

yaourt -S --noconfirm vcsh myrepos
ssh-keygen -t rsa -b 4096 -f ~/.ssh/github_rsa
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/github_rsa
< ~/.ssh/github_rsa.pub
# add new key on https://github.com/settings/ssh
ssh git@github.com
mkdir ~/.zsh/cache/$HOST
touch ~/.zsh/cache/$HOST/last-working-dir
# rm ~/.gtkrc-2.0
vcsh clone git://github.com/RichiH/vcsh_mr_template.git mr
mr up

???


Once all is working:

vcsh enter whateverrepo
  # do shit
exit
vcsh foreach add -u
  # add all tracked but uncomitted files in all repos

vcsh commit
  # commit all

vcsh push
  # push all repos

Old Ubuntu setup

ooold

hostname new.host.name

sudo apt-get update
sudo apt-get install tmux git
git clone git@github.com:milkmiruku/dottmux.git ~/.tmux
ln -s ~/.tmux/.tmux.conf ~/.tmux.conf
tmux

sudo apt-get install curl zsh ncdu htop tree mercurial build-essential gcc libc6-dev ncurses-dev

sudo git clone git@github.com:milkmiruku/zsh.git ~/.zsh && cd ~/.zsh && sudo git submodule init && sudo git submodule update
  # edit zshrc location config 
useradd -m -s /usr/bin/zsh milk
passwd milk
adduser milk sudo

sudo apt-get remove vim vim-runtime gvim
  # (disable distro vim. not possible with apt on ubuntu [2])
mkdir ~/src && mkdir ~/src/vim
hg clone https://vim.googlecode.com/hg/ ~/src/vim && cd ~/src/vim && ./configure --enable-pythoninterp=yes && make && sudo make install
cd

git clone git@github.com:milkmiruku/dotvim.git ~/.vim
ln -s ~/.vim/vimrc ~/.vimrc
mkdir ~/.vim/bundle
git clone git://github.com/Shougo/neobundle.vim ~/.vim/bundle/neobundle.vim
echo ':NeoBundleInstall' > ~/viminit.txt
echo ':q' >> ~/viminit.vim
vim -s ~/viminit.vim
rm ~/viminit.vim
git clone    vimproc ......

wget -O src/atop.tar.gz http://www.atoptool.nl/download/atop-2.0.2.tar.gz && cd ~/src && tar zxvf atop.tar.gz && cd ~/src/atop && ./configure && make && make install
cd

vim /etc/ssh/sshd_config
  # disable root, change port, etc.
ssh-keygen -t rsa
  # (for user and root?)


To sort: multiuser config. permissions? Or /usr/share/config/ ...

apt-get install php mariadb
apt-get install ruby rubygems
apt-get install python pip

backup

Silver


Possible

Tower or shuttle?


MiniATX