Align compressed initrd to 4 bytes

Allows appending another initrd.

Also build initrd on tmpfs as should be a bit faster now we have to do
another copy.

Fix #618

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
Justin Cormack 2016-12-02 14:51:03 +00:00
parent 9916e7510d
commit 72d4d5aefc
2 changed files with 28 additions and 4 deletions

View File

@ -44,7 +44,7 @@ initrd.img: Dockerfile mkinitrd.sh init $(ETCFILES)
containers/*/rootfs containers/*/config.json \
| \
docker build -q - ) && [ -n "$$BUILD" ] && echo "Built $$BUILD" && \
docker run --net=none --log-driver=none --rm $$BUILD > $@
docker run --read-only --net=none --log-driver=none --rm --tmpfs /tmp --tmpfs /initrd $$BUILD > $@
mobylinux-efi.iso: Dockerfile.efi initrd.img kernel/x86_64/vmlinuz64
BUILD=$$( tar cf - $^ | docker build -q -f Dockerfile.efi - ) && [ -n "$$BUILD" ] && echo "Built $$BUILD" && \

View File

@ -32,7 +32,31 @@ EOF
printf 'moby' > /tmp/etc/hostname
rm /tmp/mkinitrd.sh
cd /tmp
find . | cpio -H newc -o | gzip -9
rm mkinitrd.sh
find . | cpio -H newc -o | gzip -9 > /initrd/initrd.img
cd /initrd
SIZE=$(stat -c "%s" initrd.img)
SIZE4=$(( $SIZE / 4 \* 4 ))
DIFF=$(( $SIZE - $SIZE4 ))
[ $DIFF -ne 0 ] && DIFF=$(( 4 - $DIFF ))
dd if=/dev/zero bs=1 count=$DIFF of=zeropad
cat zeropad >> initrd.img
SIZE=$(stat -c "%s" initrd.img)
SIZE4=$(( $SIZE / 4 \* 4 ))
DIFF=$(( $SIZE - $SIZE4 ))
if [ $DIFF -ne 0 ]
then
echo "Bad aligment" >2
exit 1
fi
cat initrd.img