Howto create own archlinux distro: Difference between revisions

From Vidalinux Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 18: Line 18:
  qemu-nbd -c /dev/nbd0 arch-openstack-LATEST-image-bootstrap_100G.qcow2  
  qemu-nbd -c /dev/nbd0 arch-openstack-LATEST-image-bootstrap_100G.qcow2  
  kpartx -a /dev/nbd0
  kpartx -a /dev/nbd0
  mkdir /mnt/archlinux
  mkdir /mnt/archlive
  mount /dev/mapper/nbd0p1 /mnt/archlinux
  mount /dev/mapper/nbd0p1 /mnt/archlinux
  mount -o bind /dev /mnt/archlinux/dev
  mount -o bind /dev /mnt/archlive/dev
  mount -o bind /proc /mnt/archlinux/proc
  mount -o bind /proc /mnt/archlive/proc
enter enviroment with arch-chroot:
enter enviroment with arch-chroot:
  arch-chroot /mnt/archlinux
  arch-chroot /mnt/archlive
initialize the pacman keyring and populate signing keys:
initialize the pacman keyring and populate signing keys:
  pacman-key --init
  pacman-key --init
Line 30: Line 30:
  cat > /etc/hosts << EOF
  cat > /etc/hosts << EOF
  127.0.0.1 localhost
  127.0.0.1 localhost
  10.44.1.44 archlinux
  10.44.1.44 archlive
  EOF
  EOF
edit /etc/ssh/sshd_config:
edit /etc/ssh/sshd_config:
Line 63: Line 63:
  systemctl enable chronyd
  systemctl enable chronyd
umount qcow2 image:
umount qcow2 image:
  umount /mnt/archlinux/proc
  umount /mnt/archlive/proc
  umount /mnt/archlinux/dev
  umount /mnt/archlive/dev
  umount /mnt/archlinux
  umount /mnt/archlive
  nbd-client -d /dev/nbd0
  nbd-client -d /dev/nbd0
  dmsetup remove /dev/mapper/nbd0p1
  dmsetup remove /dev/mapper/nbd0p1

Revision as of 18:21, 15 November 2023

configure os

download latest archlinux cloud image:

wget https://linuximages.de/openstack/arch/arch-openstack-LATEST-image-bootstrap.qcow2

make sure we have libguestfs installed:

pacman -S libguestfs guestfs-tools

resize image:

cp arch-openstack-LATEST-image-bootstrap.qcow2 arch-openstack-LATEST-image-bootstrap_100G.qcow2
qemu-img resize arch-openstack-LATEST-image-bootstrap_100G.qcow2 +99G

expand image:

virt-resize --expand /dev/sda1 arch-openstack-LATEST-image-bootstrap.qcow2 arch-openstack-LATEST-image-bootstrap_100G.qcow2

change password:

virt-sysprep -a arch-openstack-LATEST-image-bootstrap_100G.qcow2 -q --root-password password:vidalinux

uninstall cloud-init:

virt-sysprep -a arch-openstack-LATEST-image-bootstrap_100G.qcow2 --run-command "pacman -R cloud-init --noconfirm"

on centos copy the image to this directory:

cd /var/lib/libvirt/images/

mount image:

qemu-nbd -c /dev/nbd0 arch-openstack-LATEST-image-bootstrap_100G.qcow2 
kpartx -a /dev/nbd0
mkdir /mnt/archlive
mount /dev/mapper/nbd0p1 /mnt/archlinux
mount -o bind /dev /mnt/archlive/dev
mount -o bind /proc /mnt/archlive/proc

enter enviroment with arch-chroot:

arch-chroot /mnt/archlive

initialize the pacman keyring and populate signing keys:

pacman-key --init
pacman-key --populate archlinux

configure /etc/hosts:

cat > /etc/hosts << EOF
127.0.0.1 localhost
10.44.1.44 archlive
EOF

edit /etc/ssh/sshd_config:

sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/g' /etc/ssh/sshd_config
sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config

enable sshd service:

systemctl enable --now sshd 

configure hostname:

hostnamectl set-hostname archlive

configure timezone:

timedatectl set-timezone America/Puerto_Rico

stop and disable systemd-resolved:

systemctl disable systemd-resolved && systemctl stop systemd-resolved

nameserver configuration:

rm /etc/resolv.conf
echo "nameserver 4.2.2.1" > /etc/resolv.conf
echo "nameserver 4.2.2.2" >> /etc/resolv.conf

update entire os:

pacman -Syuu --noconfirm

install packages:

pacman -Sy curl vim screen nano net-tools bind-tools networkmanager ebtables ethtool wget unzip socat conntrack-tools parted gptfdisk lvm2 git

configure networkmanager:

cat > /root/net << EOF
systemctl start NetworkManager && systemctl enable NetworkManager
nmcli con del eth0
nmcli con del Wired\ connection\ 1
nmcli con add con-name eth0 ipv4.method manual type ethernet ifname eth0 ipv4.addresses 10.44.1.44/24 ipv4.gateway 10.44.1.1 ipv4.dns 4.2.2.1,4.2.2.2 autoconnect yes
EOF

install chrony:

pacman -S chrony --noconfirm

enable and start chrony:

systemctl enable chronyd

umount qcow2 image:

umount /mnt/archlive/proc
umount /mnt/archlive/dev
umount /mnt/archlive 
nbd-client -d /dev/nbd0
dmsetup remove /dev/mapper/nbd0p1