编辑
2024-01-09
记录知识
0

ssh记录

记录一下ssh相关配置,随时查询用

免密登录

ssh-keygen -C name@mail.com ssh-copy-id -i ~/.ssh/id_rsa.pub root@ip

别名登录

ssh-keygen ssh-copy-id -i ~/.ssh/id_rsa.pub root@ip vim ~/.ssh/config Host tf HostName 172.25.80.123 Port 22 User root IdentityFile ~/.ssh/id_rsa ssh tf

ssh登录慢

  1. 使用root权限修改ssh的配置文件

vim /etc/ssh/sshd_config

增加一行记录:UseDNS no

  1. 关闭GSSAPI

发现:Next authentication method: gssapi-with-mic

vim /etc/ssh/sshd_config

vim /etc/ssh/ssh_config

修改GSSAPIAuthentication参数为no

远程备份

dd if=/dev/mmcblk1p4 | ssh root@ip dd of=~/backup.img

tar cvzf - package_dir/ | ssh root@ip "cd ~/backup ;cat >backup_file.tar.gz"

Root登录

/etc/ssh/sshd_config PermitRootLogin yes

allocation request failed on channel 0

mount devpts /dev/pts -t devpts

删除hosts

ssh-keygen -f "~/.ssh/known_hosts" -R ip

no matching key exchange method found. Their offer: diffie-hellman-group1-sha1

~/.ssh/config Host * KexAlgorithms +diffie-hellman-group1-sha1

tcp转发

AllowTcpForwarding 默认yes,可以no关闭

tun转发

PermitTunnel 是否允许 tun 设备转发。可用值如下: "yes", "point-to-point", "ethernet", "no"(默认) "yes"同时蕴含着"point-to-point"和"ethernet"
编辑
2024-01-08
记录知识
0

磁盘速度太慢

在使用服务器编译代码的时候,因为最近有一个组raid的过程,所以使用的空间是格式化过的。空间虽然大了,但是编译速度却下降很多,十分苦恼。

/dev/sdc1 7.3T 328G 6.6T 5% /root/public-workspace

主要原因是格式化时是直接使用mkfs.ext4命令格式,所以它默认带数据日志的。

ext文件系统的模式

ext4 支持多个模式

  1. Writeback 模式

Data ordering is not preserved, data may be written into the main file system after its metadata has been committed to the journal.

数据和日志写入主文件,但是无顺序的 2. Ordered 模式

All data are forced directly out to the main file system prior to its metadata being committed to the journal.

数据在写日志之前进入主文件

  1. Journal 模式

All data are committed into the journal prior to being written into the main file system. Enabling this mode will disable delayed allocation and O_DIRECT support.

所有数据到主文件都是在日志之后

注意的配置

  1. norecovery noload

Don't load the journal on mounting. Note that if the filesystem was not unmounted cleanly, skipping the journal replay will lead to the filesystem containing inconsistencies that can lead to any number of problems. 挂载时不加载日志,但是如果文件系统卸载不干净的时候将会导致文件系统的各类问题。

  1. commit=nrsec

Ext4 can be told to sync all its data and metadata every 'nrsec' seconds. The default value is 5 seconds. This means that if you lose your power, you will lose as much as the latest 5 seconds of work (your filesystem will not be damaged though, thanks to the journaling). This default value (or any low value) will hurt performance, but it's good for data-safety. Setting it to 0 will have the same effect as leaving it at the default (5 seconds). Setting it to very large values will improve performance. 设置commit的时间,默认5s,如果设置提交时间太短,则影响性能,设置时间过长可提高性能,但是异常断电的时候会丢最近nrsec的内容

设置

根据上面的介绍,我可以有两个方式

  1. 设置提交日志的时间 (更稳妥)
  2. 关闭日志 (更激进)

对于1,我选择60秒同步一次日志,如下设置(/etc/fstab)

LABEL=public-workspace /root/public-workspace ext4 nofail,auto,noatime,data=ordered,commit=60 0 0

对于2,我选择关闭日志,如下设置

LABEL=public-workspace /root/public-workspace ext4 nofail,auto,noatime,noload,norecovery 0 0

最后我选择2,选择权在自己手上,风险自己能把握住就行。

参考链接

https://www.kernel.org/doc/Documentation/filesystems/ext4.txt

编辑
2024-01-08
记录知识
0

ubuntu2004的chroot环境

工作需要ubuntu2004的chroot开发环境,故这里记录搭建ubuntu2004的chroot环境。

镜像地址

如下:

https://releases.ubuntu.com/20.04.6/

获取环境

