Category: Linux

  • 在Radxa Zero 3上运行deepseek

    在Zero上编译非常痛苦,所以使用交叉编译:

    安装步骤
    更新包列表:

    sudo apt update
    安装交叉编译工具链:

    sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
    //gcc-aarch64-linux-gnu:ARM64架构的C编译器。

    //g++-aarch64-linux-gnu:ARM64架构的C++编译器。

    验证安装:

    aarch64-linux-gnu-gcc –version
    aarch64-linux-gnu-g++ –version

    1. 设置交叉编译环境
      在项目目录中创建一个 toolchain.cmake 文件,用于指定交叉编译工具链。

    创建 toolchain.cmake 文件
    cmake

    toolchain.cmake

    set(CMAKE_SYSTEM_NAME Linux)
    set(CMAKE_SYSTEM_PROCESSOR aarch64)

    set(CMAKE_C_COMPILER /usr/bin/aarch64-linux-gnu-gcc)
    set(CMAKE_CXX_COMPILER /usr/bin/aarch64-linux-gnu-g++)

    set(CMAKE_FIND_ROOT_PATH /usr/aarch64-linux-gnu)
    set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
    set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
    set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

    1. 交叉编译项目
      使用交叉编译工具链编译项目。

    步骤 1:生成构建文件

    cmake -B build -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake
    步骤 2:编译项目

    cmake –build build –config Release -j 2
    步骤 3:验证编译结果
    检查生成的可执行文件是否为ARM64架构:

    file build/my_program
    输出示例:

    build/my_program: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, not stripped

    1. 将程序复制到RK3566
      使用 scp 或U盘将编译好的程序复制到RK3566上运行。

    使用 scp 复制

    scp build/my_program user@rk3566_ip:/path/to/destination
    在RK3566上运行

    ./llama-server -m DeepSeek-R1-Distill-Qwen-1.5B-Q4_K_M.gguf –host 0.0.0.0

    使用精简蒸馏模型DeepSeek-R1-Distill-Qwen-1.5B-Q4_K_M.gguf

    结果还是非常意料之内的,缓慢无比。0.2 t/s

  • Radxa 3w zero connect wifi before login

    So here is the thing:
    I want to use one of my radxa 3w zero to be a light server, but for some reason their CLI version can not start up, which is insane. And I tried, it just stuck at the beginning.

    So I uninstalled the xfce of debian-xfce version. And everything I need were working properly.
    Except the Wi-Fi. It only connects when I login.

    I have tried several methods. And finally.

    At /etc/NetworkManager/system-connections/mywifi.nmconnection

    Then disable the line “permissions” and it works.

  • Protected: Delete a NVROM entry[reference]

    This content is password protected. To view it please enter your password below:

  • Fixed my corrupted database last night

    For some reason, I turned off the power switch last night, before I have done it, I forgot to shut down my home servers correctly. Then, it was not a surprise that the database on one of my Raspi crashed.
    In order to solve this problem, Follow the message it provide, use “journalctl -xe” command to show related information. Modify “my.cnf”, add ” innodb_force_recovery > 0 ” then start the database, afterward comment the ” innodb_force_recovery > 0″ line in again, restart the database subsequently. Done.

  • Use a SMB directory on Apache2

    Install samba client:

    apt-get install  samba-common smbclient samba-common-bin smbclient  cifs-utils
    
    mkdir /mnt/abc
    mount -t cifs //yourIP/yourShare /mnt/abc
    
    

    If you need to add credentials at the mount time:

    
    mount -t cifs //server/share /mnt/abc -o user=user,pass=password,dom=domain
    

    If you want to dismount the share later:

    umount /mnt/abc
    

    Mount permanently:

    sudo nano /etc/fstab
    

    Add: //server/share /mnt/abc cifs guest,uid=1000,iocharset=utf8,x-systemd.automount 0 0

    For more information visit:
    https://wiki.ubuntu.com/MountWindowsSharesPermanentlyUbuntu forum

    Access Permission(May not necessary):

    chown -R $USER:$USER /mnt/abc
    chmod -R 755 /mnt/abc
    

    Apache2 on Debian based OS:

    Modify apache2.conf add lines:

    <Directory /mnt/abc/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted

    Modify conf in sites-available directory:

        <VirtualHost *:80>
    DocumentRoot /mnt/abc
    ServerName myv.host.com
    ServerAlias myv.host.com
    ErrorLog logs/myvhost-error_log
    CustomLog logs/myvhost-access_log combined
    ServerAdmin [email protected]
    <Directory /mnt/abc/>
        AllowOverride All
        Options +Indexes
    </Directory>
    </VirtualHost>
    
    
  • Typecho出现数据库错误

    前几天突然发现我的树莓派数据库服务器挂了,想来是多次插拔移动硬盘导致意外重启,损坏了文件,表现为数据库无法运行,后来扒日志修复了。今天又突然发现租用的数据库也报错了,但查看数据库运行良好。想起来运营商发的邮件来,他们更新了管理套件相应的也会更新服务器环境。登陆phpadmin查看,是比较新的php7.1,数据库扩展有了变化,修改config.nic文件里的$db = new Typecho_Db(‘Mysql’, ‘xx_’);为“$db = new Typecho_Db(‘Pdo_Mysql’, ‘xx_’); 就好了。基本上遇到问题都不必惊慌,查log和搜索总能解决的。当然了,定时备份总没有坏处。

  • DD&fdisk

    fdisk和dd命令
    查看:
    $ sudo fdisk -u -l
    备份:
    $ dd bs=512 count=[fdisk命令中最大的end数+1] if=/dev/sda6 of=/sysbackup.img
    恢复:
    $ dd if=sysbackup.img of=/dev/sda
    压缩备份:
    $ dd bs=512 count=[fdisk命令中最大的end数+1] if=/dev/sda6 | gzip -6 > /sysbackup.img.gz
    恢复:
    $ gzip -dc /sysbackup.img.gz | dd of=/dev/sda

    最好先umount所有 if和of 设备的分区。后执行sudo sync。

    如果对整个硬盘进行备份和恢复 count=[fdisk命令中最大的end数+1] bs=512可以去掉。

    当你刚装完redhat 7.3第一次启动时,总会死掉。主要原因是Linux在安装时探测到有usb-uhci和ehci-hcd两个控制器,但在启动时,加载完usb-uhci再加载ehci-hcd就会有冲突。分析认为redhat7.3系统内核在支持USB2.0标准上存在问题。在其他版本的Linux中均不存在此问题。

    解决办法:在lilo或grub启动时用命令行传递参数init=/sbin/init。这样在启动后就不运行其他服务而直接启动shell。然后运行
    mount -o remount,rw / 使/ 可写,init直接启动的系统默认只mount /为只读
    然后vi /etc/modules.config文件(modules.conf)
    删除alias usb-controller1 ehci-hcd一行。或前面加#注释掉
    然后mount -o remount,ro / 使/ 只读,避免直接关机破坏文件系统
    然后就可以按Ctrl-Alt-Delete直接重启了
    或许,你有更简单的办法:换USB键盘和鼠标为PS2接口,启动后修改/etc/modules.config文件。
    linux压缩文件为.tar.gz的命令

    1. .tar格式

    解包: tar -xvf FileName.tar
    打包: tar -cvf FileName.tar DirName(注:tar是打包,不是压缩)

    1. .gz格式

    解压1:gunzip FileName.gz
    解压2:gzip -d FileName.gz
    压缩:gzip FileName

    1. .tar.gz格式

    解压: tar -zxvf FileName.tar.gz
    压缩: tar -zcvf Filename.tar.gz DirName

    1. .bz2格式

    解压1: bzip2 -d filename.bz2
    解压2: bunzip2 filename.bz2
    压缩: bzip2 -z filename

    1. .tar.bz2格式

    解压: tar -jxvf filename.tar.bz2
    压缩: tar -jcvf filename.tar.bz2 dirname

    1. .bz格式

    解压1: bzip2 -d filename.bz
    解压2: bunzip2 filename.bz

    1. .tar.bz格式

    解压:tar -jxvf filename.tar.bz

    1. .Z格式

    解压: uncompress filename.Z
    压缩:compress filename

    1. .tar.Z格式

    解压: tar -Zxvf filename.tar.Z
    压缩: tar -Zcvf filename.tar.Z dirname

    1. .tgz格式

    解压: tar -zxvf filename.tgz

    1. .tar.tgz格式

    解压: tar -zxvf filename.tar.tgz
    压缩: tar zcvf filename.tar.tgz filename

    1. .zip格式

    解压: unzip filename.zip
    压缩: zip Filename.zip dirname

    1. .lha格式

    解压: lha -e filename.lha
    压缩: lha -a filename.lha filename

    1. .rar格式

    解压: rar a filename.rar
    压缩: rar e filename.rar

  • Protected: Mysql

    This content is password protected. To view it please enter your password below:

  • 修改虚拟机网卡eth0

    修改文件/etc/sysconfig/network-scripts/ifcfg-eth0中的MAC为正确地址后
    (ifconfig -a中的)

    然后删除/etc/udev/rules.d/70-persistent-net.rules

    使用/etc/init.d/network restart 或reboot

  • Protected: 好记性不如烂键盘

    This content is password protected. To view it please enter your password below: