Lav din egen Linux Live ISO

Hvordan man laver sin egen Live ISO

Der er mange formål – et af dem jeg pusler med er at lave en et rescue miljø baseret på Arch Linux

Inspirerende artikler og how-to (på engelsk)

Manjaro wiki

  • https://wiki.manjaro.org/Build_Manjaro_ISOs_with_buildiso
  • https://wiki.manjaro.org/Build_Manjaro_Net-Install
  • https://wiki.manjaro.org/Build_KDE_Minimal
  • https://wiki.manjaro.org/Buildiso_with_AUR_packages:_Using_buildpkg

Arch wiki

  • https://wiki.archlinux.org/index.php/archiso
  • https://wiki.archlinux.org/index.php/Installing_Arch_Linux_on_a_USB_key
  • https://wiki.archlinux.org/index.php/USB_flash_installation_media
  • https://wiki.archlinux.org/index.php/Multiboot_USB_drive

Ren Arch installation

Using another mans script is not the Arch way

Grunden er enkel – hvis det ikke virker som forventet – skal du vide hvor du tastede forkert eller hvad du har glemt.

Og man skal ikke springe over hvor gærdet er lavest. Man må godt hæve overliggeren for sig selv en gang i mellem.

Men lige præcist installation af computerens operativ system er et trivielt antal gentagne trin og her er en installationsramme på sin plads.

  • Architect Linux
  • Arch-Anywhere
  • Manjaro
  • Antergos

Grundlæggende linux installation – trin for trin

Arch Linux i Virtualbox

Det antages at du ved hvordan man laver en virtuel maskine i VirtualBox og ved hvordan man tilknytter en iso fil til opstart.
Vigtigt! Alle de viste kommander er i den virtuelle computer som root. # indikerer root og skal ikke medtages som en del af kommandoen.

Hent en iso på https://www.archlinux.org/download/. Tilknyt iso til cd drev i virtuel computer og start den.

Sæt dansk tastatur

# loadkeys dk

Sæt ur

# timedatectl set-ntp true

Partitioner

# cfdisk /dev/sdX

opret dos filtabel og partition for boot (512M), partition for root og evt også en partition for home

Formattering

# mkfs.vfat /dev/sda1
# mkfs.ext4 /dev/sda2

Hvis du har en partition for home formatteres denne på samme måde som root partition

Montering

root partition monteres altid først

# mount /dev/sda1 /mnt/

opret mappe til montering af boot

# mkdir /mnt/boot

monter boot

# mount /dev/sda2 /mnt/boot

hvis du har en partition for home er det på samme måde – opret mappen home i din monterede root partition og monter home partition

Installation af base

# pacstrap -i /mnt base

Monterings valg til fstab

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

Opsætning af det endelige system i chroot miljø

# arch-chroot /mnt

Sæt tidszone

# ln -s /usr/share/zoneinfo/Europe/Copenhagen /etc/localtime

Sæt hardware ur

# hwclock --systohc

System sprog

# nano /etc/locale.gen

rediger linjen med ‘da_DK.UTF-8 UTF-8’ ved at fjerne # og gem med F2.

Generering af system sprog

# locale-gen

X tastatur

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

Terminal tastatur

# echo KEYMAP=dk > /etc/vconsole.conf

Sæt computer navn

ditcomputernavn erstattes med et relevant computer navn

# echo ditcomputernavn > /etc/hostname

Sæt samme computernavn i hosts

ditcomputernavn erstattes med dit computernavn jf. foregående trin

# echo '127.0.1.1 ditcomputernavn.localdomain {hostname];' >> /etc/hosts

Aktiver dhcp service ved opstart

# systemctl enable dhcpcd

Sæt root password

# passwd

Opret bruger

ditbrugernavn erstattes med et relevant brugernavn

# useradd -m ditbrugernavn

Sæt bruger password

ditbrugernavn erstattes med dit brugernavn jf. foregående trin

# passwd ditbrugernavn

Installer grub bootloader

# pacman -S grub

Opsæt grub bootloader

# grub-install --target=i386-pc /dev/sdx

Opret grub config

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

Afslut

# exit

Afmonter partitioner

# umount -R /mnt

