--- layout: default title: Linux installation categories: linux --- 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](https://github.com/clearlinux/common/raw/master/OVMF.fd) ```bash 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 ```bash 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 ```bash diskutil unmount /dev/disk2s1 ``` Here is how we can list all the disks attached to the system ```bash diskutil list ``` Writing image to the USB device (notice that we do not write to a partition) ```bash sudo dd if=archlinux-2021.01.01-x86_64.iso of=/dev/disk2 ``` then flush the data by ejecting the drive ```bash 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: - [amd64 - Install disc](https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.2.0-amd64-netinst.iso) - [amd64 - Live disc](https://cdimage.debian.org/debian-cd/current-live/amd64/iso-hybrid/) 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. ```bash nano /etc/ssh/sshd_config ``` `Ctrl-o` `Ctrl-x` Put this line in the file ```plain PermitRootLogin yes ``` and then ```bash 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 ``` ```bash apt update apt upgrade apt dist-upgrade apt autoremove apt install firmware-linux-nonfree ``` ### Tools ```sh apt install neovim clang ``` **Swift** Dependencies ```sh 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 ```text libpython3.8 ``` Installed instead ```plain 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 ```plain export PATH="$PATH:/opt/swift-5.9.1/usr/bin" ``` # Archlinux Links: - [torrents with ISO files](https://archlinux.org/releng/releases/) - [latest ISO version from HTTP mirror](https://geo.mirror.pkgbuild.com/iso/latest/) - [Offline: Most recent installation guide](https://wiki.archlinux.org/index.php/Offline_installation) - [UEFI: Most recent installation guide](https://wiki.archlinux.org/title/installation_guideI) # 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 ```bash cat /proc/partitions ls /dev/[s|x|v]d* lsblk fdisk –l ls /dev | grep ‘^[s|v|x][v|d]’$* ``` Update packages manager ```bash pacman -Sy ``` Make a partition table ```bash parted -s /dev/sda mktable GPT ``` ### Create partitions In this case: - 300MB → UEFI - 16GB → Swap - Rest → System List all types of partitions ```bash sfdisk -T ``` #### First way: Using `sfdisk` ```bash sfdisk /dev/sda << EOF ,300,ef ,16000,S,h ; EOF ``` or pipe to the program like ```bash echo ',,c;' | sfdisk /dev/sdd ``` #### Secund way: Using `fdisk` ```bash 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 ```bash cfdisk /dev/sda ``` Formatting ```bash mkfs.fat -F32 /dev/sda1 mkswap /dev/sda2 mkfs.ext4 /dev/sda3 ``` Mounting partitions ```bash mount /dev/sda3 /mnt swapon /dev/sda2 ``` Installing base packages ```bash pacstrap /mnt base base-devel linux linux-firmware ``` Chrooting ```bash arch-chroot /mnt << CHROOT #commands CHROOT ``` or just `arch-chroot /mnt` and then commands ```bash 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 ```bash pacman -Syu pacman -S zsh --noconfirm ``` #### Setup users Set password for root ```bash passwd ``` Create user ```bash useradd -mg users -G wheel,storage,power -s /usr/bin/zsh user ``` ```bash passwd user ``` You can force user to change password ```bash chage -d 0 user ``` sudoers ```bash visudo ``` or ```bash cat >> /etc/sudoers <> /mnt/etc/fstab ``` - `umount -a` - `poweroff` ## Install any Linux out from VM Create OS archive locally using rsync ```bash rsync -aAXHSv /* /root/winux --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/root/*,/media/*,/lost+found,/home/*/.gvfs} tar -cvjSf winux.tar.bz2 winux ``` or ```bash 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 ```bash 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 ```bash genfstab -U /mnt/sys > /mnt/sys/etc/fstab ```