Sep 4, 2024
TechnologyBefore building, enable all of the deb-src items.
Steps:
sudo apt build-dep linux linux-image-unsigned-$(uname -r)
sudo apt install libncurses-dev gawk flex bison openssl libssl-dev dkms libelf-dev libudev-dev libpci-dev libiberty-dev autoconf llvm
sudo apt install git
apt source linux-image-unsigned-$(uname -r)
chmod a+x debian/rules
chmod a+x debian/scripts/*
chmod a+x debian/scripts/misc/*
fakeroot debian/rules clean
Edit the items:
vim debian.xxxx/config/annotations
Change the items you want to change, for example:
cat /boot/config-5.4.0-150-generic | grep -i module_force
CONFIG_MODULE_FORCE_LOAD=y
CONFIG_MODULE_FORCE_UNLOAD=y
Edit the configurations:
fakeroot debian/rules editconfigs
fakeroot debian/rules binary-headers binary-generic binary-perarch
Then after building you could get deb generated.
Aug 27, 2024
TechnologyServer startup via:
# vim docker-compose.yml
version: '3'
networks:
rustdesk-net:
external: false
services:
hbbs:
container_name: hbbs
ports:
- 21115:21115
- 21116:21116
- 21116:21116/udp
- 21118:21118
image: rustdesk/rustdesk-server:latest
command: hbbs -r 127.0.0.1:21117
volumes:
- ./data:/root
networks:
- rustdesk-net
depends_on:
- hbbr
restart: unless-stopped
hbbr:
container_name: hbbr
ports:
- 21117:21117
- 21119:21119
image: rustdesk/rustdesk-server:latest
command: hbbr
volumes:
- ./data:/root
networks:
- rustdesk-net
restart: unless-stopped
# docker-compose -f docker-compose.yml up -d
Inspect the running docker instance:
sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5e5ea15264d5 rustdesk/rustdesk-server:latest "hbbs -r 127.0.0.1:2…" 2 hours ago Up 2 hours 0.0.0.0:21115-21116->21115-21116/tcp, :::21115-21116->21115-21116/tcp, 0.0.0.0:21118->21118/tcp, :::21118->21118/tcp, 0.0.0.0:21116->21116/udp, :::21116->21116/udp hbbs
6206c4cbb810 rustdesk/rustdesk-server:latest "hbbr" 2 hours ago Up 2 hours 0.0.0.0:21117->21117/tcp, :::21117->21117/tcp, 0.0.0.0:21119->21119/tcp, :::21119->21119/tcp hbbr
Configuration on this server:
The key is filled with following steps:
[dash@shidaarch ~]$ cd rustdeck/data/
[dash@shidaarch data]$ ls
db_v2.sqlite3 db_v2.sqlite3-shm db_v2.sqlite3-wal id_ed25519 id_ed25519.pub
[dash@shidaarch data]$ cat id_ed25519.pub
8+p6ycEu7aPcLDSkzBg4Lgml3m5EbuTzzl9yRhfixCE=
Aug 24, 2024
TechnologySteps
Change hostname and print system info:
# hostnamectl set-hostname multiubuntu
# exit
logout
Connection to 192.168.1.52 closed.
$ ssh root@192.168.1.52
root@multiubuntu:~# uname -a
Linux multiubuntu 5.15.0-117-generic #127-Ubuntu SMP Fri Jul 5 20:13:28 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
root@multiubuntu:~# cat /etc/issue
Ubuntu 22.04.4 LTS \n \l
Install xfce4(Using xfce4 for demo):
# apt install -y xfce4
Create 10 test users, change shell, change passwd:
$ for i in {1..10}; do useradd -m test$i; done
$ sudo ls /home
test test1 test10 test2 test3 test4 test5 test6 test7 test8 test9
$ for i in {1..10}; do chsh -s /bin/bash test$i; done
$ vim bulkpasswords
$ chpasswd < bulkpasswords
Define every user’s .xinitrc
:
# cp /etc/X11/xinit/xinitrc .
# vim xinitrc
......
# invoke global X session script
#. /etc/X11/Xsession
XDG_SESSION_TYPE=x11
exec dbus-run-session -- startxfce4
# for i in {1..10}; do cp xinitrc /home/test$i/.xinitrc; done
Change the available ttys:
# vim /etc/systemd/logind.conf
[Login]
NAutoVTs=50
ReserveVT=50
Change the bash profile for each user:
# cat bash_profile_example
#
# ~/.bash_profile
#
[[ -f ~/.bashrc ]] && . ~/.bashrc
if [ -z "$DISPLAY" ] && [ "$XDG_VTNR" = TOBEREPLACED ]; then
exec startx &>/dev/null
fi
# for i in {1..10}; do cp /root/bash_profile_example /home/test$i/.bash_profile; sed -i "s/TOBEREPLACED/$i/g" /home/test$i/.bash_profile; chown -R test$i /home/test$i/.bash_profile; done
Add all user to autologin:
# groupadd -r autologin
# for i in {1..10}; do gpasswd -a test$i autologin; done
autologin template file:
[Service]
Type=simple
ExecStart=
Environment=XDG_SESSION_TYPE=x11
ExecStart=-/usr/sbin/agetty --skip-login --nonewline --noissue --autologin TOBEREPLACED --noclear %I $TERM
Add autologin service:
root@multi:~# cat autologin.conf
[Service]
Type=simple
ExecStart=
ExecStart=-/usr/bin/agetty --skip-login --nonewline --noissue --autologin TOBEREPLACED --noclear %I $TERM
# for i in {1..50}; do mkdir -p /etc/systemd/system/getty\@tty$i.service.d/; done
for i in {1..50}; do cp autologin.conf /etc/systemd/system/getty\@tty$i.service.d/; sed -i "s/TOBEREPLACED/test$i/g" /etc/systemd/system/getty\@tty$i.service.d/autologin.conf; done
Now add autologin crontab:
# crontab -e
@reboot sleep 10 && /usr/bin/chvtsh.sh
Create chvtsh.sh
:
#!/bin/bash
while ! ps -p $(pgrep Xorg) > /dev/null; do
echo "Waiting for xorg to start...">>/tmp/waitdone.txt
sleep 1
done
echo "xorg started, switching to console 2">>/tmp/waitdone.txt
sleep 5
for i in {2..50}
do
chvt $i
systemctl start getty@tty$i
sleep 5
done
Enable the getty@tty1:
# systemctl set-default multi-user.target
# systemctl enable getty@tty1
Aug 23, 2024
TechnologyCreate users:
for i in {1..20}; do useradd -m test$i; done
Create a bulkpasswords file:
test1: goeugoogue
test2: gowguowgow
.....
Change password:
chpasswd < bulkpasswords
Copy the getty service:
for i in {7..21}; do cp -r getty\@tty6.service.d/ getty\@tty$i.service.d; done
change the systemd files:
[root@archremote system]# vim getty\@tty7.service.d/autologin.conf
[root@archremote system]# vim getty\@tty6.service.d/autologin.conf
[root@archremote system]# vim getty\@tty8.service.d/autologin.conf
[root@archremote system]# vim getty\@tty9.service.d/autologin.conf
[root@archremote system]# vim getty\@tty10.service.d/autologin.conf
[root@archremote system]# vim getty\@tty11.service.d/autologin.conf
[root@archremote system]# vim getty\@tty12.service.d/autologin.conf
[root@archremote system]# vim getty\@tty13.service.d/autologin.conf
[root@archremote system]# vim getty\@tty14.service.d/autologin.conf
[root@archremote system]# vim getty\@tty15.service.d/autologin.conf
[root@archremote system]# vim getty\@tty16.service.d/autologin.conf
[root@archremote system]# vim getty\@tty17.service.d/autologin.conf
[root@archremote system]# vim getty\@tty18.service.d/autologin.conf
[root@archremote system]# vim getty\@tty19.service.d/autologin.conf
[root@archremote system]# vim getty\@tty20.service.d/autologin.conf
[root@archremote system]# vim getty\@tty6.service.d/autologin.conf
[root@archremote system]# cat getty\@tty6.service.d/autologin.conf
[Service]
Type=simple
ExecStart=
#ExecStart=-/sbin/agetty -o '-p -f -- \\u' --noclear --autologin dash %I $TERM
ExecStart=-/usr/bin/agetty --skip-login --nonewline --noissue --autologin test6 --noclear %I $TERM
for i in {6..20}; do cp /home/test1/.bash_profile /home/test$i/.bash_profile && chown -R test$i /home/test$i/.bash_profile; done
vim /home/test6/.bash_profile
vim /home/test7/.bash_profile
vim /home/test8/.bash_profile
vim /home/test9/.bash_profile
vim /home/test10/.bash_profile
vim /home/test11/.bash_profile
vim /home/test12/.bash_profile
vim /home/test13/.bash_profile
vim /home/test14/.bash_profile
vim /home/test15/.bash_profile
vim /home/test16/.bash_profile
vim /home/test17/.bash_profile
vim /home/test18/.bash_profile
vim /home/test19/.bash_profile
vim /home/test20/.bash_profile
for i in {6..20}; do cp /home/test1/.xinitrc /home/test$i/.xinitrc; chmod 777 /home/test$i/.xinitrc; done
Example for bash_profile
:
[root@archremote ~]# cat /home/test18/.bash_profile
#
# ~/.bash_profile
#
[[ -f ~/.bashrc ]] && . ~/.bashrc
if [ -z "$DISPLAY" ] && [ "$XDG_VTNR" = 18 ]; then
exec startx &>/dev/null
fi
Added autologin:
gpasswd -a test7 autologin
for i in {8..20}; do gpasswd -a test$i autologin; done
crontab for activating this:
[root@archremote ~]# cat /usr/bin/chvtsh.sh
#!/bin/bash
while ! ps -p $(pgrep Xorg) > /dev/null; do
echo "Waiting for xorg to start...">>/tmp/waitdone.txt
sleep 1
done
echo "xorg started, switching to console 2">>/tmp/waitdone.txt
sleep 15
chvt 2
sleep 5
chvt 3
sleep 5
chvt 4
sleep 5
chvt 5
sleep 5
chvt 6
sleep 5
chvt 7
systemctl start getty@tty7
sleep 5
chvt 8
systemctl start getty@tty8
sleep 5
chvt 9
systemctl start getty@tty9
[root@archremote ~]# crontab -l
@reboot sleep 10 && /usr/bin/chvtsh.sh
Aug 20, 2024
TechnologyModification on grub default parameters:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash iommu=pt amd_iommu=on initcall_blacklist=sysfb_init pcie_acs_override=downstream,multifunction"
Remove some items in nova:
$ vim /etc/nova/nova.conf
[libvirt]
virt_type = kvm
cpu_mode = host-passthrough
qemu_envs = QEMU_AUDIO_DRV=pa,QEMU_PA_SERVER=/run/user/1000/pulse/native
#qemu_envs = QEMU_AUDIO_DRV=pa
#qemu_args = -set,device.hostdev0.x-igd-opregion=on, -set,device.hostdev0.x-igd-gms=2, -set,device.hostdev0.romfile=/usr/share/OVMF/adls-1085.rom, -set,device.hostdev0.multifunction=on
Modification on libvirt hooks:
$ vim /etc/libvirt/hook/vfio-startup
......
# 1. find the graphical card and its associated devices in the same pci slot, record its pci id
# 1.1 find vgaid via lspci
vgaid=`lspci | grep -i vga | awk {'print $1'}`
# 1.2 find iommu file in /sys
vgaiommufile=`find /sys/kernel/iommu_groups/ -type l | grep $vgaid`
# 1.3 retrieve the iommu fold, which contains other device which should be processed in next step
vgaiommudir=`dirname $vgaiommufile`
# 1.4 record the system device driver in dic devicedriver
declare -A devicedriver
for i in `ls $vgaiommudir`; do devicedriver[$i]=`lspci -v -s $i | grep 'Kernel driver in use' | awk -F ': ' {'print $2'}`;done
# 1.5 record the pciid in dic pciid
declare -A pciid
for i in `ls $vgaiommudir`; do pciid[$i]=`lspci -n -s $i | awk -F ' ' {'print $3'}`;done
# 1.6 write devicedriver and pciid in /tmp
rm -f /tmp/devicedriver
rm -f /tmp/pciid
for i in `echo "${!devicedriver[@]}"`; do echo $i "${devicedriver[$i]}">>/tmp/devicedriver;done
for i in `echo "${!pciid[@]}"`; do echo $i "${pciid[$i]}">>/tmp/pciid;done
# 2. unbind the current activated device driver mode
# example: echo "0000:06:00.0" > /sys/bus/pci/drivers/amdgpu/unbind
while IFS= read -r line; do
pci_no=$(echo "$line" | cut -d' ' -f1)
driver_name=$(echo "$line" | cut -d' ' -f2)
echo $pci_no > /sys/bus/pci/drivers/$driver_name/unbind
done < /tmp/devicedriver
# 3. echo new_id to vfio-pci
# example echo $igd_id > /sys/bus/pci/drivers/vfio-pci/new_id
while IFS= read -r line; do
pci_id=$(echo "$line" | cut -d' ' -f2)
echo $pci_id > /sys/bus/pci/drivers/vfio-pci/new_id
done < /tmp/pciid
# Old Logical for gen10/gen12
#igd_id="8086 $(lspci -n|grep '0:02.0'|cut -d ':' -f4|cut -c 1-4)"
#echo 0000:00:02.0 > /sys/bus/pci/drivers/i915/unbind
#if ! lsmod | grep "vfio_pci" &> /dev/null ; then
# modprobe vfio-pci
#fi
#echo $igd_id > /sys/bus/pci/drivers/vfio-pci/new_id
#echo $usb_id > /sys/bus/pci/drivers/vfio-pci/new_id
Also change teardown hook:
$ vim /etc/libvirt/hook/vfio-teardown.sh
# 1. unbind all of the vfio-pci items
# Example: echo $igd_id > /sys/bus/pci/drivers/vfio-pci/remove_id
while IFS= read -r line; do
pci_id=$(echo "$line" | cut -d' ' -f2)
echo $pci_id > /sys/bus/pci/drivers/vfio-pci/remove_id
done < /tmp/pciid
# 2. re-bind system device driver
# example: echo "0000:06:00.0" > /sys/bus/pci/drivers/radeon/unbind
while IFS= read -r line; do
pci_no=$(echo "$line" | cut -d' ' -f1)
driver_name=$(echo "$line" | cut -d' ' -f2)
echo $pci_no > /sys/bus/pci/drivers/$driver_name/bind
done < /tmp/devicedriver
Change the nova’s libvirt items:
$ vim /usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.py
else:
with open('/tmp/pciid', 'r') as f:
for line in f:
#print(line.strip().split(' ')[0])
pci = vconfig.LibvirtConfigGuestHostdevPCI()
pci_addr = (line.strip().split(' ')[0])
pci.address = pci_addr
dbs, sep, pci.function = pci_addr.partition('.')
pci.domain, pci.bus, pci.slot = dbs.split(':')
if CONF.libvirt.virt_type in ('xen', 'parallels',):
pci.managed = 'no'
if CONF.libvirt.virt_type in ('kvm', 'qemu'):
pci.managed = 'yes'
guest.add_device(pci)
$ vim /usr/lib/python2.7/dist-packages/nova/virt/libvirt/config.py
def _format_os(self, root):
os = etree.Element("os")
type_node = self._text_node("type", self.os_type)
type_node.set("machine", "pc-q35-8.0")
# rm -f /usr/lib/python2.7/dist-packages/nova/virt/libvirt/driver.pyc
# rm -f /usr/lib/python2.7/dist-packages/nova/virt/libvirt/config.pyc
But this will cause the libvirt won’t startup, cause it will need /tmp/pciid
file available before creating vms, so we have to change the items for generating pciids:
$ sudo vim /bin/detectgpu.sh
#!/bin/bash
# 1. find the graphical card and its associated devices in the same pci slot, record its pci id
# 1.1 find vgaid via lspci
vgaid=`lspci | grep -i vga | awk {'print $1'}`
# 1.2 find iommu file in /sys
vgaiommufile=`find /sys/kernel/iommu_groups/ -type l | grep $vgaid`
# 1.3 retrieve the iommu fold, which contains other device which should be processed in next step
vgaiommudir=`dirname $vgaiommufile`
# 1.4 record the system device driver in dic devicedriver
declare -A devicedriver
for i in `ls $vgaiommudir`; do devicedriver[$i]=`lspci -v -s $i | grep 'Kernel driver in use' | awk -F ': ' {'print $2'}`;done
# 1.5 record the pciid in dic pciid
declare -A pciid
for i in `ls $vgaiommudir`; do pciid[$i]=`lspci -n -s $i | awk -F ' ' {'print $3'}`;done
# 1.6 write devicedriver and pciid in /tmp
rm -f /tmp/devicedriver
rm -f /tmp/pciid
for i in `echo "${!devicedriver[@]}"`; do echo $i "${devicedriver[$i]}">>/tmp/devicedriver;done
for i in `echo "${!pciid[@]}"`; do echo $i "${pciid[$i]}">>/tmp/pciid;done
Now remove items in hooks’s vfio-startup.sh.
Add this script in crontab:
crontab -e
added:
@reboot /bin/detectgpu.sh
Finally we will get the amd 520 running on hygon machine.