1#!/bin/bash 2# Copyright (C) 2020-2022 Intel Corporation. 3# SPDX-License-Identifier: BSD-3-Clause 4 5logger_prefix="(rt-vm-rootfs) " 6source logger.sh 7 8function umount_directory() { 9 target_dir=$1 10 umount -q ${target_dir} || true 11} 12 13function disable_os_prober() { 14 if [[ -f /etc/grub.d/30_os-prober ]]; then 15 mv /etc/grub.d/30_os-prober /etc/grub.d/.30_os-prober 16 fi 17} 18 19function update_package_info() { 20 apt update -y 21} 22 23function install_tools() { 24 apt install rt-tests -y 25} 26 27function update_kernel_cmdline() { 28 cat <<EOF >> /etc/default/grub 29 30GRUB_CMDLINE_LINUX="rootwait rootfstype=ext4 console=ttyS0,115200 console=tty0 rw nohpet console=hvc0 no_timer_check ignore_loglevel log_buf_len=16M consoleblank=0 tsc=reliable clocksource=tsc tsc=reliable x2apic_phys processor.max_cstate=0 intel_idle.max_cstate=0 intel_pstate=disable mce=ignore_ce audit=0 isolcpus=nohz,domain,1 nohz_full=1 rcu_nocbs=1 nosoftlockup idle=poll irqaffinity=0 no_ipi_broadcast=1" 31EOF 32} 33 34function install_rt_kernel() { 35 search_dir=$1 36 for file in $(ls -r ${search_dir}/*acrn-kernel-*.deb) 37 do 38 cp ${file} /tmp 39 sudo apt install /tmp/${file##*/} -y 40 done 41} 42 43function change_root_password() { 44 passwd root 45} 46 47function disable_services() { 48 services=(systemd-timesyncd.service \ 49 systemd-journal-flush.service \ 50 apt-daily.service \ 51 apt-daily-upgrade.service \ 52 snapd.autoimport.service \ 53 snapd.seeded.service) 54 55 for service in ${services[*]} 56 do 57 systemctl disable ${service} 58 systemctl mask ${service} 59 done 60 61 for timer in $(systemctl list-unit-files | grep -o "^.*\.timer"); do 62 systemctl disable ${timer} 63 done 64 65 apt-get remove unattended-upgrades -y 66 } 67 68# Change current working directory to the root to avoid "target is busy" errors 69# on unmounting. 70cd / 71 72try_step "Unmounting /root" umount_directory /root 73try_step "Unmounting /home" umount_directory /home 74try_step "Disabling GRUB OS prober" disable_os_prober 75try_step "Updating package information" update_package_info 76try_step "Installing tools" install_tools 77try_step "Updating kernel command line" update_kernel_cmdline 78try_step "Installing RT kernel" install_rt_kernel /root 79try_step "Changing the password of the root user" change_root_password 80try_step "Disabling services that impact real-time performance" disable_services 81