blob: d4783552dfa630d30add70ae3f8ba38aea1f4bf4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
#!/bin/bash
# enable for debugging (single stepping line by line)
#set -x
#trap read debug
exec > >(tee -i logfile.txt)
exec 2>&1
# configuration
INSTALL_DRIVE=/dev/vda
PARTITION_BOOT=1
PARTITION_ROOT=2
LABEL_ROOT=ROOT
MOUNT_PATH=/mnt
HOST=192.168.120.1
HTTP_SERVER=http://${HOST}:8088
IP=192.168.120.101
NETWORK=192.168.120.0
NETMASK=255.255.255.0
PREFIX=24
HOSTNAME=arch32
# set up networking
ip addr add dev eth0 ${IP}
ip route add to ${NETWORK}/${PREFIX} dev eth0 via ${HOST}
ip route add to default dev eth0 via ${HOST}
cat > /etc/resolv.conf <<EOF
nameserver 8.8.8.8
EOF
# create early SSH access
echo 'root:xx' | chpasswd
echo "PermitRootLogin yes" >> /etc/ssh/sshd_config
systemctl start sshd
echo "Partitioning and creating filesystem.."
mknod /dev/vda b 254 0
mknod /dev/vda1 b 254 1
mknod /dev/vda2 b 254 2
wipefs -a ${INSTALL_DRIVE}
printf ",128M,L,*\n" | /sbin/sfdisk -f ${INSTALL_DRIVE}
printf ",,L,*\n" | /sbin/sfdisk -a -f ${INSTALL_DRIVE}
mkfs.ext2 ${INSTALL_DRIVE}${PARTITION_BOOT}
mkfs.ext4 ${INSTALL_DRIVE}${PARTITION_ROOT}
mount ${INSTALL_DRIVE}${PARTITION_ROOT} ${MOUNT_PATH}
mkdir ${MOUNT_PATH}/boot
mount ${INSTALL_DRIVE}${PARTITION_BOOT} ${MOUNT_PATH}/boot
echo "Patching pacman to play locally.."
cat >/etc/pacman.d/mirrorlist <<EOF
Server = ${HTTP_SERVER}/mirror/\$arch/\$repo
EOF
echo "Installing keyring for ArchLinux32."
sed -i 's/^SigLevel.*/SigLevel = Never/g' /etc/pacman.conf
sed -i '/CheckSpace/ a DisableDownloadTimeout' /etc/pacman.conf
pacman --noconfirm -Syyw archlinux32-keyring
pacman --noconfirm -U /var/cache/pacman/pkg/archlinux32-keyring-*.pkg.tar.xz
echo "Installing minimalistic base system.."
pacstrap ${MOUNT_PATH} filesystem grep findutils coreutils glibc bash pacman \
mkinitcpio linux dhcpcd systemd sed systemd-sysvcompat
sed -i 's/^SigLevel.*/SigLevel = Never/g' ${MOUNT_PATH}/etc/pacman.conf
cat >${MOUNT_PATH}/etc/pacman.d/mirrorlist <<EOF
Server = ${HTTP_SERVER}/mirror/\$arch/\$repo
EOF
# pin the architecture
sed -i 's/^Architecture.*/Architecture=i686/' ${MOUNT_PATH}/etc/pacman.conf
echo "Test if we can update the system inside chroot."
arch-chroot ${MOUNT_PATH} pacman -Syyu --noconfirm
echo "Install /etc/fstab"
genfstab -L -p ${MOUNT_PATH} > ${MOUNT_PATH}/etc/fstab
echo "Installing boot loader.."
arch-chroot ${MOUNT_PATH} pacman --noconfirm -S grub
arch-chroot ${MOUNT_PATH} grub-install --force /dev/vda
arch-chroot ${MOUNT_PATH} grub-mkconfig -o /boot/grub/grub.cfg
echo "Configuring base system.."
sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/g' ${MOUNT_PATH}/etc/locale.gen
arch-chroot ${MOUNT_PATH} locale-gen
echo LANG=en_US.UTF-8 > ${MOUNT_PATH}/etc/locale.conf
ln -fs /usr/share/zoneinfo/Europe/Zurich ${MOUNT_PATH}/etc/localtime
arch-chroot ${MOUNT_PATH} hwclock --systohc --utc
echo ${HOSTNAME} > ${MOUNT_PATH}/etc/hostname
cat > ${MOUNT_PATH}/etc/systemd/network/25-wired.network <<EOF
[Match]
Name=ens3
[Network]
Address=${IP}/${PREFIX}
Gateway=${HOST}
EOF
ln -sf ../run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
arch-chroot ${MOUNT_PATH} systemctl enable systemd-networkd
arch-chroot ${MOUNT_PATH} systemctl enable systemd-resolved
arch-chroot ${MOUNT_PATH} sh -c "echo 'root:xx' | chpasswd"
arch-chroot ${MOUNT_PATH} pacman --noconfirm -S openssh
echo "PermitRootLogin yes" >>${MOUNT_PATH}/etc/ssh/sshd_config
arch-chroot ${MOUNT_PATH} systemctl enable sshd
# maybe later, when pacman knows the Archlinux32 developer keys
#sed -i 's/^SigLevel.*/SigLevel = Required DatabaseOptional/g' ${MOUNT_PATH}/etc/pacman.conf
echo "Unmounting.."
umount ${MOUNT_PATH}/boot
umount ${MOUNT_PATH}
echo "Powering off.."
sleep 10
systemctl poweroff
|