LinuxTips17

TurnToJPG -->


1. liquorix kernel(zen)

Install on Ubuntu 22.04 via:

curl -s 'https://liquorix.net/install-liquorix.sh' | sudo bash

2. pikvm for x86

Tips(comment the brltty related items and reboot, then ttyUSB0 is avaiable):

sudo vim /usr/lib/udev/rules.d/85-brltty.rules
# ENV{PRODUCT}=="1a86/7523/*", ENV{BRLTTY_BRAILLE_DRIVER}="bm", GOTO="brltty_usb_run"
sudo systemctl mask brltty.path
sudo reboot

Change to ubuntu22.04 and solved the problem.

3. socket 5 proxy

Open the proxy via:

ssh -N -D 0.0.0.0:10000 dash@localhost

Then set the proxy in other machine for yum usage:

$ vim /etc/yum.conf
#proxy=socks5://10.23.119.200:10000

4. ubuntu22.04 curl issue

Problem:

OpenSSL Error messages: error:0A000126:SSL routines::unexpected eof while reading

solved via:

apt remove curl
apt purge curl
apt-get update
apt-get install -y libssl-dev autoconf libtool make
cd /usr/local/src
wget https://curl.haxx.se/download/curl-7.88.1.zip
unzip curl-7.88.1.zip
cd curl-7.88.1
./buildconf
./configure --with-ssl 
make
sudo make install
sudo cp /usr/local/bin/curl /usr/bin/curl
sudo ldconfig
curl -V

5. nix-shell install

install via:

nix-shell '<home-manager>' -A install --option substituters https://mirrors.ustc.edu.cn/nix-channels/store

6. Workingtips for nix on ubuntu

简单步骤:

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
nix-channel --update
nix-shell '<home-manager>' -A install
nix run home-manager/master -- init --switch 
sudo apt install seatd
sudo usermod -a -G video $USER
reboot
nix profile install github:guibou/nixGL --impure
home-manager switch --option substituters https://mirrors.ustc.edu.cn/nix-channels/store
sudo apt-get install -y pipewire pipewire-pulse

Also edit the limitation of /etc/security/limits.conf, as following.

Modification for nix files:

$ vim ~/.config/home-manager/hyprland.nix
                monitor=,1920x1080@60,auto,1
