samedi 7 juillet 2018

How to build the CoreFreq Live CD

Prerequisites

  1. Install the Arch Linux distribution for Kernels compilation
  2. Install the archiso (remark: archiso requires the root permissions)
  3. Prepare a working directory (for example: live)
# su
# mkdir live
# cd live
# cp -vr /usr/share/archiso/configs/releng/. .

Customize the boot configuration files

  • add the packages to be included into the image
# nano packages.x86_64

arch-install-scripts
b43-fwcutter
broadcom-wl
btrfs-progs
crda
darkhttpd
ddrescue
dhclient
dialog
dmraid
dnsmasq
dnsutils
dosfstools
elinks
ethtool
exfat-utils
f2fs-tools
fsarchiver
gcc
gdb
git
gnu-netcat
gptfdisk
grml-zsh-config
grub
hdparm
ipw2100-fw
ipw2200-fw
irssi
lftp
linux-atm
linux-headers
lsscsi
make
mtools
ndisc6
networkmanager
nfs-utils
nilfs-utils
nmap
ntfs-3g
ntp
openconnect
openssh
openvpn
partclone
parted
partimage
ppp
pptpclient
refind-efi
rp-pppoe
rsync
sdparm
sg3_utils
smartmontools
sudo
tcpdump
testdisk
unzip
usb_modeswitch
# valgrind
vim-minimal
vpnc
wget
wireless_tools
wpa_actiond
wvdial
xl2tpd

  • modify the SysLinux configuration section files with the following contents
# nano syslinux/archiso_head.cfg

SERIAL 0 38400

#UI boot/syslinux/vesamenu.c32
UI boot/syslinux/menu.c32

MENU TITLE Arch Linux (x86_64) [   CoreFreq   ]
#MENU BACKGROUND boot/syslinux/splash.png

MENU WIDTH 78
MENU MARGIN 4
MENU ROWS 10
MENU VSHIFT 3
MENU TIMEOUTROW 16
MENU TABMSGROW 17
MENU CMDLINEROW 16
MENU HELPMSGROW 20
MENU HELPMSGENDROW -1

# Refer to http://syslinux.zytor.com/wiki/index.php/Doc/menu

MENU COLOR border       30;44   #40ffffff #a0000000 std
MENU COLOR title        1;36;44 #9033ccff #a0000000 std
MENU COLOR sel          7;37;40 #e0ffffff #20ffffff all
MENU COLOR unsel        37;44   #50ffffff #a0000000 std
MENU COLOR help         37;40   #c0ffffff #a0000000 std
MENU COLOR timeout_msg  37;40   #80ffffff #00000000 std
MENU COLOR timeout      1;37;40 #c0ffffff #00000000 std
MENU COLOR msg07        37;40   #90ffffff #a0000000 std
MENU COLOR tabmsg       31;40   #30ffffff #00000000 std

MENU CLEAR
TIMEOUT 120

# nano syslinux/archiso_pxe.cfg

INCLUDE boot/syslinux/archiso_head.cfg

LABEL arch64_nbd
TEXT HELP
Boot the Arch Linux (x86_64) live medium (Using NBD).
It allows you to install Arch Linux or perform system maintenance.
ENDTEXT
MENU LABEL Boot Arch Linux (x86_64) (NBD)
LINUX boot/x86_64/vmlinuz
INITRD boot/intel_ucode.img,boot/x86_64/archiso.img
APPEND nmi_watchdog=0 archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% archiso_nbd_srv=${pxeserver}
SYSAPPEND 3

LABEL arch64_nfs
TEXT HELP
Boot the Arch Linux (x86_64) live medium (Using NFS).
It allows you to install Arch Linux or perform system maintenance.
ENDTEXT
MENU LABEL Boot Arch Linux (x86_64) (NFS)
LINUX boot/x86_64/vmlinuz
INITRD boot/intel_ucode.img,boot/x86_64/archiso.img
APPEND nmi_watchdog=0 archisobasedir=%INSTALL_DIR% archiso_nfs_srv=${pxeserver}:/run/archiso/bootmnt
SYSAPPEND 3

