J6BFj

            Learning path and method of survival:

            How much one must know to survive?
            Depends on people you surrounded yourself with --
            no less than each of them knows, but not like this:
            "Make things as simple as possible but not simpler",
            you know? Unix is a philosophy, religion, worldview,
            whatever.. but Einstein's saying was about physics,
            real sciences.

            So hey, feel the difference..

## ARCH LINUX INSTALL AS VIRTUALBOX GUEST.

1. Download ISO (Google for archlinux-2021.01.01-x86_64.iso)

2. Compose VirtualBox Machine and boot from CD. Choose

     Boot Arch Linux (x86_64)

3. Check guest IP address

4. allow ssh root access from outside world.

  # cat /etc/ssh/sshd_config | grep -P '^Port|^PermitR'
  Port 22
  PermitRootLogin yes
  
  Set root password:
   
  # passwd
  
  Start sshd service

  # systemctl start sshd.service
  
5. Login via PuTTY as root

  # fdisk /dev/sda
  Command (m for help): p
  Disk /dev/sda: 32 GiB, 34359738368 bytes, 67108864 sectors
  Disk model: VBOX HARDDISK
  Units: sectors of 1 * 512 = 512 bytes
  Sector size (logical/physical): 512 bytes / 512 bytes
  I/O size (minimum/optimal): 512 bytes / 512 bytes
  Disklabel type: dos
  ..
  Device     Boot Start      End  Sectors Size Id Type
  /dev/sda1        2048 67103504 67101457  32G 83 Linux

  # mkfs.ext4 /dev/sda1
  ..
  Proceed anyway? (y,N) y
  # mount /dev/sda1 /mnt

Packages to be installed must be downloaded from mirror servers, which are defined in /etc/pacman.d/mirrorlist. On the live system, all mirrors are enabled, and sorted by their synchronization status and speed at the time the installation image was created. 

NB! Please remove broken mirrors from live system.*1

  # vi /etc/pacman.d/mirrorlist
  # mount /dev/sda1 /mnt
  # pacstrap /mnt base base-devel linux linux-firmware 
  ~300MB download
  # genfstab -U /mnt >> /mnt/etc/fstab

  # arch-chroot /mnt

  # ln -sf /usr/share/zoneinfo/Europe/Tallinn /etc/localtime
  # hwclock --systohc --utc

  # /run/initramfs/usr/bin/vi /etc/locale.gen
  (uncomment en_US.UTF-8)
  # locale-gen
  Generating locales...
  en_US.UTF-8... done
  Generation complete.
  # echo LANG=en_US.UTF-8 > /etc/locale.conf
  # export LANG=en_US.UTF-8
  
  # pacman -Syu grub
  # grub-install /dev/sda
  # grub-mkconfig -o /boot/grub/grub.cfg

6. Create user,
   Create home folder for this user,
   add user to /etc/sudoers

  # useradd opilane
  # passwd opilane
  # mkdir -p /home/opilane
  # cat /etc/sudoers | grep -P '^[a-z ]+?ALL=\(ALL\) ALL'
  root ALL=(ALL) ALL
  opilane ALL=(ALL) ALL

7. Network

  https://www.ostechnix.com
    /configure-static-dynamic-ip-address-arch-linux/

ip link
..enp0s3

cat /etc/systemd/network/enp0s3.network
```
[Match]
Name=enp0s3
[Network]
DHCP=yes
```
cat /etc/hosts
```
127.0.0.1   localhost
127.0.1.1   buster

# The following lines are desirable for IPv6 capable hosts
::1         localhost ip6-localhost ip6-loopback
ff02::1     ip6-allnodes
ff02::2     ip6-allrouters
```
cat /etc/hostname
```
ABOX
```
cat /etc/resolv.conf
```
nameserver 8.8.8.8
```
Activate network for the next boot (from HD)

  # systemctl enable systemd-networkd

