找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 1664|回复: 4

[N1盒子] Ambian探索记录

[复制链接]
发表于 2020-3-26 20:05 | 显示全部楼层 |阅读模式
本帖最后由 strelizia 于 2020-3-29 00:08 编辑

Ambian探索记录
初始化
写入EMMCnano-sata-install
​
#安装系统至eMMC
连接Wi-Fi
ssh连接后执行
nmtui或armbian-config
选择第二个Activate a connection,按提示选择并输入密码即可
若Activate a connection中没有Wi-Fi选项卡则说明内核尚未开启wifi_dummy和dhd模块,执行如下指令即可
modprobe dhd && echo dhd >> /etc/modules
modprobe wifi_dummy && echo wifi_dummy >> /etc/modules
蓝牙连接
执行
armbian-config
进去后选择Network,接着选择BT Install,耐心等待蓝牙组件安装完毕,然后退出。
接着执行
apt install pulseaudio-module-bluetootharmbian-config
#安装pulseaudio组件
安装完成后,分别执行
killall pulseaudio
pulseaudio --start
#启动pulseaudio服务
开始进入蓝牙连接阶段,首先执行
hciconfig -a
#查看蓝牙控制器信息
确认无误后,执行
hciconfig hci0 up
#打开蓝牙控制器
然后执行
bluetoothctl#打开蓝牙管理器
先后执行
power ondiscoverable onagent onscan on#搜集周围的蓝牙设备
记录下要连接的设备地址后,执行
trust <设备地址>#信任设备pair <设备地址>#配对
此时,要配对的设备上可能会弹出提示,点确认。
如以上步骤都没有问题,则执行
connect <设备地址>
稍候即可顺利连接蓝牙,可以运行
info <设备地址>#确认状态
至此,N1盒子蓝牙连接完毕。

系统优化
修复MAC地址
建立脚本,root权限执行
#!/bin/bash#update:2019-11-11#author:alon2000#LAN_MAC=`ifconfig eth0 | grep -w ether | awk '{print $2}'`LAN_MAC=`cat /sys/class/net/eth0/address`MAC_HEAD=`echo $LAN_MAC|cut -c1-15`MAC_TAIL=`echo $LAN_MAC|cut -c16-17`MAC_TAILn=$((16#${MAC_TAIL}-1))WLAN_MAC="$(printf '%s%02x\n' $MAC_HEAD $[MAC_TAILn])"if [[ -f "/lib/firmware/brcm/brcmfmac43455-sdio.phicomm,n1.txt" ]] ; then  sed -i -e "s/^macaddr=b8:27:eb:74:f2:6c$/macaddr=$WLAN_MAC/" \    "/lib/firmware/brcm/brcmfmac43455-sdio.phicomm,n1.txt"fiif [[ -f "/lib/firmware/brcm/brcmfmac43455-sdio.txt" ]] ; then  sed -i -e "s/^macaddr=b8:27:eb:74:f2:6c$/macaddr=$WLAN_MAC/" \    "/lib/firmware/brcm/brcmfmac43455-sdio.txt"fiecho "WiFi MAC address modified successfully! reboot..."reboot


修改apt软件源为国内源
本文基于armbian 5.77 Debian
vim /etc/apt/sources.list
按 i 进入插入模式。
将文件内容替换成以下内容:
deb [ arch=arm64,armhf ] https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main contrib non-free#deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch main contrib non-freedeb [ arch=arm64,armhf ] https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main contrib non-free#deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-updates main contrib non-freedeb [ arch=arm64,armhf ] https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main contrib non-free#deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ stretch-backports main contrib non-freedeb [ arch=arm64,armhf ] https://mirrors.tuna.tsinghua.edu.cn/debian-security/ stretch/updates main contrib non-free#deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security/ stretch/updates main contrib non-free#deb [ arch=arm64,armhf ] https://mirrors.tuna.tsinghua.edu.cn/debian/ sid main contrib non-free
编辑完成按 Esc 退出插入模式,按 :wq 保存退出。
使用 apt-get 更新和升级软件包:
apt-get update && apt-get upgrade
在实际操作过程中,可能由于某个软件包的更新导致文件系统变为只读状态,此时 reboot 重启后重新更新就可。

