Linux installation

In case of installation on VM make the disk image

qemu-img create -f qcow2 debian.qcow2 16G

Other format option

qemu-img create -f raw debian.raw 16G
-drive file=disk.raw,format=raw

Start the VM with bios

qemu-system-x86_64 -bios OVMF.fd -m 1G -drive file=debian.qcow2,format=qcow2 \
                   -cdrom debian-12.2.0-amd64-netinst.iso

Go through the installation process and then power off the VM

Start VM with command

qemu-system-x86_64 -bios OVMF.fd -m 1G -smp 6 \
                   -net user,hostfwd=tcp::2222-:22 -net nic \
                   -drive file=debian.qcow2,format=qcow2

Prepare install media on macOS

Insert and unmount an USB stick

diskutil unmount /dev/disk2s1

Here is how we can list all the disks attached to the system

diskutil list

Writing image to the USB device (notice that we do not write to a partition)

sudo dd if=archlinux-2021.01.01-x86_64.iso of=/dev/disk2

then flush the data by ejecting the drive

sudo sync
diskutil eject /dev/disk2

Debian sid

This is the Debian setup where most of the examples shown on the website should work.

Download links:

During installation select SSH server, standard system utilities and no desktop

Allowing login root user from the network

This is our testing installation, so we do not care about security, but easiness and convenience.

nano /etc/ssh/sshd_config

Ctrl-o Ctrl-x

Put this line in the file

PermitRootLogin yes

and then

systemctl restart sshd

From now on you can log in to the VM using ssh connection

ssh -p 2222 user@localhost

Making it the sid

/etc/apt/sources.list

deb https://deb.debian.org/debian/ sid main contrib non-free non-free-firmware
deb-src https://deb.debian.org/debian/ sid main contrib non-free non-free-firmware
apt update
apt upgrade
apt dist-upgrade
apt autoremove

apt install firmware-linux-nonfree

Tools

apt install neovim clang

Swift

Dependencies

apt install build-essential libcurl4-openssl-dev binutils git gnupg2 libc6-dev \
            libedit2 libsqlite3-0 libxml2-dev libz3-dev pkg-config tzdata \
            tzdata unzip zlib1g-dev libgcc-9-dev libncurses-dev \
            libstdc++-9-dev

Missing dependencies for Debian sid

libpython3.8 

Installed instead

apt install libpython3.10-dev python3-clang python3-lldb

Downloading and installing

wget https://download.swift.org/swift-5.9.1-release/ubuntu2204/swift-5.9.1-RELEASE/swift-5.9.1-RELEASE-ubuntu22.04.tar.gz

tar -xf swift-5.9.1-RELEASE-ubuntu22.04.tar.gz
mv swift-5.9.1-RELEASE-ubuntu22.04 /opt/swift-5.9.1

add this line to /etc/profile so the path will be added for all the users

export PATH="$PATH:/opt/swift-5.9.1/usr/bin"

Archlinux

Links:

Installation

Note: in case case it is Mac mini. Hold alt (option) button on boot up and select the install disk.

Here are commands to check what discs are attached to the system

cat /proc/partitions
ls /dev/[s|x|v]d*
lsblk
fdisk –l
ls /dev | grep ‘^[s|v|x][v|d]’$*

Update packages manager

pacman -Sy

Make a partition table

parted -s /dev/sda mktable GPT

Create partitions

In this case:

  • 300MB → UEFI
  • 16GB → Swap
  • Rest → System

List all types of partitions

sfdisk -T

First way: Using sfdisk

sfdisk /dev/sda << EOF
 ,300,ef
 ,16000,S,h
 ;
EOF

or pipe to the program like

echo ',,c;' | sfdisk /dev/sdd

Secund way: Using fdisk

fdisk /dev/sda << FDISK_CMDS
g
n
1

+300MiB
t
1
n
2

+16GiB
t
2
19
n
3


t
3
20
w
FDISK_CMDS

Therd way

cfdisk /dev/sda

Formatting

mkfs.fat -F32 /dev/sda1
mkswap /dev/sda2
mkfs.ext4 /dev/sda3

Mounting partitions

mount /dev/sda3 /mnt
swapon /dev/sda2

Installing base packages

pacstrap /mnt base base-devel linux linux-firmware

Generate fstab

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

Chrooting

arch-chroot /mnt << CHROOT
    #commands
CHROOT

or just arch-chroot /mnt and then commands

echo "archlinux" > /etc/hostname
sed -i "s/#en_US/en_US/g" /etc/locale.gen
locale-gen
echo LANG=en_US.UTF-8 > /etc/locale.conf
export LANG=en_US.UTF-8
ln -s /usr/share/zoneinfo/Europe/Warsaw /etc/localtime
hwclock --systohc --utc

Run 32bit apps

open → /etc/pacman.conf and uncomment [multilib] section

Installing additional software

pacman -Syu
pacman -S zsh --noconfirm

Setup users

Set password for root

passwd

Create user

useradd -mg users -G wheel,storage,power -s /usr/bin/zsh user
passwd user

You can force user to change password

chage -d 0 user

sudoers

visudo

or

cat >> /etc/sudoers <<EOL
%wheel ALL=(ALL) NOPASSWD: ALL
EOL

Setting up bootloader

pacman -S grub efibootmgr dosfstools os-prober mtools --noconfirm
mkdir /boot/EFI
mount /dev/sda1 /boot/EFI
grub-install --target=x86_64-efi --efi-directory=EFI --bootloader-id=grub_uefi --recheck

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

then exit and

  • umount -a
  • poweroff

Install any Linux out from VM

Create OS archive locally using rsync

rsync -aAXHSv /* /root/winux --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/root/*,/media/*,/lost+found,/home/*/.gvfs}
tar -cvjSf winux.tar.bz2 winux

or

tar -cvjSf winux.tar.bz2 / --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/root/*,/media/*,/lost+found,/home/*/.gvfs}

Create archive and move it to the host

ssh -p 2222 root@localhost 'tar -cvjS / --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/root/*,/media/*,/lost+found,/home/*/.gvfs} --to-stdout' > winux.tar.bz2

Extract files to the destination drive

tar -xvjf winux.tar.bz2 -C /mnt/sys

https://wiki.archlinux.org/title/Moving_an_existing_install_into_(or_out_of)_a_virtual_machine

Then generate fstab

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