mkdir iso && mount ubuntu-20.04.6-desktop-amd64.iso iso/ unsquashfs iso/casper/filesystem.squashfs umount iso && rm -rf iso

准备chroot

为了能够chroot的一些编译工作正常,更真实的模拟实际环境,这里需要和linux启动一致,挂载必要的文件系统如下:

vim 1-chroot #!/bin/bash CHROOT_DIR=/root/sdk/chroot/squashfs-root [ ! -d ${CHROOT_DIR} ] && exit cd ${CHROOT_DIR} mountpoint -q ./proc || mount -t proc proc ./proc mountpoint -q ./sys || mount -t sysfs sysfs ./sys mountpoint -q ./dev || mount -t devtmpfs devtmpfs ./dev mountpoint -q ./dev/pts || mount -t devpts devpts ./dev/pts chroot .

为了能够全局使用,可以放在/usr/local/sbin/下面

mv 1-chroot /usr/local/sbin/

到这里,chroot环境已经基本成型,下面需要针对这个chroot环境做一些易用的改动。

配置源

配置源之前先设置dns,这里是chroot环境,所以直接修改resolv.conf文件,这里以114为例

nameserver 114.114.114.114

然后修改源地址为国内,修改文件/etc/apt/sources.list如下

deb http://mirrors.aliyun.com/ubuntu/ focal main restricted deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted deb http://mirrors.aliyun.com/ubuntu/ focal universe deb http://mirrors.aliyun.com/ubuntu/ focal-updates universe deb http://mirrors.aliyun.com/ubuntu/ focal multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-updates multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted deb http://mirrors.aliyun.com/ubuntu/ focal-security universe deb http://mirrors.aliyun.com/ubuntu/ focal-security multiverse

最后update一下即可

禁止一些低级操作

为了避免reboot和一些低级操作,这里需要处理一下(在特殊情况下会生效),故如下

vim /etc/profile.d/chroot.sh hint_reboot(){ info="Forbidden reboot!" echo -e "\033[31m${info}\033[0m" } hint_poweroff(){ info="Forbidden poweroff!" echo -e "\033[31m${info}\033[0m" } hint_halt(){ info="Forbidden halt!" echo -e "\033[31m${info}\033[0m" } alias reboot='hint_reboot' alias poweroff='hint_poweroff' alias halt='hint_halt'

提示chroot

为了提示自己是在chroot环境中,修改bashrc如下:

vim /root/.bashrc # 1.修改TERM为xterm-color TERM=xterm-color cd source /etc/profile.d/chroot.sh # 2.修改\h为chroot 54 if [ "$color_prompt" = yes ]; then 55 # PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 56 PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@chroot\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' 57 else 58 PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' 59 fi ......

装包

基础开发环境包安装

apt-get install git ssh make gcc libssl-dev liblz4-tool expect \ g++ patchelf chrpath gawk texinfo chrpath diffstat binfmt-support \ qemu-user-static live-build bison flex fakeroot cmake gcc-multilib \ g++-multilib unzip device-tree-compiler ncurses-dev rsync gdb-multiarch \ openocd qemu-system-arm cargo doxygen apt-get install libgucharmap-2-90-dev bzip2 expat gpgv2 \ cpp-aarch64-linux-gnu libgmp-dev libmpc-dev bc python-is-python3 \ python2 libsqlite3-dev esmtp codespell python-ply mutt tig u-boot-tools \ meson ninja-build u-boot-tools build-essential devscripts breeze-dev \ debhelper extra-cmake-modules libcap-dev libxcb-composite0-dev \ libdrm-dev libgbm-dev libxcb-cursor-dev libxcb-damage0-dev \ libxcb-glx0-dev libxcb-randr0-dev libxcb-util-dev # 可能出现图形化服务器选择lightdm/gdm apt-get install libtool qtmultimedia5-dev \ libdbusmenu-qt5-dev libfcitx-qt5-dev libfcitx5-qt-dev \ libgsettings-qt-dev libkf5bluezqt-dev libkf5networkmanagerqt-dev \ liblightdm-qt5-3-dev libpolkit-qt5-1-dev libpoppler-qt5-dev \ libqt5charts5-dev libqt5opengl5-dev libqt5sensors5-dev \ libqt5svg5-dev libqt5texttospeech5-dev libqt5virtualkeyboard5-dev \ libqt5waylandclient5-dev libqt5webchannel5-dev libqt5webkit5-dev \ libqt5x11extras5-dev libqt5xdg-dev libqt5xdgiconloader-dev \ libqtav-dev libqtav-private-dev qt5-default qtbase5-dev \ qtbase5-dev-tools qtbase5-private-dev qtchooser \ qtconnectivity5-dev qtdeclarative5-dev qtdeclarative5-dev-tools \ qtdeclarative5-private-dev qtlocation5-dev qtmultimedia5-dev \ qtpositioning5-dev qtquickcontrols2-5-dev qtscript5-dev \ qttools5-dev qttools5-dev-tools qtwayland5-dev-tools \ qtwebengine5-dev qtwebengine5-private-dev libkdecorations2-dev \ libkf5xmlgui-dev libkf5crash-dev kscreenlocker-dev kinit-dev pkg-kde-tools

