Using disk image builder to create rapid VM
[samplevnf.git] / rapidvm / dib / elements / rapid / post-install.d / 70-os-cfg
1 #!/usr/bin/env bash
2 #
3 # Copyright (c) 2021 Intel Corporation
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 BUILD_DIR="/opt/rapid"
18 # huge pages to be used by DPDK
19 sh -c '(echo "vm.nr_hugepages = 1024") > /etc/sysctl.conf'
20
21 sh -c '(echo "options vfio enable_unsafe_noiommu_mode=1") > /etc/modprobe.d/vfio.conf'
22 sh -c '(echo "vfio") > /etc/modules-load.d/vfio.conf'
23 sh -c '(echo "vfio-pci") > /etc/modules-load.d/vfio.conf'
24 # Enabling tuned with the realtime-virtual-guest profile
25 pushd ${BUILD_DIR} > /dev/null 2>&1
26 #wget http://linuxsoft.cern.ch/cern/centos/7/rt/x86_64/Packages/tuned-profiles-realtime-2.8.0-5.el7_4.2.noarch.rpm
27 wget http://linuxsoft.cern.ch/cern/centos/7/rt/x86_64/Packages/tuned-profiles-realtime-2.9.0-1.el7_5.2.noarch.rpm
28 #wget http://linuxsoft.cern.ch/cern/centos/7/rt/x86_64/Packages/tuned-profiles-nfv-guest-2.8.0-5.el7_4.2.noarch.rpm
29 wget http://linuxsoft.cern.ch/cern/centos/7/rt/x86_64/Packages/tuned-profiles-nfv-guest-2.9.0-1.el7_5.2.noarch.rpm
30 # Install with --nodeps. The latest CentOS cloud images come with a tuned version higher than 2.8. These 2 packages however
31 # do not depend on v2.8 and also work with tuned 2.9. Need to be careful in the future
32 #rpm -ivh ${BUILD_DIR}/tuned-profiles-realtime-2.8.0-5.el7_4.2.noarch.rpm --nodeps
33 #rpm -ivh ${BUILD_DIR}/tuned-profiles-nfv-guest-2.8.0-5.el7_4.2.noarch.rpm --nodeps
34 rpm -ivh ${BUILD_DIR}/tuned-profiles-realtime-2.9.0-1.el7_5.2.noarch.rpm --nodeps
35 rpm -ivh ${BUILD_DIR}/tuned-profiles-nfv-guest-2.9.0-1.el7_5.2.noarch.rpm --nodeps
36 # Although we do no know how many cores the VM will have when begin deployed for real testing, we already put a number for the
37 # isolated CPUs so we can start the realtime-virtual-guest profile. If we don't, that command will fail.
38 # When the VM will be instantiated, the check_kernel_params service will check for the real number of cores available to this VM
39 # and update the realtime-virtual-guest-variables.conf accordingly.
40 echo "isolated_cores=1-3" | tee -a /etc/tuned/realtime-virtual-guest-variables.conf
41 tuned-adm profile realtime-virtual-guest
42
43 # Install the check_tuned_params service to make sure that the grub cmd line has the right cpus in isolcpu. The actual number of cpu's
44 # assigned to this VM depends on the flavor used. We don't know at this time what that will be.
45 chmod +x ${BUILD_DIR}/check_prox_system_setup.sh
46 mv ${BUILD_DIR}/check_prox_system_setup.sh /usr/local/libexec/
47 mv ${BUILD_DIR}/check-prox-system-setup.service /etc/systemd/system/
48 systemctl daemon-reload
49 systemctl enable check-prox-system-setup.service
50 popd > /dev/null 2>&1