......
             master {
                 # See https://wiki.hyprland.org/Configuring/Master-Layout/ for more
# new_is_master = true
                 new_status = slave
$ vim ~/.config/home-manager/flake.nix
    #hyprland.url = "github:hyprwm/Hyprland";
    hyprland.url = "git+https://github.com/hyprwm/Hyprland?submodules=1";

7. limitation linux

enlarge via:

 /etc/security/limits.conf, add

* soft nofile 1000001
* hard nofile 1000001

8. nix dconf issue

problem:

Activating dconfSettings
dbus[13416]: Failed to start message bus: Configuration file needs one or more <listen> elements giving addresses
dbus-run-session: EOF reading address from bus daemon

Solved via:

not solved, for centos's dbus is pretty old
### 9. pactrap archlinux
Can't Pacstrap because of "Corrupted" packages, solved via:     

pacman -Sy archlinux-keyring sudo pacstrap -c /mnt base


### 10. nixos dhcpd issue
encounter following issue:      

   Failed assertions:
   - The option definition `services.dhcpd4' in `/nix/store/yq5mkfx3b97iczs5a6lhjm14gkjx9795-source/configuration.nix' no longer has any effect; please remove it.
   The dhcpd4 module has been removed because ISC DHCP reached its end of life.
   See https://www.isc.org/blogs/isc-dhcp-eol/ for details.
   Please switch to a different implementation like kea or dnsmasq.
switch to new implementation:     

### 11. sybench rocklinux
Install via:      

sudo yum install -y epel-release sudo yum install ./sysbench…..


### 12. x0vncserver
Using x0vncserver for replacing nxplayer:      

$ sudo pacman -S tigervnc $ vncpasswd $ vim ~/.xprofile x0vncserver -rfbauth ~/.vnc/passwd &


### 13. git clone via socks proxy
temp using socks proxy via:     

git -c “http.proxy=socks5h://127.0.0.1:21080” clone https://github.com/Limitex/ComfyUI-Diffusers.git


### 14. ignore ast kernel issue
issue:      

W: Possible missing firmware /lib/firmware/ast_dp501_fw.bin for module ast

Solved via:     

touch /lib/firmware/ast_dp501_fw.bin update-initramfs -u -k all


### 15. watch sync status
via:      

watch -d grep -e Dirty: -e Writeback: /proc/meminfo


### 15. g++ update
via:     

2019 sudo apt install -y g++-12 2020 ls -la /usr/bin | grep g++ 2021 sudo update-alternatives –install /usr/bin/g++ g++ /usr/bin/g++-11 10 2022 sudo update-alternatives –install /usr/bin/g++ g++ /usr/bin/g++-12 20 2023 sudo update-alternatives –install /usr/bin/c++ c++ /usr/bin/g++ 30


### 16. set default opener
Install:     

perl-file-mimeinfo Or perl538Packages.FileMimeInfo

Select the default opener for jpeg:     

mimeopen -d photo.jpeg


### 17. esxi usb nic
`https://avojak.com/blog/2024/01/17/installing-esxi-with-usb-nic/`, 参考。    



### 18. nixos citrix workspace
Download the tar file from citrix:     

sudo nixos-rebuild switch –option substituers https://mirror.sjtu.edu.cn/nix-channels/store nix-prefetch-url file:///home/dash/Downloads/linuxx64-24.5.0.76.tar.gz sudo nixos-rebuild switch –option substituers https://mirror.sjtu.edu.cn/nix-channels/store


### 19. Run llama3.1
Steps:       

curl -fsSL https://ollama.com/install.sh | sh ollama run llama3.1:8b


### 20. offline kubespray issues
Solved via:     

tar xzvf ../off.tar.gz cd kubespray-offline-2.25.0-0/ cd outputs/ ./setup-container.sh && ./start-nginx.sh && ./setup-offline.sh && ./setup-py.sh && ./start-registry.sh && ./load-push-all-images.sh && ./extract-kubespray.sh cd kubespray-2.25.0/ cd inventory/ cp -r sample/ rong cd rong/ vim inventory.ini cd ../../ python3.11 -m venv ~/.venv/3.11 source ~/.venv/3.11/bin/activate pip install -U pip pip install -r requirements.txt cp ../../offline.yml inventory/rong/group_vars/all/offline.yml vim inventory/rong/group_vars/all/offline.yml cp ~/new/kubespray-offline-2.25.0-0/outputs/playbook/offline-repo.yml . cp -r ~/new/kubespray-offline-2.25.0-0/outputs/playbook/roles/offline-repo/ roles/ ansible-playbook -i inventory/rong/inventory.ini offline-repo.yml ansible-playbook -i inventory/rong/inventory.ini –become –become-user=root cluster.yml kubectl get nodes kubectl get po –all-namespaces vim /etc/systemd/resolved.conf reboot


### 21. grep in linux root
via:    

grep -rli –exclude-dir={proc,boot,root,sys} ‘xmlns:qemu=’ /


### 22. one-kvm-docker
via:    

docker run -itd -p443:443 -p80:80 –name pikvm-docker –device=/dev/ttyUSB0:/dev/kvmd-hid –device=/dev/video0:/dev/kvmd-video pikvm-ch9329:0.61


![/images/20240821_095332_x.jpg](/images/20240821_095332_x.jpg)

should use relative mouse.   

### 23. cowsay issue
issue:    

cowsay: Could not find cowfile for ‘default.cow’!

Solved via:   

$ vim ~/.zshrc export ZSH=/home/dash/.oh-my-zsh COWPATH=/usr/share/cowsay/cows

recreate the terminal, this time cowsay works properly.   

### 24. flux1-dev-bnb-nf4-v2
Steps:    

models:
(base) dash@comfyvm:~/Code/ComfyUI/models/checkpoints$ mv ~/flux1-dev-bnb-nf4-v2.safetensors . (base) dash@comfyvm:~/Code/ComfyUI/models/checkpoints$ pwd /home/dash/Code/ComfyUI/models/checkpoint

Custom model:
(base) dash@comfyvm:~/Code/ComfyUI/custom_nodes$ mv ~/ComfyUI_bitsandbytes_NF4-master.zip . (base) dash@comfyvm:~/Code/ComfyUI/custom_nodes$ unzip ComfyUI_bitsandbytes_NF4-master.zip Archive: ComfyUI_bitsandbytes_NF4-master.zip 6c65152bc48b28fc44cec3aa44035a8eba400eb9 creating: ComfyUI_bitsandbytes_NF4-master/ inflating: ComfyUI_bitsandbytes_NF4-master/LICENSE.txt
inflating: ComfyUI_bitsandbytes_NF4-master/README.md
inflating: ComfyUI_bitsandbytes_NF4-master/init.py
extracting: ComfyUI_bitsandbytes_NF4-master/requirements.txt

$ conda activate comfyui (comfyui) dash@comfyvm:/opt/src/redsocks$ cd ~/Code/ComfyUI/ (comfyui) dash@comfyvm:~/Code/ComfyUI$ python -s -m pip install -U bitsandbytes

### 25. hygon win7
libvirt configuration:    

<memballoon model='virtio'>
  <address type='pci' domain='0x0000' bus='0x03' slot='0x00' function='0x0'/>
</memballoon>
  <os>
    <type arch='x86_64' machine='pc-q35-8.2'>hvm</type>
    <boot dev='hd'/>
  </os>

hardware info:

root@idv-P860:~# lspci | grep -i vga
06:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Lexa PRO [Radeon 540/540X/550/550X / RX 540X/550/550X] (rev c7)

win7, only in bios with Win7_hygon.iso, select q35. and install specified old win7 driver.

26. archlinux cn

Edit the /etc/pacman.conf:

[archlinuxcn]
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch

Then:

$ sudo pacman -Sy archlinuxcn-keyring

27. bootrepair

via:

sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt update
sudo apt install -y boot-repair && boot-repair

28. nvidia t4 qxl

Configuration items:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}
EnableMsHybrid 1
qxl: 
EnableMsHybrid 2
GridLicensedFeatures 7
AdapterType should be removed.