打包

umount dev/pts dev proc sysfs && cd ..
tar cvzf ubuntu-2004-develop.tar.gz squashfs-root/
至此获得ubuntu-2004-develop.tar.gz是可用于x86的ubuntu2004的chroot

导入docker

docker import ubuntu-2004-develop.tar.gz x86-ubuntu2004-dev:v1
这样docker内也能正常使用此环境

编辑
2023-10-19
记录知识
0

RK3588S开发板编译

自己购买了RK3588S的firefly的开发板,这里记录firefly板子的sdk编译方法。

Wiki地址

https://wiki.t-firefly.com/zh_CN/ROC-RK3588S-PC/linux_compile.html#huo-qu-sdk

仓库地址

firefly的gitlab仓库地址如下

https://gitlab.com/firefly-linux

拉取SDK

repo init --no-clone-bundle --repo-url https://gitlab.com/firefly-linux/git-repo.git -u https://gitlab.com/firefly-linux/manifests.git -b master -m rk3588_linux_release.xml 这里拉取在我的环境会报错,主要如下

  1. DeprecationWarning: the imp module is deprecated 这里好像是和python3不支持import imp模块,如果默认是python3的情况下,则需要修改为

import importlib

  1. str object has no attribute decode 然后继续运行,会出现如上错误,这里错误是没办法decode, image.png 根据百度搜索可知,去掉git_config.py内的decode函数即可。

  2. firefly的repo推荐使用python2 通过提示可知道,repo推荐你去使用python2,这里修改python为python2即可

ln -sf /usr/bin/python2 /usr/bin/python

同步代码

跟着文档走,直接如下命令同步即可

.repo/repo/repo sync -c --no-tags
.repo/repo/repo start firefly --all

后续可以使用以下命令更新 SDK:

.repo/repo/repo sync -c --no-tags

切换分支

这里默认分支用tag: rk3588/linux_release_v1.1.1d。需要主动切一下

编译uboot

注意uboot的make.sh,这里如果默认的CROSS_COMPILSE_ARM64变量有问题需要根据实际情况修改,如果没问题就无需修改 注意:编译uboot需要rkbin仓库,如没有rkbin仓库,则编译会因为无法编译miniloader而失败

-CROSS_COMPILE_ARM64=../prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- +# CROSS_COMPILE_ARM64=../prebuilts/gcc/linux-x86/aarch64/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu- +CROSS_COMPILE_ARM64=YOUR_PATH/gcc-linaro-6.3.1-2017.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-

编译命令如下

make rk3588_defconfig firefly-linux.config && ./make.sh

编译完成之后,会生成如下文件

uboot.img rk3588_spl_loader_v1.11.112.bin

修改

uboot通常不打开pcie的phy识别usb3.0,这里默认打开即可

diff --git a/configs/firefly-linux.config b/configs/firefly-linux.config index 503356b..3003d81 100644 --- a/configs/firefly-linux.config +++ b/configs/firefly-linux.config @@ -4,3 +4,4 @@ CONFIG_SPL_GPIO_SUPPORT=n CONFIG_DM_PCA953X=y CONFIG_SPL_FIT_IMAGE_KB=4096 CONFIG_CHECK_VERSION_CHOOSE_DTB=y +CONFIG_PHY_ROCKCHIP_NANENG_COMBOPHY=y

firefly的日志比较烦人,可以去掉

diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c index 50d75c6..172eb56 100644 --- a/drivers/power/regulator/fixed.c +++ b/drivers/power/regulator/fixed.c @@ -108,7 +108,7 @@ static int fixed_regulator_set_enable(struct udevice *dev, bool enable) struct fixed_regulator_platdata *dev_pdata = dev_get_platdata(dev); int ret; - printf("Firefly %s: dev='%s', enable=%d, delay=%d, has_gpio=%d\n", __func__, + debug("%s: dev='%s', enable=%d, delay=%d, has_gpio=%d\n", __func__, dev->name, enable, dev_pdata->startup_delay_us, dm_gpio_is_valid(&dev_pdata->gpio)); /* Enable GPIO is optional */

uboot提示Bus usb@xxxxxxxx: usb maximum-speed not found 比较奇怪,可以显示指明usb3为super speed,其实默认就是super speed。感觉不舒服的可以去掉(强迫症)

diff --git a/arch/arm64/boot/dts/rockchip/rk3588-firefly-port.dtsi b/arch/arm64/boot/dts/rockchip/rk3588-firefly-port.dtsi index dc1afd6..523353b 100644 --- a/arch/arm64/boot/dts/rockchip/rk3588-firefly-port.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3588-firefly-port.dtsi @@ -315,4 +315,5 @@ &usbdrd_dwc3_0 { dr_mode = "otg"; status = "okay"; + maximum-speed = "super-speed"; }; diff --git a/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi b/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi index 40a6986..e49f5fa 100644 --- a/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi +++ b/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi @@ -221,6 +221,7 @@ &usbhost_dwc3_0 { status = "okay"; dr_mode = "host"; + maximum-speed = "super-speed"; }; &vcc5v0_host { @@ -228,7 +229,7 @@ /delete-property/ regulator-min-microvolt; /delete-property/ regulator-max-microvolt; reset-delay-us = <200000>; - startup-delay-us = <1200000>; + //startup-delay-us = <1200000>; regulator-boot-on; gpio = <&gpio1 RK_PB6 GPIO_ACTIVE_HIGH>; pinctrl-names = "default";

uboot阶段开机慢,这里regulator这里上电故意停了1.2S,去掉也不影响

diff --git a/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi b/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi index 40a6986..e49f5fa 100644 --- a/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi +++ b/arch/arm64/boot/dts/rockchip/roc-rk3588s-pc.dtsi &vcc5v0_host { @@ -228,7 +229,7 @@ /delete-property/ regulator-min-microvolt; /delete-property/ regulator-max-microvolt; reset-delay-us = <200000>; - startup-delay-us = <1200000>; + //startup-delay-us = <1200000>; regulator-boot-on; gpio = <&gpio1 RK_PB6 GPIO_ACTIVE_HIGH>; pinctrl-names = "default";

编译内核

编译内核主要选择好了设备树和配置即可,rk3588s-roc-ps-v1.0的配置如下

export ARCH=arm64 export CROSS_COMPILE=aarch64-linux-gnu- make rockchip_linux_defconfig rk3588_linux.config firefly-linux.config make roc-rk3588s-pc-mipi101-M101014-BE45-A1.img -j8

值得注意的是,我的开发板并不需要mipi dsi显示和csi摄像头,所以设备树需要更换一下。

编辑
2023-09-25
记录知识
0

Nextcloud通过docker配置

家里配置了docker版本的nextcloud,本来默认使用latest的版本,但是latest的版本有问题,一个是没办法显示上传时间,另一方面是上传大于1G的文件会失败。网上找了各种php设置参数的方法无果,最终决定使用24.0.1版本,基于如下

docker安装

docker直接通过apt安装,如下

apt install docker-ce docker-compose

我这里使用的版本为

docker-ce=5:24.0.5-1~ubuntu.20.04~focal docker-compose=1.25.0.1

Nextcloud安装

docker pull nextcloud:24.0.1
docker run -d --restart=no --name nc -p 80:80 -v /1T:/var/www/html nextcloud

初始化

这时候就可以登录本机的80端口进行初始化安装了。

所有IP访问

nextcloud默认只能运行trusted_domains内的ip访问,网上有解决方法如下

nextcloud/config/config.php
1 => preg_match('/cli/i',php_sapi_name())?'127.0.0.1':$_SERVER['SERVER_NAME'],

数据权限0770不安全

因为自己开放了权限,这里为了避免nextcloud的提示警告,需要设置一下

nextcloud/config/config.php
'check_data_directory_permissions' => false,

网盘数据重扫描

为了避免网盘数据内容和实际目录内容更新不一致的情况,每次开机我都进行了一次数据更新,命令如下

docker exec nc php occ files:scan --all

提高上传性能

网上说设置max_chunk_size 可以提高性能,我试过了没用,但是也设置了,懒得研究

docker exec nc php occ config:app:set files max_chunk_size --value 0

提高网页响应速度

按照官网说明,把定期任务设置cron,然后在crontab里面写5分钟的定时任务可以提高网页的响应速度,如下

在真实环境下
crontab -e */5 * * * * docker exec nc php cron.php

设置了反正还是那样子,nextcloud也就基本能用而已。