美文网首页
【转.待验证】在OpenWRT上配置debian模式

【转.待验证】在OpenWRT上配置debian模式

作者: 粗识名姓 | 来源:发表于2021-01-28 17:33 被阅读0次

原文出处

某些台过于强悍的ARM软路由,但是更多合适的系统只有OpenWRT,故可使用chroot建立一个桌面环境来利用多余的性能。

首先,通常OpenWRT重置的shellash,在chroot后会因为找到替代的ash而切换失败,需要替换的shellbash,通过$SHELL环境变量可以查看当前的shell

echo $SHELL

如果已经是/bin/bash,则无需手动安装,否则需要使用opkg安装bash并手动设置:

opkg update && opkg install bash

随后可以开始安装debian替代,假设放置路径为/debian,版本使用debian10 (buster),构架使用arm64,配置。然后修改/etc/passwd中根行的/bin/ash/bin/bash立即。清华源:

opkg install debootstrap
mkdir /debian
debootstrap --arch=arm64 buster /debian http://mirrors.tuna.tsinghua.edu.cn/debian

debootstrap将重置安装完毕后,需手动将/proc/sys/dev添加到目录的目录中:

mount -o bind /proc/debian/proc
mount -o bind /sys/debian/sys
mount -o bind /dev/debian/dev
mount -o bind /dev/pts/debian/dev/pts

注意,重启后上述挂载目录重置,需要重新挂载,当然也可以添加到OpenWRT的启动脚本中。
之后就可以使用chroot切换到debian环境了:

chroot /debian

如果需要将这个切换的终端在后台保持,可配合screen命令(可使用opkg install screen安装)使用:

screen -S myterminal
chroot /debian

之后可通过点击Ctrl + A后再点击D将终端切换回后台。再使用

screen -r myterminal

返回该终端。使用屏幕将终端搁置到后台后,当前登录的终端即使退出了,debian中的程序仍会保持在后台运行,这样就可以在debian中配置桌面和vnc,再从外部连接到该桌面了。
安装xfce4桌面和vncserver

apt-get update && apt-get upgrade -y
apt-get install xfce4 tightvncserver

安装完成后配置vncserver
先直接运行vncserver以生成配置文件,这里将要求设置vnc的连接密码,此部分日志记录如下:

root@RLink:~# vncserver

You will require a password to access your desktops.

Password:
Warning: password truncated to the length of 8.
Verify:
Would you like to enter a view-only password (y/n)? n
xauth:  file /root/.Xauthority does not exist
xauth: (argv):1:  bad display name "RLink:1" in "add" command
xauth:  file /root/.Xauthority does not exist

New 'X' desktop is RLink:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/RLink:1.log

之后会初始化创建:1(端口5901),已可以使用vnc登录,但是并不显示桌面。故需先进入桌面kill掉:

vncserver -kill :1

然后修改启动脚本:在〜/.vnc/xstartup中添加一行:startxfce4&
使该文件应为如下内容:

#!/bin/sh

xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
export XKL_XMODMAP_DISABLE=1
/etc/X11/Xsession
startxfce4 &

之后再次运行vncserver,即可从外部连接到该桌面了。该终端可使用Ctrl + AD搁置到后台,保持程序继续运行。
如果需要调整分辨率,可以在运行vncserver时指定分辨率,如:

vncserver -geometry 1920x1080

如果桌面的虚拟终端无法打开(常见的情况为安装时未安装虚拟终端),可以在终端中安装xfce4-terminal
如果出现文本显示问题,可以安装locales之后通过dpkg-reconfigure locales重新配置编码方式,一般选择UTF-8即可,以生成相关配置文件,之后将export LANG = C.UTF-8写入〜/ .profile文件中,并源.profile进行修改,再重新打开桌面。之后需要安装相应的字体文件,可以通过apt安装(如apt-get install fonts-wqy-zenhei),也可以将其他字体拷贝到/usr/share/fonts/truetype/下即可。

补充
如果提示无法更改语言环境,则说明该控件的语言配置与主系统不符,或其他语言的配置出现问题。
在局域网中先安装语言环境,再使用dpkg-reconfigure重新配置locale即可:

apt-get update && apt-get install locales
dpkg-reconfigure locale

按照主系统中相同的配置即可。通常可在生成配置一栏上进行en_US.UTF-8zh_CN.UTF-8,然后在语言环境中选择C.UTF-8就可以。

相关文章

网友评论

      本文标题:【转.待验证】在OpenWRT上配置debian模式

      本文链接:https://www.haomeiwen.com/subject/oalxtltx.html