29. take screenshot

via:

xfce4-screenshooter  -f --display=:2 -s /tmp/test3_5.jpg

30. kernel-lt

Install via:


[root@cc-shhsh-x86-controller-1 ~]# yum --disablerepo="*" --enablerepo="elrepo-kernel" install kernel-lt
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package kernel-lt.x86_64 0:5.4.278-1.el7.elrepo will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================================================================================================================================
 Package                                   Arch                                   Version                                                Repository                                     Size
=============================================================================================================================================================================================
Installing:
 kernel-lt                                 x86_64                                 5.4.278-1.el7.elrepo                                   elrepo-kernel                                  50 M

Transaction Summary
=============================================================================================================================================================================================
Install  1 Package

Total download size: 50 M
Installed size: 230 M
Is this ok [y/d/N]: y
Downloading packages:
kernel-lt-5.4.278-1.el7.elrepo.x86_64.rpm                                                                                                                             |  50 MB  00:00:01     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : kernel-lt-5.4.278-1.el7.elrepo.x86_64                                                                                       

Configure via:

[root@cc-shhsh-x86-controller-1 ~]# ls /boot/vmlinuz-5.4.278-1.el7.elrepo.x86_64 
/boot/vmlinuz-5.4.278-1.el7.elrepo.x86_64
[root@cc-shhsh-x86-controller-1 ~]# grubby --set-default /boot/vmlinuz-5.4.278-1.el7.elrepo.x86_64 
[root@cc-shhsh-x86-controller-1 ~]# grub2-mkconfig -o /boot/efi/EFI/
BOOT/   centos/ 
[root@cc-shhsh-x86-controller-1 ~]# grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.278-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-5.4.278-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-4.19.12-7_rc1.zdyun.x86_64
Found initrd image: /boot/initramfs-4.19.12-7_rc1.zdyun.x86_64.img
Found linux image: /boot/vmlinuz-4.19.12-1.ctyun.x86_64
Found initrd image: /boot/initramfs-4.19.12-1.ctyun.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-957.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-957.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-ad8ef31f6ef940a0b65f1f597ad06c3b
Found initrd image: /boot/initramfs-0-rescue-ad8ef31f6ef940a0b65f1f597ad06c3b.img
done
You have new mail in /var/mail/root/

31. lenovo bios issue

Install win7:

BIOS版本M31K开头的激活代码 AmiSetupWriter.efi 0x802 0x1 (CSM改为允许)
BIOS版本M31K开头的激活代码 AmiSetupWriter.efi 0x802 0x1 (CSM改为允许)
如果M31K开头的BIOS,独显为RTX 16系列和20系列输入以下三条命令
AmiSetupWriter.efi 0x808 0x0 
AmiSetupWriter.efi 0x80b 0x2
AmiSetupWriter.efi 0x80c 0x2

32. detectgpu fixed code

via:

# 1.7 remove pciroot related items
reserveid=`lspci | grep -i vga | awk -F ':' {'print $1'}`
prefixreserveid="0000:"$reserveid
echo "/^${prefixreserveid}/"'!d' > /tmp/sedcmd.txt
sed -i -f /tmp/sedcmd.txt /tmp/pciid
sed -i -f /tmp/sedcmd.txt /tmp/devicedriver
usermod -a -G kvm,libvirt idv
python3 -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
pip3 install pyqt5==5.15.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
python3 -c "from PyQt5.Qt import PYQT_VERSION_STR; print(PYQT_VERSION_STR)"

34. macos usage

via:

test@tests-iMac-Pro-2 ~ % sysctl -n hw.ncpu

14
test@tests-iMac-Pro-2 ~ % sysctl hw.memsize | awk '{print $1/1073741824}'

0
test@tests-iMac-Pro-2 ~ % sysctl hw.memsize
hw.memsize: 24775753728
test@tests-iMac-Pro-2 ~ % sysctl hw.memsize | awk '{print $2/1073741824}'

23.0742

35. fh vfio items

Change vfio hooks via:

vfio-startup.sh:

systemctl stop graphical.target
sleep 3
systemctl stop gdm
sleep 3 
systemctl stop gdm3
sleep 3
killall --user idv
sleep 5
echo 0x1ec8 0x9810 | tee -a /sys/bus/pci/drivers/vfio-pci/new_id 
sleep 2
echo "End of startup!"

vfio-teardown.sh:

sleep 3
echo 0x1ec8 0x9810 > /sys/bus/pci/drivers/vfio-pci/remove_id 
sleep 1
echo 1 > /sys/bus/pci/devices/0000\:06\:00.0/remove 
sleep 3
echo 1 > /sys/bus/pci/rescan 
sleep 3
systemctl start gdm

echo "End of teardown!"

36. cuttlefish building

Building deb:

git clone https://github.com/google/android-cuttlefish
cd android-cuttlefish
tools/buildutils/build_packages.sh 
$ ls *.deb
cuttlefish-base_1.0.0_arm64.deb         cuttlefish-orchestration_1.0.0_arm64.deb
cuttlefish-common_1.0.0_arm64.deb       cuttlefish-user_1.0.0_arm64.deb
cuttlefish-integration_1.0.0_arm64.deb

Install deb:

sudo dpkg -i ./cuttlefish-base_*_*64.deb || sudo apt-get install -f
sudo dpkg -i ./cuttlefish-user_*_*64.deb || sudo apt-get install -f
sudo usermod -aG kvm,cvdnetwork,render $USER
sudo reboot

getprop:

dumpsys SurfaceFlinger | grep GLES
 ------------RE GLES------------

37. secure boot off

via:

<loader readonly='yes' secure='no' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
    <nvram>/var/lib/libvirt/qemu/nvram/centos-4.19-3_VARS.fd</nvram>

38. ubuntuOK

via:

  HOME=$PWD ./bin/launch_cvd  -gpu_mode  drm_virgl  -enable_gpu_udmabuf -cpus 4 -memory_mb  8192

39. update gcc in debian unstable

via:

sudo apt install -y gcc-12
sudo apt install g++-12
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-12 10
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-12 10
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 20
sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
sudo update-alternatives --set /usr/bin/gcc
sudo update-alternatives --set cc /usr/bin/gcc
sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
sudo update-alternatives --set c++ /usr/bin/g++
sudo update-alternatives --config gcc
sudo update-alternatives --config g++

40. build gfxstream on ubuntu2204

problems:

test@ubuntu2204:~/Code/qemu/build/deps/gfxstream$ meson setup -Ddefault_library=static --prefix "${PREFIX}" build/ 
The Meson build system
Version: 0.61.2
Source dir: /home/test/Code/qemu/build/deps/gfxstream
Build dir: /home/test/Code/qemu/build/deps/gfxstream/build
Build type: native build
Project name: gfxstream
Project version: 0.1.2
C compiler for the host machine: cc (gcc 11.4.0 "cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0")
C linker for the host machine: cc ld.bfd 2.38
C++ compiler for the host machine: c++ (gcc 11.4.0 "c++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0")
C++ linker for the host machine: c++ ld.bfd 2.38
Host machine cpu family: x86_64
Host machine cpu: x86_64
Program python3 found: YES (/usr/bin/python3)
WARNING: Python files installed by Meson might not be found by python interpreter.
 This warning can be avoided by setting "python.platlibdir" option.