LABEL arch64_http
TEXT HELP
Boot the Arch Linux (x86_64) live medium (Using HTTP).
It allows you to install Arch Linux or perform system maintenance.
ENDTEXT
MENU LABEL Boot Arch Linux (x86_64) (HTTP)
LINUX boot/x86_64/vmlinuz
INITRD boot/intel_ucode.img,boot/x86_64/archiso.img
APPEND nmi_watchdog=0 archisobasedir=%INSTALL_DIR% archiso_http_srv=http://${pxeserver}/
SYSAPPEND 3
INCLUDE boot/syslinux/archiso_tail.cfg

# nano syslinux/archiso_sys.cfg

INCLUDE boot/syslinux/archiso_head.cfg

LABEL arch64
TEXT HELP
Boot the Arch Linux.
[Text video mode]
ENDTEXT
MENU LABEL Boot Arch Linux [Text] [English]
LINUX boot/x86_64/vmlinuz
INITRD boot/intel_ucode.img,boot/x86_64/archiso.img
APPEND archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% nmi_watchdog=0 earlysh selinux=0 plymouth.enable=0 text rd.systemd.show_status=auto rd.udev.log-priority=3 consoleblank=0 vga=current nomodeset cow_spacesize=512M modprobe.blacklist=pcspkr,iTCO_wdt cpu0_hotplug

LABEL french
TEXT HELP
Demarrer Arch Linux.
[Mode video texte]
ENDTEXT
MENU LABEL Boot Arch Linux [Text] [Francais]
LINUX boot/x86_64/vmlinuz
INITRD boot/intel_ucode.img,boot/x86_64/archiso.img
APPEND archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% nmi_watchdog=0 earlysh locale.LANG=fr_FR.UTF-8 vconsole.keymap=fr selinux=0 plymouth.enable=0 text rd.systemd.show_status=auto rd.udev.log-priority=3 consoleblank=0 vga=current nomodeset cow_spacesize=512M modprobe.blacklist=pcspkr,iTCO_wdt cpu0_hotplug

LABEL deutch
TEXT HELP
Starten Sie den Arch Linux.
[Text video modus]
ENDTEXT
MENU LABEL Boot Arch Linux [Text] [Deutch]
LINUX boot/x86_64/vmlinuz
INITRD boot/intel_ucode.img,boot/x86_64/archiso.img
APPEND archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% nmi_watchdog=0 earlysh locale.LANG=de_DE.UTF-8 vconsole.keymap=de selinux=0 plymouth.enable=0 text rd.systemd.show_status=auto rd.udev.log-priority=3 consoleblank=0 vga=current nomodeset cow_spacesize=512M modprobe.blacklist=pcspkr,iTCO_wdt cpu0_hotplug

LABEL spanish
TEXT HELP
Arranque el Arch Linux.
[Modo de video de texto]
ENDTEXT
MENU LABEL Boot Arch Linux [Text] [Espanol]
LINUX boot/x86_64/vmlinuz
INITRD boot/intel_ucode.img,boot/x86_64/archiso.img
APPEND archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% nmi_watchdog=0 earlysh locale.LANG=es_ES.UTF-8 vconsole.keymap=es selinux=0 plymouth.enable=0 text rd.systemd.show_status=auto rd.udev.log-priority=3 consoleblank=0 vga=current nomodeset cow_spacesize=512M modprobe.blacklist=pcspkr,iTCO_wdt cpu0_hotplug

LABEL envesa
TEXT HELP
Boot the Arch Linux.
[Graphic video mode]
ENDTEXT
MENU LABEL Boot Arch Linux [VESA] [English]
LINUX boot/x86_64/vmlinuz
INITRD boot/intel_ucode.img,boot/x86_64/archiso.img
APPEND archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% nmi_watchdog=0 earlysh selinux=0 plymouth.enable=0 rd.systemd.show_status=auto rd.udev.log-priority=3 consoleblank=0 cow_spacesize=512M modprobe.blacklist=pcspkr,iTCO_wdt cpu0_hotplug