设置时区
执行以下命令:
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo "Asia/Shanghai" > /etc/timezone
执行 date -R 查看时间是否正确。

开启 BBR
执行以下命令:
echo "net.core.default_qdisc=fq" >> /etc/sysctl.confecho "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.confsysctl -p
通过以下命令检查 BBR 是否启动:
sysctl net.ipv4.tcp_available_congestion_control# 返回值应为 net.ipv4.tcp_available_congestion_control = reno cubic bbrsysctl net.ipv4.tcp_congestion_control# 返回值应为 net.ipv4.tcp_congestion_control = bbrsysctl net.core.default_qdisc# 返回值应为 net.core.default_qdisc = fqlsmod | grep bbr# 返回值应包含 tcp_bbr 模块
关闭 serial-getty@ttyS0 服务
syslog 中每 10s 出现一次 ttyS0 服务启动失败的日志。不理它也没关系,但看着不舒服,所以:
systemctl stop serial-getty@ttyS0systemctl disable serial-getty@ttyS0systemctl stop syslog.servicesystemctl disable syslog.service
禁止/var/log日志
因为emmc存储是一种flash存储技术,其写入寿命非常有限,所以系统运行中应尽量避免数据写入。
如果我们没有装什么特殊程序的话,通常来说数据的主要写入就是/var/log目录的日志了,一天几十MB还是有的。
armbian其实已经考虑了这个问题,因为armbian就是给arm架构订制的debian发行版嘛,所以它默认是创建了一个内存盘(zram文件系统)挂载到了/var/log目录:
root@aml:/var/log# df -hFilesystem      Size  Used Avail Use% Mounted onudev            469M     0  469M   0% /devtmpfs           184M   22M  163M  12% /run/dev/mmcblk1p2  6.4G  2.1G  4.3G  33% /tmpfs           920M     0  920M   0% /dev/shmtmpfs           5.0M  4.0K  5.0M   1% /run/locktmpfs           920M     0  920M   0% /sys/fs/cgrouptmpfs           920M  8.0K  920M   1% /tmp/dev/mmcblk1p1  122M   58M   64M  48% /boot/dev/zram0       49M   15M   31M  32% /var/logtmpfs           184M     0  184M   0% /run/user/00
所以频繁的日志写入并不会直接伤害到emmc。
解决方法:
修改/usr/lib/armbian/armbian-ramlog脚本
syncToDisk () {        # no sync to protect emmc        return 0        isSafe         echo -e "\n\n$(date): Syncing logs from $LOG_TYPE to storage\n" | $LOG_OUTPUT         if [ "$USE_RSYNC" = true ]; then                ${NoCache} rsync -aXWv --delete --exclude armbian-ramlog.log --links $RAM_LOG $HDD_LOG 2>&1 | $LOG_OUTPUT        else                ${NoCache} cp -rfup $RAM_LOG -T $HDD_LOG 2>&1 | $LOG_OUTPUT        fi         sync}
Python
改变默认python版本
现成的aarch64的tensorflow轮子只支持python2.7和python3.5。系统默认使用的是2.7,所以要切换到3.5。
echo alias python=python3 >> ~/.bashrcsource ~/.bashrc
这时候可以查看一下版本
python -V
SyntaxError
# sudo vim /etc/profile
在末尾添上:
export LC_ALL="en_US.UTF-8"export LANG="zh_CN.GBK"
SSH 无法显示和输入中文
vi /etc/environment        ARCH=arm64        LC_ALL=″en_US.UTF-8″# 生效source /etc/environment
升级pip3
pip3 install --upgrade pippip3 -V #便可以看到当前的pip3版本
第三方库
apt install python3-pip python3-dev libpython3.5-dev libzmq-dev libgdal-dev apt install libxml2-dev libxslt1-dev zlib1g-dev libffi-dev libssl-devapt install build-essential libatlas-base-dev libgdal-dev  apt install python3-distlib python3-setuptools python3-wheelapt install python3-seleniumapt install python3-lxmlapt install python3-sklearnpip3 install requestspip3 install beautifulsoup4 pip3 install parselpip install twistedpip3 install w3libpip install cryptographypip install pyOpenSSLpip3 install Scrapy
Swap
使用 dd if 命令生成一个名为 swapfile 的空文件,放在 File System 下。
dd if=/dev/zero of=/swapfile bs=1M count=216chmod 777 /swapfile
标记为 Swap 文件并挂载。
mkswap /swapfileswapon /swapfile
执行 free -m,看到 Swap 已经被应用。
root@aml:/# free -m              total        used        free      shared  buff/cache   availableMem:           1838         187         925           5         725        1557Swap:          1135           5        1129
由于需要违禁词语,请勿再发载 /swapfile,很不方便,所以将其写入 /etc/fstab,实现开机自动挂载。
vi /etc/fstab
在该文件末尾追加挂载 /swapfile 的配置。
/swapfile none swap defaults 0 0
保存并退出。
环境部署及网站搭建
部署LNMP环境
在这里我选择的是军哥的lnmp一键包,当然你可以直接选择apt安装速度会快很多,只是易用性差点。
军哥LNMP一键包主页:https://lnmp.org/install.html
相关参数
无人值守模式 & LNMP架构&MySQL 5.5 &  启用InnoDB & 数据库Root 用户密码:strelizia & PHP 7.2 & 内存分配器 Jemalloc & Apache 2.4 & 管理员邮箱:admin@qq.com & 离线安装
命令wget http://soft.vpser.net/lnmp/lnmp1.6.tar.gz -cO lnmp1.6.tar.gz && tar zxf lnmp1.6.tar.gz && cd lnmp1.6 && LNMP_Auto="y" DBSelect="2" DB_Root_Password="strelizia" InstallInnodb="y" PHPSelect="8" SelectMalloc="2" CheckMirror="n" ./install.sh lnmppathinfo设置
解决typecho后台或其它404错误
修改/usr/local/nginx/conf/enable-php.conf 文件,添加pathinfo2.conf
location ~ [^/]\.php(/|$)     {            try_files $uri =404;            fastcgi_pass  unix:/tmp/php-cgi.sock;            fastcgi_index index.php;            include fastcgi.conf;            include pathinfo2.conf;     }
pathinfo2.conf
set $real_script_name $fastcgi_script_name;if ($fastcgi_script_name ~ "(.+?\.php)(/.*)") {set $real_script_name $1;set $path_info $2;}fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;fastcgi_param SCRIPT_NAME $real_script_name;fastcgi_param PATH_INFO $path_info;
如果除首页外全部404,则为伪静态规则问题,请使用以下伪静态规则:
location /{index index.html index.php;if (-f $request_filename/index.html){rewrite (.*) $1/index.html break;}if (-f $request_filename/index.php){rewrite (.*) $1/index.php;}if (!-f $request_filename){rewrite (.*) /index.php;}}
FRP外网映射FRP自启设置
创建frpc进程(注意服务端改成frps)
vi /lib/systemd/system/frps.service
将下面的内容中路径修改为对应你服务器上的文件路径,并填进去(注意不要使用/root目录,可能权限不足无法启动)
[Unit]Description=Frp Client ServiceAfter=network.target [Service]Type=simpleUser=nobodyRestart=on-failureRestartSec=5sExecStart=/usr/local/frp_0.27.0/frpc -c /usr/local/frp_0.27.0/frpc.iniExecReload=/usr/local/frp_0.27.0/frpc reload -c /usr/local/frp_0.27.0/frpc.ini [Install]WantedBy=multi-user.target
启动FRPC
systemctl start frpc
启用开机自启(FRPS同理)
systemctl enable frpc
挂载NTFS/exFAT设备
获得NTFS分区设备名,执行下面的命令:
fdisk -l | grep NTFS                #结果如下所示:/dev/sda1          65 1948282287 1948282223 929G 7 HPFS/NTFS/exFAT
建立装载点:
mkdir /disk      #建立/disk目录路径
给予特定的访问权限
chmod 777 /disk
装载NTFS分区,可以使用下面的命令以读写方式临时装载一个NTFS分区到装载点
mount -t ntfs-3g <NTFS Partition> <Mount Point>其中:   <NTFS Partition>  ------ NTFS所在分区的设备名,如/dev/sda1   <Mount Point>    ------ 装载点,如/media/share参考:mount -t ntfs-3g /dev/sda1 /disk
系统启动时装载NTFS分区,编辑:
vi /etc/fstab在文件最后增加如下格式的行<NTFS Partition> <Mount Point> ntfs-3g defaults 0 0其中: <NTFS Partition>  ------ NTFS所在分区的设备名,如1.1中的/dev/sda1 <Mount Point>    ------ 装载点,如1.2中的/media/share参考:/dev/sda1 /disk ntfs-3g defaults 0 0附录:卸载挂载区(备用)   umount /dev/sda1
使用udev自动挂载
编辑 /etc/udev/udev.conf 在最后添加
udev_root="/dev/"udev_rules="/etc/udev/rules.d"udev_log="err"
编辑 /etc/udev/rules.d/11-usbmount.rules文件名可以自定义 但要以.rules结尾
KERNEL=="sd[a-z][0-9]", RUN+="/etc/udev/mount_usb.sh $env{ACTION} %k"mkdir -p /usbdisk                #新建挂载目录
编辑 /etc/udev/mount_usb.sh由于系统问题导致不能使用udev自动挂载ntfs、exfat格式的usb存储设备,暂时未找到解决方法!ntfs格式需要安
装ntfs-3g exfat需要安装fuse-exfat和exfat-utils
#!/bin/bashusbdisk=/usbdiskif [ "$1" == "add" ]; then        ID_FS_TYPE=$(blkid -sTYPE -ovalue /dev/$2)        case $ID_FS_TYPE in                vfat)                        mount -t vfat -o noatime,umask=0,iocharset=utf8 /dev/$2 $usbdisk > /dev/null 2>&1                        sync                        ;;                ext[2-4])                        mount -o noatime /dev/$2 $usbdisk >/dev/null 2>&1                        sync                        ;;        #        exfat)        #                mount -t exfat -o noatime,umask=0,iocharset=utf8 /dev/$2 $usbdisk > /dev/null 2>&1        #                sync        #                ;;        #        ntfs)        #                mount -t ntfs-3g -o noatime,umask=0,iocharset=utf8 /dev/$2 $usbdisk > /dev/null 2>&1        #                sync        #                ;;                *)                        exit 0                        ;;        esacelif [ "$1" == "remove" ]; then        sync        umount -f $usbdiskfichmod a+x /etc/udev/mount_usb.sh                #给脚本执行权限
编辑 /lib/systemd/system/systemd-udevd.service
MountFlags=sharedsystemctl restart udev                #重启服务
软件安装
网页版管理cockpitapt-get install cockpit#安装后浏览器打开IP:9090
Samba
修改smb.conf文件
vi /etc/samba/smb.conf
可以删除[printers]及[profiles]
参考模板:
[media]   comment = Storage   path = /media   writable = yes   public = no   valid users = root   create mask = 0700
重启服务
service smbd restart
MiniDlna
安装MiniDlnaarmbian-config配置相关参数
查看硬盘挂载路径
df -h
编辑文件
vi /etc/minidlna.conf
参考:
media_dir=A,/sharedfolders/abc#其中A,代表是音乐文件。/sharedfolders/abc  是挂载硬盘的路径,根据自己的查看结果修改,不指定媒体文件A,P,V,可以不加举例:media_dir=A,/sharedfolders/abc        #音乐文件目录media_dir=P,/sharedfolders/abc        #图像文件目录media_dir=V,/sharedfolders/abc        #视频文件目录
重启,访问localhost:8200检验数据

Docker安装dockerarmbian-config
修改默认存储空间及镜像加速
修改docker默认存储空间到移动硬盘的方法.默认docker存储目录在/var/lib/docker,就是把这个文件夹移到移动硬盘下,然后创建一个软链接到移动硬盘(软连接貌似不好使,现修改如下)。
systemctl stop dockercd /var/libmv /var/lib/docker /储存目录ln -s /储存目录 /var/lib/dockervim /etc/docker/daemon.json{        "graph": /储存目录",        "storage-driver": "overlay" ,        "registry-mirrors": ["https://wdq1zej0.mirror.aliyuncs.com"]        }        systemctl start dockerdocker info #查看docker的默认存储目录-Docker Root Dir: /储存目录
安装图形化管理工具Portainer docker pull portainer/portainer:latestdocker run -d -p 9000:9000 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer:latest
docker镜像
80x86/typecho:latest
docker pull 80x86/typecho:latestdocker run -d -p 8000:80 --name typecho --restart=always -v /media/typecho:/data 80x86/typecho:latest
80x86/filebrowser:latest
docker pull 80x86/filebrowser:latest
80x86/qbittorrent:latest
docker pull 80x86/qbittorrent:latestdocker run  --name portainer --restart=always -v /disk:/downloads /media/qbittorrent/data:/data /media/qbittorrent/config:/config 80x86/qbittorrent:latest
adguard/adguardhome:arm64-latest
docker pull adguard/adguardhome:arm64-latestdocker run --name adguardhome -p 53:53/tcp -p 53:53/udp -p 67:67/udp -p 69:68/tcp -p 69:68/udp -p 3339:80/tcp -p 444:443/tcp -p 853:853/tcp -p 3333:3000/tcp -d adguard/adguardhome:arm64-latest
访问localhost:3333 初始化设置
访问localhost:3339 进入adguardhome控制面板
外加一个网址:https://github.com/otobtc/ADhosts  作者:otobtc
注意:https的443端口被映射成了444,启用https解析时端口不要写错
下面需要设置的地方:上游 DNS 服务器:114.114.114.114
Bootstrap DNS 服务器:114.114.114.114:53
最后把要启用设备的DNS设置成 N1 的IP地址即可!!!




如有遗误,敬请斧正!本教程主要是备忘,做个记录!


参考教程:
Python3.6 SyntaxError: ascii codec cant decode byte 0xe5 in position 7: ordinal not in range(128..._Python_weixin_30924239的博客-CSDN博客
ubuntu安装/查看已安装包的方法_运维_yessharing的博客-CSDN博客
linux 大神请进! samba服务器添加用户,在设置密码时出现了错误_百度知道
解决运行scrapy是报错No module named cryptography,解决cryptography的安装问题,解决libffi的安装问题 - xiaoli2018 - 博客园
小钢炮Docker的portainer面板安装不上的过来,教你手工安装方法+更新版本方法 - 斐讯无线路由器以及其它斐迅网络设备 - 恩山无线论坛 - Powered by Discuz!
斐讯N1折腾记 - Armbian 5.77 刷入与优化https://www.dragoncave.me/2019/07/armbian-on-n1.html
斐讯N1折腾记:运行 Linux 及优化https://www.mivm.cn/phicomm-n1-linux/
N1盒子Armbian折腾记https://segmentfault.com/a/1190000021386143
[N1盒子] 斐讯N1从刷ARMBIAN到宝塔当服务器https://www.right.com.cn/forum/f ... t%3D1%26typeid%3D21
(还有个教程链接找不着了,是论坛一大佬的,号称最完美的优化教程,找到了再补上)





评分

参与人数 1恩山币 +2 收起 理由
h*** + 2 感谢楼主全干货的分享!

查看全部评分

我的恩山、我的无线 The best wifi forum is right here.
发表于 2020-3-26 20:14 来自手机 | 显示全部楼层
收了吧,牛B
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-3-26 20:26 | 显示全部楼层
谢谢分享~~~~~~~~~
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-5-9 18:13 | 显示全部楼层
楼主硬核实力派,感谢!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2020-9-24 15:21 | 显示全部楼层
收藏了,感谢兄弟!
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-26 01:51

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表