8. Ssh

  # pacman -Sy
  # pacman -S openssh
  
  in /etc/ssh/sshd_config open ssh port, so you should see
  
  # cat /etc/ssh/sshd_config | grep ^Port
  Port 22
  # systemctl enable sshd
  # systemctl start sshd
  
9. exit arch-chroot and shutdown.

  # exit
  # shutdown -P now
  
or

  # poweroff

Remove CD and reboot. Install Desktop:

  https://www.debugpoint.com/2020/12/gnome-arch-linux-install/

## LINKS

Trusted source:

  0. https://wiki.archlinux.org/index.php/Installation_guide#Installation

Other sources (may have problems..)
  
  1. https://itsfoss.com/install-arch-linux/
  2. https://wiki.archlinux.org/index.php/Netboot
  3. https://www.raspberrypi.org/forums/viewtopic.php?t=172010
  4. https://www.ostechnix.com
       /configure-static-dynamic-ip-address-arch-linux/
  5. https://linuxhint.com/arch_linux_ssh_server/


## ANNEX A.  PACMAN

Pacman
------

  https://www.digitalocean.com
    /community/tutorials/how-to-use-arch-linux-package-management

  sudo pacman -Syy              # update like apt-get update in Debian
  sudo pacman -Su               # upgrade like apt-get upgrade in Debian
  sudo pacman -Ss <package>     # search repos

  sudo pacman -Syu <package>    # install
  sudo pacman -Sw <package>     # download
  sudo pacman -U <package_path> # install downloaded

  sudo pacman -Syyu             # adopt the new mirrorlist
  sudo pacman -Rs <package>     # remove with dependencies
  sudo pacman -R <package>      # remove only
  sudo pacman -Scc              # clean the cache

  pacman -Qs linux    # list installed (pacsearch linux)
  pacman -Qi          # information about an installed package.
  pacman -Ql          # lists all files associated with a package.

Cleanup:

  $ sudo pacman -Scc
  $ dd if=/dev/zero of=biig; rm biig
  
  
## ANNEX B.  Installing Powershell on Arch Linux

  https://ephos.github.io/posts/2019-10-13-PowerShell-Previews-on-Arch
  
  # cd ~
  # sudo pacman -Syu git
  # git clone https://aur.archlinux.org/powershell-preview-bin.git
  # cd powershell-preview-bin/
  # cat ./PKGBUILD
  # sudo pacman -Syu libunwind openssl-1.0
  # makepkg -i
  # pwsh-preview


## ANNEX C. Installing Arch Linux with LVM

Posted in Tutorials  and tagged Arch, Linux on May 9, 2016

  https://gilyes.com/Installing-Arch-Linux-with-LVM/

Recently I decided to give Arch Linux a try. This is a quick overview of the steps I followed to get up and running on an old Thinkpad T400.

This is mostly a reference for myself, but hopefully opilane will be somewhat useful for someone out there as well. It is mainly based on the excellent ArchWiki with additional stuff from here and there.

Getting Arch

This guide assumes you already have a bootable Arch installation media. See here on how to get opilane.

Installation

Start with booting into the Arch live CD/USB.

Connecting to Wi-Fi

Internet connection will be required during install, so let’s do that as the first step (for wired connection see e.g. here).

wifi-menu

Select wireless network, type in the password and if everything went well you should now be connected to the Internet.

Update the system clock

  timedatectl set-ntp true

Set up LVM

To view details about the available storage devices:

  lsblk

Determine the drive(s)/partition(s) you want to use. In this example I am creating a single LVM physical volume using a full drive.

First, create a Linux LVM partition spanning the whole disk:

  fdisk /dev/sdX
  n (to add a new partition)
  p (for primary partition)
  1 (default partition number)
  (accept default start)
  (accept default end)
  t (to change partition type)
  8e (for LVM partition when using MBR)
  i (to verify)
  w (save and quit)

Create an LVM physical volume on the new partition:

  pvcreate /dev/sdX1

Create a volume group:

  vgcreate vg1 /dev/sdX1