Genstart

Tast F12 og vælg harddisk – fjern cd

# reboot

Login i Arch Linux

Ajourføring pakke database

# pacman -Syyu

Installer xorg og skærm driver

# pacman -S xorg-server xorg-apps xorg-server-utils xf86-video-fbdev

Grafisk brugerflade aka desktop

Her er valgt xfce men det kunne være gnome, kde eller hvad du nu foretrækker

# pacman -S xfce4 xfce4-goodies numix-themes

Grafisk login – display manager

# pacman -S lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings

Aktiver ved opstart

# systemctl enable lightdm

Start display manager og login

# systemctl start lightdm

Arch Linux – reflector util

Opsætning af mirrorlist

# pacman -Syu reflector

15 hurtigste mirrors af 30 senest synkroniserede
Sorteret efter download hastighed
Gemt til /etc/pacman.d/mirrorlist

# reflector --verbose -l 30 -f 15 --sort rate --save /etc/pacman.d/mirrorlist

Linux: XDMCP summary

XDMCP

locally – and locally only

Installer XDM

Archlinux

# pacman -S xorg-xdm

Ubuntu

# apt-get install xdm

When installing select xdm as default login manager

Edit as root

# nano /etc/X11/xdm/Xaccess
## remove remark (#) from the line reading
#*        #any host can get a login window

# nano /etc/X11/xdm/Xservers
##add remark (#) for the line - probably last - reading
:0 local ..(rest omitted)

# nano /etc/X11/xdm/xdm-config
## add remark (!) for the line - probably last - reading
DisplayManager.requestPort:    0

Arch: sshd – authorized_keys

Debugging: No supported authentication methods available

# systemctl stop sshd && systemctl disable sshd
# /usr/bin/sshd -d

If you want to use your public keyfile from puttygen in the ssh-authorized_keys file you are looking for trouble.

[root@tsa]# /usr/bin/sshd -d
debug1: sshd version OpenSSH_6.7, OpenSSL 1.0.1l 15 Jan 2015
...
debug1: Bind to port 22 on 0.0.0.0.
Server listening on 0.0.0.0 port 22.    
Failed publickey for root from 192.168.1.100 port 49393 ssh2: RSA f3:d4:90:c1:95:4d:b5:ce:9e:db:56:4a:84:79:15:43
Received disconnect from 192.168.1.100: 14: No supported authentication methods available [preauth]
...
debug1: do_cleanup
debug1: Killing privsep child 9921

Here is the reason

# cat .ssh/authorized_keys
---- BEGIN SSH2 PUBLIC KEY ----
Comment: "rsa-key-20150125"
AAAAB3NzaC1yc2EAAAABJQAAAQEAsKx3JfVH3D9aMdKTlwmsG6osXs3WN/aGXcAD
zKw0Wy8Bbou+/VWwXL+TR0IGIFoTSN6KYpw0K4bUCQWopdWlQAbV4+roe7gHcxzm
HLLPQDQvqAt7FZsv5u666/DDzpGbwwGniOARdBPEyWhVkKx1r5DE6jyDVNBgSDWh
eAXicW43ytbIZHx+xMcCb6zQ2U08UiOw8oUW6N2mUKJ/Shgk19WM4DqsHl8Yq8P5
61g109b2OdLJQw4MoKdjvJZFkf+g170goUo/mT8HesEYlEIHSpliwWLmb+kqv0lI
neYanV9cxiqKmeFxs4UgomCURobxGx3p2iNtaCHmRNTJHvIeSQ==
---- END SSH2 PUBLIC KEY ----

This is a no-go – not usable – authorized_keys does not contain LF. Copy/paste from inside puttygen to ssh-authorized_keys

# cat .ssh/autorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAsKx3JfVH3D9aMdKTlwmsG6osXs3WN/aGXcADzKw0Wy8Bbou+/VWwXL+TR0IGIFoTSN6KYpw0K4bUCQWopdWlQAbV4+roe7gHcxzmHLLPQDQvqAt7FZsv5u666/DDzpGbwwGniOARdBPEyWhVkKx1r5DE6jyDVNBgSDWheAXicW43ytbIZHx+xMcCb6zQ2U08UiOw8oUW6N2mUKJ/Shgk19WM4DqsHl8Yq8P561g109b2OdLJQw4MoKdjvJZFkf+g170goUo/mT8HesEYlEIHSpliwWLmb+kqv0lIneYanV9cxiqKmeFxs4UgomCURobxGx3p2iNtaCHmRNTJHvIeSQ== rsa-key-20150125