LABEL frvesa
TEXT HELP
Demarrer Arch Linux.
[Mode video graphique]
ENDTEXT
MENU LABEL Boot Arch Linux [VESA] [Francais]
LINUX boot/x86_64/vmlinuz
INITRD boot/intel_ucode.img,boot/x86_64/archiso.img
APPEND archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% nmi_watchdog=0 earlysh locale.LANG=fr_FR.UTF-8 vconsole.keymap=fr selinux=0 plymouth.enable=0 rd.systemd.show_status=auto rd.udev.log-priority=3 consoleblank=0 cow_spacesize=512M modprobe.blacklist=pcspkr,iTCO_wdt cpu0_hotplug

LABEL devesa
TEXT HELP
Starten Sie den Arch Linux.
[Grafischer videomodus]
ENDTEXT
MENU LABEL Boot Arch Linux [VESA] [Deutch]
LINUX boot/x86_64/vmlinuz
INITRD boot/intel_ucode.img,boot/x86_64/archiso.img
APPEND archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% nmi_watchdog=0 earlysh locale.LANG=de_DE.UTF-8 vconsole.keymap=de selinux=0 plymouth.enable=0 rd.systemd.show_status=auto rd.udev.log-priority=3 consoleblank=0 cow_spacesize=512M modprobe.blacklist=pcspkr,iTCO_wdt cpu0_hotplug

LABEL spvesa
TEXT HELP
Arranque el Arch Linux.
[Modo de video grafico]
ENDTEXT
MENU LABEL Boot Arch Linux [VESA] [Espanol]
LINUX boot/x86_64/vmlinuz
INITRD boot/intel_ucode.img,boot/x86_64/archiso.img
APPEND archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% nmi_watchdog=0 earlysh locale.LANG=es_ES.UTF-8 vconsole.keymap=es selinux=0 plymouth.enable=0 rd.systemd.show_status=auto rd.udev.log-priority=3 consoleblank=0 cow_spacesize=512M modprobe.blacklist=pcspkr,iTCO_wdt cpu0_hotplug

INCLUDE boot/syslinux/archiso_tail.cfg

# nano syslinux/archiso_tail.cfg

LABEL poweroff
MENU LABEL Power Off
COM32 boot/syslinux/poweroff.c32

LABEL reboot
MENU LABEL Reboot
COM32 boot/syslinux/reboot.c32

LABEL existing
TEXT HELP
Boot an existing operating system.
Press TAB to edit the disk and partition number to boot.
ENDTEXT
MENU LABEL Boot existing OS
COM32 boot/syslinux/chain.c32
APPEND hd0 0

# http://www.memtest.org/
LABEL memtest
MENU LABEL Run Memtest86+ (RAM test)
LINUX boot/memtest

# http://hdt-project.org/
LABEL hdt
MENU LABEL Hardware Information (HDT)
COM32 boot/syslinux/hdt.c32
APPEND modules_alias=boot/syslinux/hdt/modalias.gz pciids=boot/syslinux/hdt/pciids.gz

  • isolinux remains unchanged
  • modify the EFI boot configuration
# nano efiboot/loader/loader.conf

timeout 12
default archiso-x86_64

# nano efiboot/loader/entries/archiso-x86_64-cd.conf

title   Arch Linux archiso x86_64 UEFI CD
linux   /EFI/archiso/vmlinuz.efi
initrd  /EFI/archiso/intel_ucode.img
initrd  /EFI/archiso/archiso.img
options archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% nmi_watchdog=0 selinux=0 rd.systemd.show_status=auto rd.udev.log-priority=3 consoleblank=0 nomodeset cow_spacesize=512M modprobe.blacklist=pcspkr,iTCO_wdt cpu0_hotplug

# nano efiboot/loader/entries/archiso-x86_64-usb.conf

title   Arch Linux archiso x86_64 UEFI USB
linux   /%INSTALL_DIR%/boot/x86_64/vmlinuz
initrd  /%INSTALL_DIR%/boot/intel_ucode.img
initrd  /%INSTALL_DIR%/boot/x86_64/archiso.img
options archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% nmi_watchdog=0 selinux=0 rd.systemd.show_status=auto rd.udev.log-priority=3 consoleblank=0 nomodeset cow_spacesize=512M modprobe.blacklist=pcspkr,iTCO_wdt cpu0_hotplug

