aboutsummarylogtreecommitdiffstats
path: root/arch.install
blob: f34d8662ffa90f08bdd1484538d5c4562a3f4932 (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
#!/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 syslinux mkinitcpio haveged openssh sudo

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]
Name=en* eth* usb* wl*

[Network]
DHCP=yes
EOF

setarch ${arch} arch-chroot . <<EOF
sudo pacman --noconfirm -S linux
syslinux-install_update -i -m
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