Output from /usr/bin/sshd -d

[root@tsa]# /usr/bin/sshd -d
debug1: sshd version OpenSSH_6.7, OpenSSL 1.0.1l 15 Jan 2015
debug1: Bind to port 22 on 0.0.0.0.
Server listening on 0.0.0.0 port 22.
...
debug1: trying public key file /root/.ssh/authorized_keys
debug1: fd 4 clearing O_NONBLOCK
debug1: matching key found: file /root/.ssh/authorized_keys, line 1 RSA f3:d4:90:c1:95:4d:b5:ce:9e:db:56:4a:84:79:15:43
...
debug1: trying public key file /root/.ssh/authorized_keys
debug1: fd 4 clearing O_NONBLOCK
debug1: matching key found: file /root/.ssh/authorized_keys, line 1 RSA f3:d4:90:c1:95:4d:b5:ce:9e:db:56:4a:84:79:15:43
debug1: restore_uid: 0/0
Accepted publickey for root from 192.168.1.100 port 49421 ssh2: RSA f3:d4:90:c1:95:4d:b5:ce:9e:db:56:4a:84:79:15:43
debug1: monitor_child_preauth: root has been authenticated by privileged process
...
Starting session: shell on pts/1 for fh from 192.168.1.100 port 49421
...
Closing connection to 192.168.1.100 port 49421

That’s better

# systemctl start sshd && systemctl enable sshd

Arch: My preferred packages

My preferred packages

archlinux

base 
base-devel

boot

gptfdisk
syslinux

workstation

xf86-video-intel
xorg-server 
xorg-server-utils 
xorg-xinit 
xorg-apps 
xorg-twm 
xorg-xclock 
xterm
xorg-xdm
xorg-server-xephyr
xfce4 
xfce4-goodies 
xfce4-settings
lightdm
firefox
chromium
abs
xfce4-whiskermenu-plugin
yajl   

Xorg :0 -configure

Keyring opdate

haveged
systemctl start haveged
systemctl enable haveged

pacman-key --init

antergos.mirrorlist
kopier /etc/pacman.d/mirrorlist => antergos.mirrorlist
edit antergos.mirrorlist

Server = http://mirrors.antergos.com/$repo/$arch

edit /etc/pacman.conf

[antergos]
SigLevel = TrustAll
Include = /etc/pacman.d/antergos.mirrorlist

antergos packages

numix-themes
numix-frost-themes
numix-icon-theme
numix-icon-theme-square

synaptics touch thinkpad labtop

xf86-input-synaptics

frosting

Indstillinger => Udseende => Numix Frost (Light)
Indstillinger => Udseende => Ikoner => Numix-Square
Indstillinger => Vindueshåndtering => Stil => Numix Frost (Light)
Skrivebordsbaggrund => noget andet end xfce-musen :)

download

mozilla firefox developer edition
oracle java
jetbrains webstorm
syntevo smartgit
aur package-query
aur yaourt

build and install package-query

makepkg -i

build and install yaourt

makepkg -i

install pacmatic

yaourt pacmatic

install virtualbox

pacmatic virtualbox virtualbox-guest-iso

Arch: Network Setup

Network setup

# ip addr

nic

# ip link set dev enp0s25 up

the easy way dhcp

# systemctl enable dhcpcd.service
# systemctl start dhcpcd.service

the manual setup

# systemctl stop dhcpcd.service
# systemctl disable dhcpcd.service
# ip addr add 192.168.x.y/24 broadcast 192.168.x.255 dev enp0s25
# ip route add via 192.168.x.1

remember dns

# nano /etc/resolv.conf                                          
nameserver v.x.y.z
search example.com

Arch: Install using TFTP

Local pxe installation

Remember – every action by YOU is YOUR responsibility – not mine.

Recommended reading