Create logical volumes for boot, root, swap and home.

  lvcreate -L 500M -n boot vg1
  lvcreate -L 6G -n root vg1
  lvcreate -L 3G -n swap vg1
  lvcreate -l 100%FREE -n home vg1

Note: instead of -l 100%FREE you may want to leave some unused space for snapshots.

Format the logical volumes:

  mkfs.ext4 /dev/vg1/boot
  mkfs.ext4 /dev/vg1/root
  mkfs.ext4 /dev/vg1/home
  mkswap /dev/vg1/swap
  swapon /dev/vg1/swap

Then finally mount them under the live system’s /mnt:

  mount /dev/vg1/root /mnt
  mkdir /mnt/boot
  mount /dev/vg1/boot /mnt/boot
  mkdir /mnt/home
  mount /dev/vg1/home /mnt/home

Install base packages

  pacstrap /mnt base base-devel

Generate fstab

  genfstab -U /mnt >> /mnt/etc/fstab

Change root to new system

  arch-chroot /mnt /bin/bash

Set up locale

In /etc/locale.gen uncomment en_US.UTF-8 UTF-8 or whatever else locale you need

Generate the new locale(s):

  locale-gen

Create /etc/locale.conf:

  # /etc/locale.conf
  LANG=en_US.UTF-8

Setup time

Set time zone:

  tzselect
  ln -s /usr/share/zoneinfo/<Zone>/<SubZone> /etc/localtime
  ln -sf /usr/share/zoneinfo/Europe/Tallinn /etc/localtime

Adjust the time skew, and set the time standard to UTC:

  hwclock --systohc --utc

Update initramfs

Add LVM2 hook to /etc/mkinitcpio.conf:

  # /etc/mkinitcpio.conf
  HOOKS="...lvm2 filesystems..."

For example

  HOOKS=(base udev autodetect modconf block lvm2 filesystems keyboard fsck)

Re-generate the initramfs image:

  mkinitcpio -p linux

Bootloader

In this example we are using MBR with grub. Install grub:

  pacman -S grub

Install the bootloader to the drive Arch was installed to:

  grub-install --target=i386-pc /dev/sdX

i386-pc target seems to be fine for non efi (BIOS, Virtualbox)

Generate configuration file:

  grub-mkconfig -o /boot/grub/grub.cfg

Configure network

Set hostname:

  # /etc/hostname
  myhostname

Install packages for wireless support:

  pacman -S iw wpa_supplicant dialog

Set root password

  passwd

## Reboot to new system

Exit the chroot environment, unmount partitions, remove live media and reboot:

  exit
  umount -R /mnt
  reboot

Setup automatic Wi-Fi connection

  wifi-menu -o
  netctl start profileName
  netctl enable profileName

Install desktop environment

For desktop environment let’s install Cinnamon. First, X:

  pacman -S xorg-server xorg-xinit xorg-utils xorg-server-utils mesa xorg-twm xterm

Touchpad support:

  pacman -S xf86-input-synaptics

Detemine the video card:

  lspci | grep VGA

Search for video driver packages:

  pacman –Ss | grep xf86-video

In this machine I have an Intel integrated video card, so installing driver for that:

  pacman -S xf86-video-intel

Install Cinnamon:

  pacman -S cinnamon nemo-fileroller

Install and start display manager:

  pacman –S gdm
  systemctl enable gdm
  systemctl start gdm

Note: On password entry click the gear icon and select Cinnamon.

And done, a barebones Arch Linux installation with a desktop environment is now complete.

## Resources

  1. https://gilyes.com/Installing-Arch-Linux-with-LVM/

  2. https://wiki.archlinux.org/index.php/Beginners%27_guide

  3. http://blog.ataboydesign.com/2012/08/29/installing-arch-linux-on-lvm

  4. https://www.linuxserver.io/index.php/2014/01/18/installing-arch-linux-with-root-on-an-lvm

  5. https://wiki.archlinux.org/index.php/LVM

  6. http://www.tecmint.com/install-cinnamon-desktop-in-arch-linux

  7. https://wiki.archlinux.org/index.php/netctl#Automatic_operation
