-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage2initrd-fakeroot
More file actions
executable file
·29 lines (23 loc) · 836 Bytes
/
image2initrd-fakeroot
File metadata and controls
executable file
·29 lines (23 loc) · 836 Bytes
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
#!/usr/bin/env bash
set -euox pipefail
WORK=/tmp/image2initrd/$$
mkdir -p $WORK
tar xvf $1 --directory=$WORK
# Clean up some files added by `podman create` (apparently)
rm $WORK/etc/hosts || true
rm $WORK/etc/resolv.conf || true
rm $WORK/run/.containerenv || true
rm -rf $WORK/run/secrets/ || true
# Now add stuff which is not in the container images
# (and can't be added via Dockerfile, because /dev/ is a tmpfs)
# as per `man null` (and required for tty* below)
mknod -m 666 $WORK/dev/null c 1 3
mknod -m 666 $WORK/dev/zero c 1 5
chown root:root /dev/null /dev/zero
# fix "can't open /dev/tty4: No such file or directory"
ln -sf /dev/null $WORK/dev/tty2
ln -sf /dev/null $WORK/dev/tty3
ln -sf /dev/null $WORK/dev/tty4
# Create Initial RAM Disk CPIO archive
( cd $WORK/ && find . | cpio -o -H newc ) | gzip > $2
rm -rf $1 $WORK