The following is my preferences

  • and therefore might not suit you – so change what ever you like, to fit your needs.

The approach is more than average geeky, and requires a local server to serve pxe-boot and fast internet connection, but you will benefit by getting an up2date killer-installation just as you prefer it.

You need at machine to serve as TFTP server. If you have Synology NAS you are in luck.

The machine you want to install must be able to boot from the network. This is a setting in BIOS.

When booted you must select an installation mirror. It makes sense to select a mirror in your neighborhood – or at least in your country

http://mirrors.dotsrc.org/archlinux/$repo/os/$arch

Above mirror is Ålborg University in Denmark so this works for me.

Wait while 250MB data is fetched …

Keyboard layout

# loadkeys dk

Get disk ready

remember backup – all my files is located at network-shares so this works for me.

# sgdisk --zap-all /dev/sdc
# reboot

The terminal font can be a pain (this one lacks danish accent chars æøå) but is good on my tired eyes

# setfont Lat2-Terminus16

This one has support for above mentioned accent chars

# setfont cp865-8x16

Partitioning

I run from a PCIe card with mSATA disk raid so my bootdrive is not the common choice. You will need to modify according to your actual setup

# cgdisk /dev/sdc

    sdc1 type 8200 name root filesystem ext4
    sdc2 type 8302 name home filesystem ext4
    sdc3 type 8300 name boot filesystem ext2

Create filesystems and mount them

# mkfs.ext4 /dev/sdc1
# mkfs.ext4 /dev/sdc2 
# mkfs.ext2 /dev/sdc3
# mount /dev/sdc1 /mnt
# mkdir /mnt/home
# mkdir /mnt/boot
# mount /dev/sdc2 /mnt/home
# mount /dev/sdc3 /mnt/boot
# lsblk -f

Base installation

# pacman -Syy                                                 
# pacstrap /mnt base base-devel
# genfstab -U -p /mnt >> /mnt/etc/fstab
# cat /mnt/etc/fstab
# arch-chroot /mnt /bin/bash

Locale

# echo LANG=da_DK.UTF-8 > /etc/locale.conf
# echo da_DK.UTF-8 UTF-8 > /etc/locale.gen
# locale-gen                                                  
# echo KEYMAP=dk > /etc/vconsole.conf            
# echo FONT=Lat2-Terminus16 >> /etc/vconsole.conf
# ln -s /usr/share/zoneinfo/Europe/Copenhagen /etc/localtime  
# hwclock --systohc --utc

Network

# echo ts1 > /etc/hostname
# nano /etc/hosts

    127.0.0.1         localhost.localdomain    localhost
    127.0.1.1         sfinx
    192.168.10.200    sfinx.uex.lan sfinx

Info

# ip link
# ip addr

DHCP

# systemctl enable            

Boot-loader

# pacman -S gptfdisk syslinux
# syslinux-install_update -iam                      
# nano /boot/syslinux/syslinux.cfg

    ...
    LABEL arch
        ...
        APPEND root=/dev/sdc3 rw
        ...
    LABEL archfallback
        ...
        APPEND root=/dev/sdc3 rw
        ...

The raisin in the hotdog-end

# passwd                                            
# exit
# umount -R /mnt
# reboot

References

Beginners’ guide
Installation guide
General recommendations

Arch: XDMCP

XDMCP desktop over LAN

Install XDM, LightDM and a greeter

$ sudo pacman -S xorg-xdm lightdm lightdm-gtk-greeter

/etc/X11/xdm/Xaccess => remove # at beginning of line

#*                  #any host can get a login window    

/etc/X11/xdm/Xservers => insert # at beginning of line

:0 local /usr/bin/X :0

/etc/X11/xdm/xdm-config => insert ! at beginning of line

DisplayManager.requestPort: 0

/etc/lightdm/lightdm.conf => edit section [XDMCPServer]

[XDMCPServer]
enabled=true
port=177
#key=

su

$ su -l root
# xdm -config /etc/X11/xdm/xdm-config
# exit

Activate and start LightDM

$ sudo systemctl enable lightdm
$ sudo systemctl start lightdm

Install Xming on Windows.

I recommend the donation approach. These versions are much-much than community version.