THEME: UNIX INSTALL

revision L54

Why Alpine?

Why did I decided to choose this particular OS distribution?..

Alpine Linux is good for remote education because everyone can choose a convenient way to get acquainted with this OS.

  1. Launch in the browser
  2. Build a virtual machine in VirtualBox
  3. Build a virtual machine in Hyper-V
  4. Build a virtual machine in VMware, Parallels, Bosh, qemu..
  5. Build a container in Docker
  6. Run MSYS2 (more like Arch, but quite good)
  7. Install on a flash drive, run your computer from a flash drive
  8. Make a multi-boot system (grub, ntldr, bootcamp)
  9. ..

INSTALLATION

1.1 Installing the operating system.

I will perform the installation for the 32-bit version, since the computer on which the installation is being done is very old:

$ sysctl -a | grep brand
machdep.cpu.brand_string: Intel(R) Core(TM)2 CPU T7400 @ 2.16GHz
machdep.cpu.brand: 0

I will install it on VirtualBox from the image here:

Google: alpine linux download

Link

Previous Releases

Older releases are found here.

  alpine-virt-3.13.1-x86.iso

There is nothing unusual about creating a VM:

During the installation process, you should log in to the live system as root without a password and run the installation script called setup-alpine and answer a number of questions `

localhost:~# setup-alpine
Available keyboard layouts:
af     br     dz     gr     it     lv     nl     si     uz
al     brai   ee     hr     jp     ma     no     sk     vn
am     by     epo    hu     ke     md     ph     sy
ara    ca     es     id     kg     me     pk     th
at     ch     fi     ie     kr     mk     pl     tj
az     cm     fo     il     kz     ml     pt     tm
ba     cn     fr     in     la     mm     ro     tr
bd     cz     gb     iq     latam  mt     rs     tw
be     de     ge     ir     lk     my     ru     ua
bg     dk     gh     is     lt     ng     se     us
Select keyboard layout [none]:
Enter system hostname (short form, e.g. 'foo') [localhost]: alpine-kn
Available interfaces are: eth0.
Enter '?' for help on bridges, bonding and vlans.
Which one do you want to initialize? (or '?' or 'done') [eth0]
Ip address for eth0? (or 'dhcp', 'none', '?') [172.18.68.132] dhcp
Do you want to do any manual network configuration? [no]
Changing password for root
New password:
Bad password: too short
Retype password:
passwd: password for root changed by root
Which timezone are you in? ('?' for list) [UTC]
HTTP/FTP proxy URL? (e.g. 'http://proxy:8080', or 'none') [none]
Which NTP client to run? ('busybox', 'openntpd', 'chrony' or 'none') [chrony] none
Available mirrors:
 1) dl-cdn.alpinelinux.org
 2) uk.alpinelinux.org
..
55) alpine.ccns.ncku.edu.tw

r) Add random from the above list
f) Detect and add fastest mirror from above list
e) Edit /etc/apk/repositories with text editor

Enter mirror number (1-55) or URL to add (or r/f/e/done) [1]:
Added mirror dl-cdn.alpinelinux.org
Updating repository indexes... done.
Which SSH server? ('openssh', 'dropbear' or 'none') [openssh]
Available disks are:
  sda   (34.4 GB Msft     Virtual Disk    )
  sr0   (1.1 GB Msft      Virtual CD/ROM  )
Which disk(s) would you like to use? (or '?' for help or 'none') [none] sda
The following disk is selected:
  sda   (34.4 GB Msft     Virtual Disk    )
How would you like to use it? ('sys', 'data', 'lvm' or '?' for help) [?] sys
100% ███████████████████████████████████████████████████████████
WARNING: The following disk(s) will be erased:
  sda   (34.4 GB Msft     Virtual Disk    )
WARNING: Erase the above disk(s) and continue? [y/N]: y
Creating file systems...
Installing system on /dev/sda3:
/mnt/boot is device /dev/sda1
100% ███████████████████████████████████████████████████████████
==> initramfs: creating /boot/initramfs-lts
/boot is device /dev/sda1

Installation is complete. Please reboot.
alpine-kn:~#

It remains to remove the boot disk and restart the virtual computer.

1.2 Configuring SSH

To establish an ssh connection, you need to open the port 22 on Alpine Linux and allow the login for root.

/etc/ssh/sshd_config

Port 22
..
AllowRootLogin yes

Then restart the sshd daemon:

rc-service sshd restart

If the rc-service command does not exist, install:

apk add openrc

On the host comuter, you may need to delete the file in the folder with bent keys, I have this one C:\Users\alien\.ssh\known_hosts

1.3 Installing Packages

Choose from what is offered in the repository

apk info | wc -l
apk add --no-cache git ed bash zsh 
apk add --no-cache perl python3
apk add --no-cache mandoc man-pages
apk add --no-cache musl-dev gcc

looking for answers to questions we may have about packages here:

  google: alpine packages

  https://pkgs.alpinelinux.org/contents

1.4 problems with networking

  1. Which virtual network card is installed in the Alpine VM? Checked the performance for:

VirtualBox 4: Intel PRO/1000 MT Desktop (82450OEM) VirtualBox 6: Intel PRO/1000 MT Desktop (82450OEM)

  1. Does the ping pass?
    alpine:~# ping 1.1.1.1 -c 2
    PING 1.1.1.1 (1.1.1.1): 56 data bytes
    64 bytes from 1.1.1.1: seq=0 ttl=58 time=9.557 ms
    64 bytes from 1.1.1.1: seq=1 ttl=58 time=7.533 ms
    
    --- 1.1.1.1 ping statistics ---
    2 packets transmitted, 2 packets received, 0% packet loss
    round-trip min/avg/max = 7.533/8.545/9.557 ms
    
  2. What does ip a say?
    alpine:~# ip a
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2. eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
        link/ether 00:15:5d:01:a0:17 brd ff:ff:ff:ff:ff:ff
        inet 172.23.90.157/20 scope global eth0
           valid_lft forever preferred_lft forever
        inet6 fe80::215:5dff:fe01:a017/64 scope link
           valid_lft forever preferred_lft forever
    
  3. Is there a DNS ?
    alpine:~# ping google.com -c 2
    PING google.com (216.58.207.238): 56 data bytes
    64 bytes from 216.58.207.238: seq=0 ttl=114 time=15.661 ms
    64 bytes from 216.58.207.238: seq=1 ttl=114 time=15.558 ms
    
    --- google.com ping statistics ---
    2 packets transmitted, 2 packets received, 0% packet loss
    round-trip min/avg/max = 15.558/15.609/15.661 ms
    
  4. View the contents of the file /etc/resolv.conf
    alpine:~# cat /etc/resolv.conf
    search mshome.net
    nameserver 192.168.1.1
    
  5. View the contents of the file ' /etc/apk/repositories`
alpine:~# cat /etc/apk/repositories
#/media/cdrom/apks
http://dl-cdn.alpinelinux.org/alpine/v3.13/main
#http://dl-cdn.alpinelinux.org/alpine/v3.13/community
#http://dl-cdn.alpinelinux.org/alpine/edge/main
#http://dl-cdn.alpinelinux.org/alpine/edge/community
#http://dl-cdn.alpinelinux.org/alpine/edge/testing

Note. On some 'Debian' virtual machines running on Windows laptops and networking via Wi-Fi, it was only possible to contact the host through the second network interface, which was located in the virtual network 'Host Only' (VirtualBox). The details of such case are shown on picture below:

http://kirill.tpt.edu.ee/html/image/HostOnly.png

In case of Alpine, the network interfaces are configured here:

alpine:~# cat /etc/network/interfaces
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
        hostname alpine-kn
auto eth1
iface eth1 inet static
        address 192.168.1.150/24
        gateway 192.168.1.1
  1. Test the already working configuration by installing and configuring the machine in VirtualBox by just double-click on (.ova) file, took here:

(link is down) http://kirill.tpt.edu.ee/big/Alpine-x86-64-L35.ova

1.5 Installing from source

$ touch kn-13.c
$ ed kn-13.c
a
#include <stdio.h>
int main() { 
  printf("almost there..\n");
}
.
w
q

I'm writing/copy-pasting my source code in ed. if ed responds with ?, it means it does not understood me, does not found requested piece of text, etc.

Now let'screate a binary and install it.

$ bash
$ gcc kn-13.c -o kn-13
$ echo $PATH
/usr/local/sbin;..
$ mv kn-13 /usr/local/bin
$ kn-13
almost there..
$

1.6 Install with make

A Simple Makefile Tutorial. The original article is here:

http://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/

REFERENCES

  1. Alpine Linux Install: https://en.wikipedia.org/wiki/Alpine_Linux