Box

From Things and Stuff Wiki
Revision as of 18:15, 26 April 2016 by Milk (talk | contribs) (→‎to sort)
Jump to navigation Jump to search


A box, yer computer, physical and abstract box.

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

Arch Linux, bspwm, sxhkd, dmenu_run.pl, xfce4-panel, urxvt(c), zsh, vim

Setup, format, bootstrap, chroot

# arch linux install from archiso usb drive
# requires network connectivity, possibly wired, to be available

# 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

# turn ntp time updates on
timedatectl set-ntp true

# create drive partitions
[http://www.tldp.org/HOWTO/IBM7248-HOWTO/cfdisk.html cfdisk]

# 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/25Gb - 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 and format drive partitions
lsblk

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

# 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
vi /etc/pacman.d/mirrorlist
# put selected mirror at top of the list. this is copied across in the next step

# install pacman and bootstrap
pacstrap /mnt base bade-devel vim

# 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

Images

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

# build boot images
mkinitcpio -p linux

# install lts kernel
pacman -S linux-lts

# install a bootloader. tried syslinux before, trying grub now. first impression, syslinux is cleaner.
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

# syslinux route instead; will require some *.c32 symbolic links


# install wpa_supplicant for later wifi setup
pacman -S wpa_supplicant

# reboot
# ctrl-alt-del is quickest

Network

# set network device names in relation to their MAC
vim /etc/udev/rules.d/10-network.rules

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
# or such

# setup 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


(
# set dns resolver (router)
vim /etc/resolv.conf

/

# install dnscrypt
pacman -S dnsmasq dnsmdnscrypt-proxy

# setup dnsmasq

 vim /etc/dnsmasq.conf

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

 systemctl edit dnscrypt-proxy.socket

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

 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
 
 systemctl daemon-reload
 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 # etc.

# hardware video acceleration
pacman -S libva-mesa-driver 

Various software

# 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

# install a display manager # https://wiki.archlinux.org/index.php/display_manager
yaourt -S mdm-display-manager
systemctl enable mdm.service


# install various apps
yaourt -S pm-utils zsh openssh tmux links-g-directfb htop atop tree friendly-find

# install x related

xorg-server xorg-xinit xorg-xsetroot xorg-xrdb xorg-xset udiskie bspwm-git xev sxhkd-git rxvt-unicode-fontspacing-noinc-vteclear-secondarywheel terminus-font autocutsel compton dunst feh dmenu xfce4-panel pnmixer-git redshift unclutter radiotray lxappearance xscreensaver lightson-git workrave xdpyinfo systemd-numlockontty

# enable numlock for ttys and X
systemctl enable numLockOnTty

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

to sort

# slim slim-themes 
# mdm seems better, fork of gdm, animated images



# 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


git config --global user.name USERNAME

git config --global user.email MAILADDRESS

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

Laptop

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

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

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

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

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 [1])
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

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

Install

  • archinstaller - Automated installation script for arch linux written in bash. It works similar to preseeding the debian installer d-i.
  • FAI is a non-interactive system to install, customize and manage Linux systems and software configurations on computers as well as virtual machines and chroot environments, from small networks to large-scale infrastructures like clusters and cloud environments. It's a tool for unattended mass deployment of Linux. You can take one or more virgin PC's, turn on the power, and after a few minutes, the systems are installed, and completely configured to your exact needs, without any interaction necessary.

Backup

See also Backup

Borg

pacman -Qqe
  # list intentionally installed packages

Backup paths;

/home/*
/etc
/var
/boot
etc..