|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright (c) Intel Corporation. |
| 4 | +# Licensed under the MIT License. |
| 5 | + |
| 6 | +# Failure can be ignored. |
| 7 | +set -e |
| 8 | +set -x |
| 9 | + |
| 10 | +# regen initramfs for tink |
| 11 | +echo "Tink: final regen initramfs" |
| 12 | + |
| 13 | +ramfs=$(find /boot -type f -name initramfs*img -printf '%f\n') |
| 14 | +# unzip initramfs |
| 15 | +mkdir /tmp/initramfs |
| 16 | +cd /tmp/initramfs |
| 17 | +echo "Tink: inside $(pwd)" |
| 18 | +echo "Tink: unziping initial initramfs for repack" |
| 19 | +gunzip -c -k /boot/$ramfs | cpio -idmv --no-absolute-filenames |
| 20 | +echo "Tink: free space $(df -h)" |
| 21 | + |
| 22 | +mkdir /tmp/rootfs |
| 23 | +cd /tmp/rootfs |
| 24 | +echo "Tink: inside $(pwd)" |
| 25 | +echo "Tink: free space $(df -h)" |
| 26 | +mkdir -p boot dev etc home mnt media proc sys run tmp usr usr/bin usr/sbin usr/lib usr/libexec var |
| 27 | +chown root:root boot dev etc home mnt media proc sys run tmp usr usr/bin usr/sbin usr/lib usr/libexec var |
| 28 | +chmod 0700 boot |
| 29 | +chmod 0755 dev etc home mnt media proc sys run tmp usr usr/bin usr/sbin usr/lib usr/libexec var |
| 30 | +echo "Tink: copy initial initramfs for rootfs" |
| 31 | +cp -a /tmp/initramfs/dev/* dev/ |
| 32 | +ln -s usr/bin bin |
| 33 | +ln -s usr/sbin sbin |
| 34 | +ln -s usr/lib lib |
| 35 | +ln -s usr/lib lib64 |
| 36 | +chown root:root bin sbin lib lib64 |
| 37 | +chmod 0777 bin sbin lib lib64 |
| 38 | +echo "Tink: after initramfs copy $(ls -l .)" |
| 39 | +echo "Tink: after initramfs copy $(du -h /tmp/rootfs)" |
| 40 | +echo "Tink: copying rootfs files" |
| 41 | +cp -R -p /usr/sbin/* usr/sbin/ |
| 42 | +cp -R -p /usr/bin/* usr/bin/ |
| 43 | +cp -R -p /usr/lib/* usr/lib/ |
| 44 | +cp -R -p /usr/libexec/* usr/libexec/ |
| 45 | +cp -R -p /var/lib var/ |
| 46 | +cp -R -p /etc/* etc/ |
| 47 | +# override boot device command line |
| 48 | +echo "Tink: fstab contents $(cat etc/fstab)" |
| 49 | +echo 'Tink: tmpfs / tmpfs defaults,size=1G 0 0' > etc/fstab |
| 50 | +#echo "" > etc/fstab |
| 51 | +echo "Tink: fstab contents after edit $(cat etc/fstab)" |
| 52 | +# simple setup for console |
| 53 | +#echo 'LANG=en_US.UTF-8' > etc/locale.conf |
| 54 | +#echo 'KEYMAP=us' > etc/vconsole.conf |
| 55 | +#echo 'FONT=lat9w-16' >> etc/vconsole.conf |
| 56 | +echo "Tink: console setup $(cat etc/locale.conf etc/vconsole.conf)" |
| 57 | +mkdir -p usr/share/terminfo/v |
| 58 | +cp -R -p /usr/share/terminfo/v/vt100 usr/share/terminfo/v/ |
| 59 | +cp -R -p /usr/share/terminfo/v/vt220 usr/share/terminfo/v/ |
| 60 | +mkdir -p usr/share/keymaps |
| 61 | +cp -R -p /usr/share/keymaps/include usr/share/keymaps/ |
| 62 | +mkdir -p usr/share/keymaps/i386/include |
| 63 | +cp -R -p /usr/share/keymaps/i386/include/* usr/share/keymaps/i386/include/ |
| 64 | +mkdir -p usr/share/keymaps/i386/qwerty |
| 65 | +cp -R -p /usr/share/keymaps/i386/qwerty/us.map.gz usr/share/keymaps/i386/qwerty/ |
| 66 | +mkdir -p usr/share/consolefonts |
| 67 | +cp -R -p /usr/share/consolefonts/lat9w-16* usr/share/consolefonts/ |
| 68 | +mkdir -p usr/share/dbus-1 |
| 69 | +cp -R -p /usr/share/dbus-1/system.conf usr/share/dbus-1/ |
| 70 | +echo "Tink: after copy $(du -h /tmp/rootfs)" |
| 71 | +echo "Tink: free space $(df -h)" |
| 72 | +tar cf - -C . . | gzip -9 > /rootfs.tar.gz |
| 73 | +cd - |
| 74 | +echo "Tink: rootfs size: $(ls -l /rootfs.tar.gz)" |
| 75 | +rm -rf /tmp/rootfs |
| 76 | + |
| 77 | +cd /tmp/initramfs |
| 78 | +echo "Tink: inside $(pwd)" |
| 79 | +echo "Tink: after copy $(du -h /tmp/initramfs)" |
| 80 | +echo "Tink: check cmdline.d $(ls etc/cmdline.d)" |
| 81 | +echo "Tink: check cmdline.d contents $(cat etc/cmdline.d/95root-dev.conf)" |
| 82 | +#echo 'root=tmpfs rootfstype=tmpfs' > etc/cmdline.d/95root-dev.conf |
| 83 | +#echo 'root= rootfstype=auto' > etc/cmdline.d/95root-dev.conf |
| 84 | +echo 'root=tmpfs rootflags=size=1G,mode=0755' > etc/cmdline.d/95root-dev.conf |
| 85 | +echo "Tink: check cmdline.d contents after edit $(cat etc/cmdline.d/95root-dev.conf)" |
| 86 | +echo "Tink: before rm devexist* $(ls -al var/lib/dracut/hooks/initqueue/finished/)" |
| 87 | +rm -f var/lib/dracut/hooks/initqueue/finished/devexists* |
| 88 | +echo "Tink: after rm devexist* $(ls -al var/lib/dracut/hooks/initqueue/finished/)" |
| 89 | +echo "Tink: before rm wants $(ls -al etc/systemd/system/initrd.target.wants/)" |
| 90 | +rm -rf etc/systemd/system/initrd.target.wants/dev-disk-b* |
| 91 | +echo "Tink: after rm wants $(ls etc/systemd/system/initrd.target.wants/)" |
| 92 | +echo "Tink: before rm disk service $(ls -al etc/systemd/system/dev-disk-b*)" |
| 93 | +rm -rf etc/systemd/system/dev-disk-b* |
| 94 | +echo "Tink: after rm disk service $(ls -al etc/systemd/system/)" |
| 95 | +echo "$(find . -iname dev-disk*)" |
| 96 | +# copy tar required for uncompressing rootfs archive |
| 97 | +echo "Tink: before copy tar $(find . -iname tar)" |
| 98 | +cp /usr/bin/tar usr/bin |
| 99 | +echo "Tink: after copy tar $(find . -iname tar)" |
| 100 | +mv /rootfs.tar.gz /tmp/initramfs/ |
| 101 | +find . | cpio -o -H newc | gzip > /boot/$ramfs |
| 102 | +cd - |
| 103 | + |
| 104 | +echo "Tink: $(ls -l /boot/$ramfs)" |
| 105 | +rm -rf /tmp/initramfs |
0 commit comments