Prepare the root file system

etc

# cp -v /etc/locale.gen airootfs/etc/

# nano airootfs/etc/locale.gen

de_DE.UTF-8 UTF-8
de_DE ISO-8859-1
en_US.UTF-8 UTF-8
en_US ISO-8859-1
es_ES.UTF-8 UTF-8
es_ES ISO-8859-1
fr_FR.UTF-8 UTF-8
fr_FR ISO-8859-1

# nano airootfs/etc/locale.conf

LANG=en_US.UTF-8
LC_ALL=



  • optionally makes the editor full screen with programming syntax coloring


# nano airootfs/etc/nanorc

set constantshow
set morespace
set nohelp
set nonewlines
set nowrap
set showcursor
set smarthome
set titlecolor brightwhite,red
set statuscolor brightwhite,red
set selectedcolor brightwhite,cyan
set numbercolor magenta
set keycolor brightmagenta
set functioncolor magenta
include "/usr/share/nano/*.nanorc"


# mkdir airootfs/etc/skel
# mkdir airootfs/etc/sysctl.d


  • disable the Watchdog, system wide


# nano airootfs/etc/sysctl.d/99-sysctl.conf

kernel.watchdog = 0



  • add the CoreFreq personal systemd boot unit ...


# nano airootfs/etc/systemd/system/early-shell.service

[Unit]
Description=Early configuration shell
ConditionKernelCommandLine=earlysh

[Service]
Type=oneshot
ExecStart=/etc/systemd/scripts/early-shell

[Install]
WantedBy=multi-user.target



  • ... and the unit associated script



# nano airootfs/etc/systemd/scripts/early-shell

#!/bin/bash

KEY=`grep -oP '(?<=\bvconsole.keymap=)[^;]+' /proc/cmdline | cut -f 1 -d " "`

if [ -n "${KEY}" ]; then
        localectl set-keymap ${KEY}
fi

case "${KEY}" in
        ( fr )
        localectl set-locale "LANG=fr_FR.UTF-8" ;;
        ( de )
        localectl set-locale "LANG=de_DE.UTF-8" ;;
        ( es )
        localectl set-locale "LANG=es_ES.UTF-8" ;;
        ( * )
        localectl set-locale "LANG=en_US.UTF-8" ;;
esac

if [ -f /sys/devices/cpu/rdpmc ]; then
        echo 2 > /sys/devices/cpu/rdpmc
fi


# chmod +x airootfs/etc/systemd/scripts/early-shell

root

# touch airootfs/root/.hushlogin

# nano airootfs/root/.zlogin

~/.automated_script.sh

if [[ ${TTY} == "/dev/tty1" ]]; then
        corefreq_menu.sh
fi

# nano airootfs/root/customize_airootfs.sh

#!/bin/bash

set -e -u

sed -i 's/#\(en_US\.UTF-8\)/\1/' /etc/locale.gen
locale-gen

ln -sf /usr/share/zoneinfo/UTC /etc/localtime

usermod -s /usr/bin/zsh root
cp -aT /etc/skel/ /root/
chmod 700 /root

sed -i 's/#\(PermitRootLogin \).\+/\1yes/' /etc/ssh/sshd_config
sed -i "s/#Server/Server/g" /etc/pacman.d/mirrorlist
sed -i 's/#\(Storage=\)auto/\1volatile/' /etc/systemd/journald.conf

sed -i 's/#\(HandleSuspendKey=\)suspend/\1ignore/' /etc/systemd/logind.conf
sed -i 's/#\(HandleHibernateKey=\)hibernate/\1ignore/' /etc/systemd/logind.conf
sed -i 's/#\(HandleLidSwitch=\)suspend/\1ignore/' /etc/systemd/logind.conf

systemctl enable pacman-init.service choose-mirror.service early-shell.service wpa_supplicant NetworkManager
systemctl set-default multi-user.target



  • add the CoreFreq helper scripts


