summarylogtreecommitdiffstats
path: root/arch.install
blob: 862f4dfd7f1d99d610d3b62f7bf00dc8a50ca155 (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
#!/bin/bash

set -e

arch=${1-x86_64}
file=${2-arch.qcow2}
loop=/dev/nbd0

(( ! $UID ))

[[ ! -e ${file} ]]

qemu-img create -f qcow2 ${file} 8G
modprobe nbd max_part=8
qemu-nbd -c ${loop} ${file}

sfdisk ${loop} <<\EOF
,131072
,
EOF
partprobe "${loop}"

mkfs.ext2 -L boot ${loop}p1
mkfs.ext4 -L root ${loop}p2

mnt=${file}.mnt
install -d ${mnt}
mount ${loop}p2 ${mnt}

pushd ${mnt}

install -d boot
mount ${loop}p1 boot

setarch ${arch} pacstrap -C /usr/share/devtools/pacman-extra.conf -c . base base-devel pacman-contrib haveged openssh sudo syslinux
systemctl --root=. enable systemd-{networkd,resolved} haveged sshd

ln -sf ../run/systemd/resolve/resolv.conf etc/resolv.conf

install -d home/user/.ssh
cat ~/.ssh/id_*.pub > home/user/.ssh/authorized_keys

install -d boot/syslinux

cat > boot/syslinux/syslinux.cfg <<EOF
DEFAULT arch
LABEL arch
LINUX ../vmlinuz-linux
APPEND root=LABEL=root ro
INITRD ../initramfs-linux-fallback.img
EOF

cat > etc/fstab <<EOF
tmpfs       /tmp   tmpfs  nodev,nosuid  0  0
LABEL=boot  /boot  ext2   defaults      0  1
LABEL=root  /      ext4   defaults      0  1
EOF

cat > etc/hostname <<EOF
guest
EOF

cat > etc/locale.gen <<EOF
en_US.UTF-8 UTF-8
EOF

cat > etc/sudoers.d/user <<EOF
user ALL=(ALL) NOPASSWD: ALL
EOF

cat > etc/systemd/network/any.network <<EOF
[Match]

[Network]
DHCP=yes
EOF

setarch ${arch} arch-chroot . <<EOF
syslinux-install_update -i -m
mkinitcpio -p linux
locale-gen
useradd -p 00as1wm0AZG56 user
chown -R user:users /home/user
EOF

sfdisk --activate ${loop} 1

umount boot
popd
umount ${mnt}
rmdir ${mnt}
killall qemu-nbd