WARNING: Python files installed by Meson might not be found by python interpreter.
 This warning can be avoided by setting "python.purelibdir" option.
Found pkg-config: /usr/bin/pkg-config (0.29.2)
Run-time dependency aemu_base found: YES 0.1.2
Run-time dependency aemu_host_common found: YES 0.1.2
Run-time dependency aemu_logging found: YES 0.1.2
Run-time dependency aemu_snapshot found: YES 0.1.2
Found CMake: /usr/bin/cmake (3.22.1)
Run-time dependency dl found: NO (tried pkgconfig and cmake)

host/meson.build:78:2: ERROR: Dependency "dl" not found, tried pkgconfig and cmake

41. problem solving with policykit

building issue:

terminal 1: 
$ echo $??
23783
$ pkttyagent --process 23783
Authentication is needed to run `/usr/bin/python3' as the super user
Authenticating as: test
Password: 
==== AUTHENTICATION COMPLETE ===
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/usr/bin/python3' as the super user
Authenticating as: test
Password: 
==== AUTHENTICATION COMPLETE ===

42. qemu-kvm-ev installation

Steps:

sudo sed -i.bak   -e 's|^mirrorlist=|#mirrorlist=|g'   -e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.ustc.edu.cn/centos-vault/centos|g'   /etc/yum.repos.d/CentOS-Base.repo
sudo yum update
sudo yum install -y virt-manager
sudo yum install -y centos-release-qemu-ev
sudo vi /etc/yum.repos.d/CentOS-QEMU-EV.repo
...
baseurl=http://mirrors.ustc.edu.cn/centos-vault/centos/$releasever/virt/$basearch/kvm-common/
...
sudo yum makecache
sudo yum install -y qemu-kvm-ev

elrepo:

$ cat /etc/yum.repos.d/elrepo.repo
...
[elrepo-kernel]
name=ELRepo.org Community Enterprise Linux Kernel Repository - el7
#baseurl=http://elrepo.org/linux/kernel/el7/$basearch/
baseurl=https://mirrors.ustc.edu.cn/elrepo/archive/kernel/el7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
...
$ sudo yum makecache
$ sudo yum install -y kernel-lt kernel-lt-devel kernel-lt-headers 

Create building kernel docker instance:

$ sudo docker run -it buidrockykernel:latest /bin/bash
[root@6daba91116b7 /]# useradd -m mockbuild
[root@6daba91116b7 /]# su - mockbuild

In building container:

wget https://elrepo.reloumirrors.net/kernel/el9/SRPMS/kernel-lt-6.1.112-1.el9.elrepo.nosrc.rpm
rpm -Uvh kernel-lt-6.1.112-1.el9.elrepo.nosrc.rpm 
cd rpmbuild/
cd SPECS/
vim kernel-lt-6.1.spec 
cd ../SOURCES/
wget https://mirrors.ustc.edu.cn/kernel.org/linux/kernel/v6.x/linux-6.1.112.tar.xz
cd ../SPECS/
time rpmbuild -ba kernel-lt-6.1.spec 

44. lxd to incus

via:

lxd-to-incus --ignore-version-check

45. find installed gpus

via:

 lspci -nn | grep -i -E 'VGA|Display|3d' | grep -i -v "intel"

remove grub default items:

cp -r /etc/default/grub.d/ /root
vim *.cfg  # remove all of the unnecessary items

remove all of the dkms:

mv /usr/src /root
mkdir -p /root/varlibdkms
mv /var/lib/dkms/* /root/varlibdkms

/usr/lib/dkms/dkms_autoinstaller start 5.4.0-100-generic

47. oneline dkms

via:

ls /boot/initrd.img-* | cut -d- -f2- | \
    sudo xargs -n1 /usr/lib/dkms/dkms_autoinstaller start

48. pve lxc download

tips:

# pveam update
# pveam available
# pveam download local ubuntu-22.04-standard_22.04-1_amd64.tar.zst
downloading http://download.proxmox.com/images/system/ubuntu-22.04-standard_22.04-1_amd64.tar.zst to /var/lib/vz/template/cache/ubuntu-22.04-standard_22.04-1_amd64.tar.zst

template:

root@pve:/var/lib/vz/template/cache# scp ubuntu-22.04-standard_22.04-1_amd64.tar.zst dash@192.168.1.7:/media/big/

via:

  188  sudo lxc-create -n ubuntu2204 -t download -- --dist ubuntu --release jammy --arch amd64