# mkdir airootfs/root/bin

# nano airootfs/root/bin/corefreq_build_run.sh

#!/bin/bash
cd /opt/CoreFreq
make
if [[ $? == 0 ]]; then
 insmod corefreqk.ko
 if [[ $? == 0 ]]; then
  sleep 1
  ./corefreqd -q &
  pid=$!
  sleep 1
  ./corefreq-cli
  kill -s SIGQUIT ${pid}
  sleep 1
 fi
 rmmod corefreqk.ko
fi
cd

# nano airootfs/root/bin/corefreq_experimental.sh

#!/bin/bash
cd /opt/CoreFreq
make
if [[ $? == 0 ]]; then
 insmod corefreqk.ko Experimental=1 NMI_Disable=0
 if [[ $? == 0 ]]; then
  sleep 1
  ./corefreqd -q &
  pid=$!
  sleep 1
  ./corefreq-cli
  kill -s SIGQUIT ${pid}
  sleep 1
 fi
 rmmod corefreqk.ko
fi
cd

# nano airootfs/root/bin/corefreq_online_update.sh

#!/bin/bash
cd /opt
declare -i cloned=0
for url in https://github.com/cyring/CoreFreq.git http://github.com/cyring/CoreFreq.git
do
 bak=$(stat -c "%X" CoreFreq)
 mv CoreFreq CoreFreq.${bak}
 git clone ${url}
 if [[ $? != 0 ]]; then
  mv -f CoreFreq.${bak} CoreFreq
 else
  cloned=1
  break
 fi
done
if (( cloned != 1 ))
then
 wget --no-verbose http://github.com/cyring/CoreFreq/archive/master.zip -O CoreFreq.zip
 if [[ $? == 0 ]]; then
  bak=$(stat -c "%X" CoreFreq)
  mv CoreFreq CoreFreq.${bak}
  unzip -q CoreFreq.zip
  if [[ $? != 0 ]]; then
   mv -f CoreFreq.${bak} CoreFreq
  else
   mv CoreFreq-master CoreFreq
  fi
  rm -f CoreFreq.zip
 fi
fi
cd

# nano airootfs/root/bin/corefreq_menu.sh

#!/bin/bash
HELPERS=$(ls --color -C ${HOME}/bin)
echo
echo "Starting CoreFreq in 9 seconds"
echo
echo "Helpers are: ${HELPERS}"
echo
echo -n "Press [CTRL]+[C] to abort"
sleep 9
if [[ $? == 0 ]]; then
 echo
 echo
 corefreq_build_run.sh
fi


# chmod +x airootfs/root/bin/corefreq_build_run.sh
# chmod +x airootfs/root/bin/corefreq_experimental.sh
# chmod +x airootfs/root/bin/corefreq_online_update.sh
# chmod +x airootfs/root/bin/corefreq_menu.sh

opt


  • get the CoreFreq source code from the GitHub

# mkdir -p airootfs/opt/CoreFreq

# git clone https://github.com/cyring/CoreFreq.git airootfs/opt/CoreFreq/

Build and Burn the image


  • first create a cleanup script

# nano cleanup.sh

#!/bin/bash
rm out/*.iso
rm -fr work/iso
rm -v work/build.make_*


# chmod +x cleanup.sh


  • now start building the image


# ./build.sh -v


  • remark: the image is named with the date of the day


# cdrecord blank=fast
# cdrecord -overburn out/archlinux-2018.07.07-x86_64.iso

Boot CoreFreq

Once the CD is burned, reboot the computer selecting CDROM as the boot option.
As shown into the Wiki, CoreFreq will be fully automatized from its compilation up to its startup.

At any time, you can exit from CoreFreq with [F4] or [CTRL] + [C]
You will be brought back to the command line where you can use the helper scripts to:

Update to the last source code (just enter wifi to configure a wireless connection)
# corefreq_online_update.sh

Try the experimental mode (for example, the Memory Controller)
# corefreq_experimental.sh

Start in nominal mode
# corefreq_build_run.sh

Power off computer

# poweroff

- EOF -

Aucun commentaire:

Enregistrer un commentaire