时光 2021, 2 月

月度归档: 2021 年 2 月

曲淡歌
曲淡歌@admin

2021 年 2 月 27 日

树莓派安装openwrt并扩容overlay分区 

安装的参考

如何安装

步骤

  1. 使用disk genius把内存卡的分区删除,新建一个分区并采用fat32格式化
  2. 用win32diskimage写入镜像

出现问题:

  1. 其他电脑连接wifi
    后无法获取ip,而路由器插上网线后在上级路由里面也查不到ip

解决方案:

连接wifi【openwrt】后,手动修改电脑的ip:192.168.10.x,子网掩码24,网关192.168.10.1,然后就和op在同一网段了,此时访问192.168.10.1即可。

然后在op设置界面:【网络】-【接口】-【LAN】-【修改】里面,将【IPv4网关】设置为192.168.1.1,将【使用自定义的 DNS 服务器】设置为114.114.114.114,此时op便可以获取上级路由的网络(如果不清楚上级路由的情况,则改为dhcp协议,然后用ip扫描来找到op的lan地址)

扩容的参考资料

“【转载】树莓派安装openwrt后扩容-参考资料”

“【转载】openwrt的overlay分区不足解决方法”

使用fdisk扩容的尝试(使用另一台linux)

确定内存卡的盘符

拔掉openwrt的内存卡,换上linux的卡,输入命令:df -h查看硬盘情况

判断/dev/sda是装有openwrt的内存卡,其中2是装有系统的部分(猜测)

卸载盘符

umount /dev/sda2

用fdisk命令开始重新分区

  1. 进入分区程序sudo fdisk /dev/sda
  2. 查看当前分区情况:p
#终端
pi@raspberrypi:~ $ sudo fdisk /dev/sda
Welcome to fdisk (util-linux 2.33.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sda: 7.4 GiB, 7983857664 bytes, 15593472 sectors
Disk model: Storage Device
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xf222735e
Device     Boot   Start      End  Sectors  Size Id Type
/dev/sda1  *       8192   139263   131072   64M  c W95 FAT32 (LBA)
/dev/sda2        147456  2113535  1966080  960M 83 Linux
/dev/sda3       2113536 15593471 13479936  6.4G 83 Linux

删除分区2、3

删除分区:d

选择删除分区2:2

重复一次,删除3

重新新建分区2

然后新建分区:

分区类型选择主分区:p

分区号输入2:

起始扇区选择原来的点:147456

最后一个扇区选择默认:enter

这样就新建了一个分区2,并且分区包含了剩下的全部空间。

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sda1  *       8192   139263   131072   64M  c W95 FAT32 (LBA)
/dev/sda2        147456  2113535  1966080  960M 83 Linux
/dev/sda3       2113536 15593471 13479936  6.4G 83 Linux

Command (m for help): d
Partition number (1-3, default 3): 3

Partition 3 has been deleted.

Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Command (m for help): n
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (2048-15593471, default 2048): 147456
Last sector, +/-sectors or +/-size{K,M,G,T,P} (147456-15593471, default 15593471):

Created a new partition 2 of type 'Linux' and of size 7.4 GiB.
Partition #2 contains a squashfs signature.

Do you want to remove the signature? [Y]es/[N]o: n

Command (m for help): w

The partition table has been altered.
Syncing disks.

使修改生效

sudo e2fsck /dev/sda2
sudo resize2fs /dev/sda2

出现错误

pi@raspberrypi:~ $ sudo e2fsck /dev/sda2
e2fsck 1.44.5 (15-Dec-2018)
ext2fs_open2: Bad magic number in super-block
e2fsck: Superblock invalid, trying backup blocks...
e2fsck: Bad magic number in super-block while trying to open /dev/sda2

The superblock could not be read or does not describe a valid ext2/ext3/ext4
filesystem.  If the device is valid and it really contains an ext2/ext3/ext4
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
    e2fsck -b 8193 
 or
    e2fsck -b 32768 

/dev/sda2 contains a squashfs file system
pi@raspberrypi:~ $ sudo resize2fs /dev/sda2
resize2fs 1.44.5 (15-Dec-2018)
resize2fs: Bad magic number in super-block while trying to open /dev/sda2
Couldn't find valid filesystem superblock.

这个方法暂时无法使用

在openwrt里面直接扩容

查看设备

输入lsblk

得到

OpenWrt# lsblk
\NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0         7:0    0 787.3M  0 loop /overlay
mmcblk0     179:0    0   7.4G  0 disk
├─mmcblk0p1 179:1    0    64M  0 part /boot
└─mmcblk0p2 179:2    0   960M  0 part /rom

得知可以扩容的id为mmcblk0

开始扩容

fdisk /dev/mmcblk0

使用p查看分区

得到:

Command (m for help): p
Disk /dev/mmcblk0: 7.45 GiB, 7983857664 bytes, 15593472 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5452574f

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1 *      8192  139263  131072   64M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      147456 2113535 1966080  960M 83 Linux

得知还有6个多G的空间可用

mkfs.ext4 /dev/mmcblk0p3

第一次重启前全程记录

Using username "root".
root@192.168.1.177's password:
OpenWrt# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root               172.8M    172.8M         0 100% /rom
tmpfs                     1.9G      7.8M      1.8G   0% /tmp
/dev/loop0              785.3M    139.8M    645.4M  18% /overlay
overlayfs:/overlay      785.3M    139.8M    645.4M  18% /
/dev/mmcblk0p1           63.9M     17.3M     46.5M  27% /boot
tmpfs                   512.0K         0    512.0K   0% /dev
cgroup                    1.9G         0      1.9G   0% /sys/fs/cgroup
overlayfs:/overlay      785.3M    139.8M    645.4M  18% /opt/docker
OpenWrt# lsblk
\NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0         7:0    0 787.3M  0 loop /overlay
mmcblk0     179:0    0   7.4G  0 disk
├─mmcblk0p1 179:1    0    64M  0 part /boot
└─mmcblk0p2 179:2    0   960M  0 part /rom
OpenWrt# \fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.35.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 7.45 GiB, 7983857664 bytes, 15593472 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5452574f

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1 *      8192  139263  131072   64M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      147456 2113535 1966080  960M 83 Linux

Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3):
First sector (2048-15593471, default 2048): +3G
Value out of range.
First sector (2048-15593471, default 2048): +1G
Value out of range.
First sector (2048-15593471, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-15593471, default 15593471): +3G

Created a new partition 3 of type 'Linux' and of size 3 GiB.

Command (m for help): p
Disk /dev/mmcblk0: 7.45 GiB, 7983857664 bytes, 15593472 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5452574f

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1 *      8192  139263  131072   64M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      147456 2113535 1966080  960M 83 Linux
/dev/mmcblk0p3        2048 6293503 6291456    3G 83 Linux

Partition table entries are not in disk order.

Command (m for help): w
The partition table has been altered.
Failed to add partition 3 to system: Resource busy

The kernel still uses the old partitions. The new table will be used at the next reboot.
Syncing disks.

OpenWrt# fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.35.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 7.45 GiB, 7983857664 bytes, 15593472 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5452574f

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1 *      8192  139263  131072   64M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      147456 2113535 1966080  960M 83 Linux
/dev/mmcblk0p3        2048 6293503 6291456    3G 83 Linux

Partition table entries are not in disk order.

Command (m for help): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list free unpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script file
   O   dump disk layout to sfdisk script file

  Save & Exit
   w   write table to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table


Command (m for help): d
Partition number (1-3, default 3): 3

Partition 3 has been deleted.

Command (m for help): p
Disk /dev/mmcblk0: 7.45 GiB, 7983857664 bytes, 15593472 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5452574f

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1 *      8192  139263  131072   64M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      147456 2113535 1966080  960M 83 Linux

Command (m for help): w
The partition table has been altered.
Failed to remove partition 3 from system: No such device or address

The kernel still uses the old partitions. The new table will be used at the next reboot.
Syncing disks.

OpenWrt# fdisk /dev/mmcblk0

Welcome to fdisk (util-linux 2.35.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p
Disk /dev/mmcblk0: 7.45 GiB, 7983857664 bytes, 15593472 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5452574f

Device         Boot  Start     End Sectors  Size Id Type
/dev/mmcblk0p1 *      8192  139263  131072   64M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      147456 2113535 1966080  960M 83 Linux

Command (m for help): n
Partition type
   p   primary (2 primary, 0 extended, 2 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3): 3
First sector (2048-15593471, default 2048): 2113536
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2113536-15593471, default 15593471): +3G

Created a new partition 3 of type 'Linux' and of size 3 GiB.

Command (m for help): p
Disk /dev/mmcblk0: 7.45 GiB, 7983857664 bytes, 15593472 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x5452574f

Device         Boot   Start     End Sectors  Size Id Type
/dev/mmcblk0p1 *       8192  139263  131072   64M  c W95 FAT32 (LBA)
/dev/mmcblk0p2       147456 2113535 1966080  960M 83 Linux
/dev/mmcblk0p3      2113536 8404991 6291456    3G 83 Linux

Command (m for help): w
The partition table has been altered.
Syncing disks.

OpenWrt# mkfs.ext4 /dev/mmcblk0p3
mke2fs 1.45.6 (20-Mar-2020)
Discarding device blocks: done
Creating filesystem with 786432 4k blocks and 196608 inodes
Filesystem UUID: 84f1fcef-0224-4409-a211-45f800551e81
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

OpenWrt# reboot

重启后把以前的文件复制到扩容的文件夹

mount -t ext4 /dev/mmcblk0p3 /mnt/mmcblk0p3

发现该目录还不存在

OpenWrt# mount -t ext4 /dev/mmcblk0p3 /mnt/mmcblk0p3
mount: /mnt/mmcblk0p3: mount point does not exist.

于是先使用mkdir /mnt/mmcblk0p3mount -t ext4 /dev/mmcblk0p3 /mnt/mmcblk0p3

再使用df -h查询得到

OpenWrt# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root               172.8M    172.8M         0 100% /rom
tmpfs                     1.9G      7.5M      1.8G   0% /tmp
/dev/loop0              785.3M    139.8M    645.4M  18% /overlay
overlayfs:/overlay      785.3M    139.8M    645.4M  18% /
/dev/mmcblk0p1           63.9M     17.3M     46.5M  27% /boot
tmpfs                   512.0K         0    512.0K   0% /dev
cgroup                    1.9G         0      1.9G   0% /sys/fs/cgroup
overlayfs:/overlay      785.3M    139.8M    645.4M  18% /opt/docker
/dev/mmcblk0p3            2.9G      9.0M      2.7G   0% /mnt/mmcblk0p3

说明已经挂载成功

然后看看loop0指向的是哪个目录,发现overlay目录为/overlay

于是将其内容拷贝,命令为:cp -r /overlay/* /mnt/mmcblk0p3

然后卸载umount /dev/mmcblk0p3

提示busy,可以参考linux挂载卸载不掉 umount target is busy

不过因为op上没有安装相应的命令,于是我先尝试reboot

重启之后发现不会自动挂载,再次手动挂载mount -t ext4 /dev/mmcblk0p3 /mnt/mmcblk0p3

再次手动卸载umount /dev/mmcblk0p3

成功

打开openwrt的管理界面

【挂载点】-【生成配置】(如果找不到后面的设备可以使用这一步)-【(/mnt/mmcblk0p3)修改】

重启之后,成功!(之前失败是因为忘记勾选启用此挂载点)

2021 年 2 月 27 日 333

回复

曲淡歌
曲淡歌@admin

2021 年 2 月 27 日

【2021-03-08更新】关于思源笔记服务器docker的部署笔记 

思源笔记

docker服务的布置

  1. 拉取镜像b3log/siyuan
  2. 在宿主机/siyuan/conf下新建文件conf.json,并且提前创建/siyuan/data/思源笔记用户指南
  3. 输入命令docker run -v /siyuan/conf:/siyuan/conf -v /siyuan/data:/siyuan/data -p 6806:6806 b3log/siyuan --resident=true --conf=/siyuan/conf
    4.
内容为
{
   "url": "http://127.0.0.1:6806/siyuan/siyuan/思源笔记用户指南/",
   "name": "思源笔记用户指南",
   "auth": "",
   "user": "",
   "password": "",
   "path": "/siyuan/data/思源笔记用户指南"
}

然后得到我的思源笔记地址:地址

存在的问题

如图所示,无法创建新的文件夹,从而无法建立新的笔记

解决方案

参考资料:

思源笔记 docker 部署问题 – 链滴 (ld246.com)

关于完善思源笔记 dav 与文件管理的个人建议 – 链滴 (ld246.com)

思源 Docker 版不能删除配置的 dav – 链滴 (ld246.com)

有用信息

Docker 创建笔记本的话需要定死一个文件路径,类似在 Android 上那样。目前暂时还没有进行细节设计,如果目前就需要用的话请手动修改 conf.json。

image.png

在树莓派的openwrt中布置

其他流程一致,最后提示

stderr: standard_init_linux.go:211: exec user process caused "exec format error"
stderr: standard_init_linux.go:211: exec user process caused "exec format error"
stderr: standard_init_linux.go:211: exec user process caused "exec format error"

经过分析猜测问题来自于架构的不同,树莓派是arm架构,估计这个项目是x86的,于是前往dockerhub验证

不同架构下docker的兼容问题

docker run 失败 在logs中如下错误,standard_init_linux.go:211: exec user process caused “exec format error“

去github上查到一条可能相关的can’t deploy siyuan server with the docker images b3log/siyuan #1454

docker run -d -p 6806:6806 b3log/siyuan --resident=true

docker exec -it /bin/sh

应该不是这个问题,就是架构的锅

官方镜像地址

根据”#不同架构下docker的兼容问题#”

可知:

解决办法
既然问题根源找到了 ,那就好办了 ,只需要在当前arch的linux上重新docker build 就行 。

docker build相关

Docker build 命令

参考上述资料,打算使用 -f Dockerfile 文件的位置:

$ docker build -f /path/to/a/Dockerfile .

因此需要找到之前pull的image存储位置

猜测是

/opt/docker/vfs/dir/0f1818c5db9de0fcb5b31faeee1bd89cc3ac263d22e854accac223fdbf6e8ef5/

因此命令为docker build -f /opt/docker/vfs/dir/0f1818c5db9de0fcb5b31faeee1bd89cc3ac263d22e854accac223fdbf6e8ef5/

错误! dockerfile是一种特殊的文件,用来描述如何构建一个image

然后,我不会了。就这样吧,下次继续研究。

2021-03-02更新 支持docker打开本地文件啦(2:10 周三,镜像似乎还没更新)

更新日志

Adds booting param for Docker: --data for specifying the path of the data.

拉取命令docker pull b3log/siyuan

因此命令应该为:

docker run -v /siyuan/conf:/siyuan/conf -v /siyuan/data:/siyuan/data -p 6806:6806 b3log/siyuan --resident=true --conf=/siyuan/conf --data=/siyuan/data

2021-03-08 发现使用宝塔的docker管理面板无法获取最新镜像

因此使用命令docker images查看镜像

得到

[root@iz2zehokmzpppxxwrsifshz ~]# docker images
REPOSITORY                     TAG                 IMAGE ID            CREATED             SIZE
b3log/siyuan                   latest              01a241c3b07b        7 weeks ago         133MB
b3log/solo                     latest              2bc398af448b        2 months ago        143MB
radhifadlillah/shiori          latest              69e24681b088        6 months ago        422MB
moritanosuke/wallabag-docker   latest              495f85187162        4 years ago         626MB

然后使用docker rmi 删除目标镜像

这里应该为docker rmi 01a241c3b07b

然后再使用docker pull b3log/siyuan

docker run -v /siyuan/conf:/siyuan/conf -v /siyuan/data:/siyuan/data -p 6806:6806 b3log/siyuan --resident=true --conf=/siyuan/conf --data=/siyuan/data

我发现阿里云,科大的镜像加速更新都很慢,目前最好用的是网易

网易加速地址:https://hub-mirror.c.163.com/

成功进入之后发现需要用户名和密码,用户名为siyuan,密码是随机生成的,在conf.json里面查看

如何让网页版思源和我的webdav共用文件?

思路:因为webdav的目录在wwwroot下,而docker部署的在siyuan/data下,无法直接让这两个文件夹合一,那么可以使用目录链接的方式让二者共享文件吗?

方案

  1. 【不可行】重新构建docker,把数据的位置指定到webdav的目录

那么启动命令应该为:docker run -v /siyuan/conf:/siyuan/conf -v /siyuan/data:/siyuan/data -p 6806:6806 b3log/siyuan --resident=true --conf=/siyuan/conf --data=/www/wwwroot/47.93.237.242/dav

发现怎么都不行,估计是权限的问题

  1. 【可行】重建webdav,将目录改到思源的目录
    参考#搭建webdav#

将其中的代码改为:

location / {
        root /siyuan/data;
        #client_max_body_size 102400M;#大文件支持
        autoindex on;
        dav_methods PUT DELETE MKCOL COPY MOVE;
        # 需要 nginx-dav-ext-module 才有下面的选项
        dav_ext_methods PROPFIND OPTIONS LOCK UNLOCK;
        create_full_put_path  on;
    }

此时webdav的配置如下(此处在博客脱敏)
我的webdav地址(注意此处没有dav了)

id

密码

新的问题:#链接webdav后部分文件夹不可见#

连接webdav后只能看到【极客】文件夹,后来发现只要把之前的文件夹改名就能刷新出来,推测是以前的文件修改导致识别不到

保持docker开启

使用发现思源笔记的docker在有时会宕机,因此需要设置一个自动重启,使用docker container update --restart=always

输入为:docker container update --restart=always 4ec8fe06a520

#思源笔记
2021 年 2 月 27 日 327
  • ii.kiss

    2021 年 3 月 28 日

    请问具体步骤和相关设置参数都是什么?我在群晖上想安装一下,但一直都搞不定

    • 曲淡歌

      2021 年 3 月 31 日

      1.拉取镜像
      2.按照上面的代码 docker run..hvo
      大概步骤是这样的,过程我都有记录,有具体的问题你可以写在评论区,群晖的图形界面操作我就不清楚了,建议用命令行

曲淡歌
曲淡歌@admin

2021 年 2 月 22 日

树莓派安装openwrt做软路由使用 

参考资料

固件下载

安装说明

如何安装(转载)

固件格式区别

固件文件名中带有factory字样的文件为安装固件,固件文件名中带有sysupgrade字样的文件为升级固件。固件文件名中带有ext4字样的文件为搭载ext4文件系统固件,ext4格式的固件更适合熟悉Linux系统的用户使用,可以比较方便地调整ext4分区的大小;
固件文件名中带有squashfs字样的文件为搭载squashfs文件系统固件,而squashfs格式的固件适用于“不折腾”的用户,其优点是可以比较方便地进行系统还原(控制面板-系统-备份/升级),哪怕你一不小心玩坏固件,只要还能进入控制面板,就可以很方便地进行“系统还原操作”。以下安装和升级步骤仅适用于树莓派,竞斗云或x86_64设备请按各自原有步骤进行安装/升级操作。

安装

下载固件文件名中带有factory字样的文件到本地,解压即可得到factory格式的img镜像文件。其中,文件名中带有ext4字样的为ext4固件,文件名中带有squashfs字样的为squashfs格式固件,为了避免一些玄学问题,小苏强烈推荐大家按以下步骤操作 :1.将SD卡插入电脑,使用DiskGenius或者PartitionGuru或类似的磁盘管理工具删除SD卡中的所有分区;2.在SD卡中新建一个Fat32分区,保存更改并格式化。此时SD卡便还原为出厂状态;3.使用Win32DiskImager或者Etcher将img固件写入SD卡。如果不按以上步骤操作,很可能在刷入固件后出现无法保存配置,LuCI崩溃的情况。

#[6]
2021 年 2 月 22 日 251
曲淡歌
曲淡歌@admin

2021 年 2 月 22 日

如何用树莓派做WIFI热点发射端/usb共享网络从而做到主动连接树莓派 

参考资料:

1.设置固定IP

2.vnc提示cannot currently show the desktop的解决办法

3.从零开始:树莓派共享 WiFi 秒变无线热点(树莓派路由器

4.树莓派安装 OpenWrt 打造超级路由器

我的usb网段

手机 192.618.186.255
树莓派 192.165.186.30

usb0: flags=4163  mtu 1500
inet 192.168.186.30  netmask 255.255.255.0  broadcast 192.168.186.255
inet6 2408:8466:aa30:213:28ed:8639:45a7:c3d0  prefixlen 64  scopeid 0x0
inet6 fe80::e72c:920a:3992:f2fc  prefixlen 64  scopeid 0x20
ether 42:7d:fe:0f:9f:b0  txqueuelen 1000  (Ethernet)
RX packets 74  bytes 7292 (7.1 KiB)
RX errors 0  dropped 0  overruns 0  frame 0
TX packets 82  bytes 14847 (14.4 KiB)
TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

范例(软件):

interface eth0

static ip_address=192.168.0.10/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

interface wlan0

static ip_address=192.168.0.200/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

范例(树莓派文件):

#interface eth0

#static ip_address=192.168.0.10/24

#static ip6_address=fd51:42f8:caae:d92e::ff/64

仿写:

先输入


sudo nano /etc/dhcpcd.conf

interface usb0
static ip_address=192.168.186.30/24          
static ip6_address=2408:8466:aa30:213:28ed:8639:45a7:c3d0/64

成功!!

#[6]
2021 年 2 月 22 日 165
曲淡歌
曲淡歌@admin

2021 年 2 月 22 日

【转载】刘慈欣在美国版三体后附录的后记全文 

刘慈欣在美国版三体后附录的后记全文

这篇后记是只有美国出版的三体有的

AUTHOR’S POSTSCRIPT FOR THE AMERICAN EDITION

A night from my childhood remains crisply etched in my memory: I was standing by a pond before a village somewhere in Luoshan County, Henan Province, where generations of my ancestors had lived. Next to me stood many other people, both adults and children. Together, we gazed up at the clear night sky, where a tiny star slowly glided across the darkfirmament.

It was the first artificial satellite China had ever launched: Dongfanghong I (“The East is Red I”). The date was April 25, 1970, and I was seven.

It had been thirteen years since Sputnik had been launched into space, and nine years since the first cosmonaut had left the Earth. Just a week earlier, Apollo 13 had safely returned from a perilous journey to the moon.

But I didn’t know any of that. As I gazed at that tiny, gliding star, my heart was filled with indescribable curiosity and yearning. And etched in my memory just as deeply as these feelings was the sensation of hunger. At that time, the region around my village was extremely poor. Hunger was the constant companion of every child. I was relatively fortunate because I had shoes on my feet. Most of the friends standing by my side were barefoot, and some of the tiny feet still had unhealed frostbite from the previous winter. Behind me, faint light from kerosene lamps shone out of cracks in the walls of dilapidated thatched huts—the village wasn’t wired for electricityuntil the eighties.

美国版后记

童年的一个夜晚清晰地刻在我的记忆里:我站在河南省罗山县某村庄的池塘边,我的祖辈曾在这里生活过几代。我旁边站着许多人,有大人也有孩子。我们一起仰望着晴朗的夜空,一颗小星星缓缓划过暗淡的天际。

这是中国发射的第一颗人造卫星:东方红一号。那一天是1970年4月25日,我七岁。

从“斯普特尼克号”(人类第一颗人造卫星)发射到太空已经13年,从第一位宇航员飞出地球也有9年。就在一周前,“阿波罗13号”从险象环生的登月飞行中安全返回月球。

但这些我都不知道。当我凝视着那颗小小的、滑翔的星星时,我的心中充满了难以形容的好奇和向往。

而让我感同身受且记忆深刻的,是腹中的饥饿。那时,这个地区非常贫穷。饥饿伴随着每一个孩子。我比较幸运,因为我的脚上有鞋子。站在我身边的朋友,大部分都是光着脚的,有些小脚丫还长着前一年冬天的冻疮,没有痊愈。在我身后,微弱的煤油灯从破茅草屋墙上的缝隙中透出昏暗的光线——这个村子直到20世纪80年代才通电。

The adults standing nearby said that the satellite wasn’t like an airplane because it flew outside of the Earth. Back then the dust and smoke of industry hadn’t yet polluted the air, and the starry sky was especially clear, with the Milky Way clearly visible. In my mind, the stars that filled the heavens weren’t much farther away than the tiny, gliding satellite, and so I thought it was flying among them. I even worried that it might collide with one as it passed through the dense stellar clusters.

My parents weren’t with mebecause they were working at a coal mine more than a thousand kilometers away, in Shanxi Province. A few years earlier, when I had been even younger, the mine had been a combat zone for the factional civil wars of the Cultural Revolution. I remembered gunshots in the middle of the night, trucks passing in the street, filled with men clutching guns and wearing red armbands.… But I had been too young back then, and I can’t be sure whether these images are real memories, or mirages constructed later. However, I know one thing for certain: Because the mine was too unsafe and my parents had been impacted by the Cultural Revolution, they had had no choice but to send me to my ancestral home village in Henan. By the time I saw Dongfanghong I, I had already lived there for more than three years.

站在旁边的大人说,这颗卫星可不像飞机,它是飞离地球之外的。那时的大气层还没有被工业粉尘和废气污染,繁星璀璨,银河系清晰可见。在我看来,满天星星的距离并不比那颗滑翔的小卫星远多少,所以我想它正飞向星星中间。我甚至担心,它在经过密集的恒星团时会撞上其中一颗。

我的父母不和我在一起,因为他们在一千多公里外的山西省一个煤矿工作。几年前,当我还年轻的时候,矿井一直是文革派系内部的作战区。我记得半夜的枪声, 卡车在街上经过, 满是拿着枪, 戴着红色臂章的男人。但当时我太年轻了,我不能确定这些图像是真实的记忆,还是后来的幻想。然而,我知道一件事:因为矿井太不安全,我的父母也受到了文革的影响,他们别无选择,只能把我送到祖籍地河南。看到东方红的时候,我已经在那里住了三年多了。

A few more years passed before I understood the distance between that satellite and the stars. Back then I was reading a popular set of basic science books called A Hundred Thousand Whys. From the astronomy volume, I learned the concept of a light-year. Before then, I had already known that light could traverse a distance equal to seven and a half trips around the Earth in a single second, but I had not contemplated what kind of terrifying distance could be crossed by flying at such a speed for a whole year. I imagined a ray of light passing through the cold silence of space at the speed of 300,000 kilometers per second. I struggled to grasp the bone-chilling vastness and profundity with my imagination, felt the weight of an immense terror and awe, and simultaneously enjoyed a druglike euphoria.

From that moment, I realized that I had a special talent: Scales and existences that far exceeded the bounds of human sensory perception—both macro and micro—and that seemed to be only abstract numbers to others, could take on concrete forms in my mind. I could touch them and feel them, much like others could touch and feel trees and rocks. Even today, when references to the 15-billion-light-year radius of the universe and “strings” many orders of magnitude smaller than quarks have numbed most people, theconcepts of a light-year or a nanometer can still produce lively, grand pictures in my mind and arouse in me an ineffable, religious feeling of awe and shock. Compared to most of the population who do not experience such sensations, I don’t know if I’m lucky or unlucky. But it is certain that such feelings made me first into a science fiction fan, and later a science fiction author.

过了几年,我才明白那颗卫星和星星之间的距离。当时我正在读一套流行的基础科学书籍,叫做《十万个为什么》。从天文学卷中,我学会了光年的概念。在此之前,我已经知道光可以在一秒钟内穿越相当于七次半左右地球飞行的距离,但我并没有想过以如此快的速度飞行一整年能跨越怎样的可怕距离。我想象着一束光以30万公里/秒的速度穿过寒冷寂静的太空。我努力用我的想象力抓住那令人战栗的深远和辽阔,感受到巨大的恐怖和沉重的敬畏, 同时享受着药物般的兴奋。

从那一刻起,我意识到我有一种特殊的天赋:那些远远超出人类感官范围的尺度存在——无论是宏观还是微观——对别人来说似乎只是抽象的数字,在我脑海中却可以呈现出具象的画面,我可以触摸它们,感受它们,就像其他人可以触摸树木和岩石一样。即使在今天,150亿光年的宇宙半径和比夸克小很多数量级的“弦”令大多数人麻木时,一光年或一纳米的概念仍然能在我的脑海中产生形象且宏伟的画面,并在我心中唤起一种难以言喻的、宗教般的敬畏和震撼感。与大多数没有这种感觉的人相比,我不知道我是幸运还是不幸。但可以肯定的是,这样的感受让我先成为一个科幻迷,后来又变成了科幻作家。

In that same year when I was first awed by the concept of a light-year, a flood (known as the Great Flood of August ’75) occurred near my home village. In a single day, arecord-breaking 100.5 centimeters of rain fell in the Zhumadian region of Henan. Fifty-eight dams of various sizes collapsed, one after another, and 240,000 people died in the resulting deluge. Shortly after the floodwaters had receded, I returned to the village and saw a landscape filled with refugees. I thought I was looking at the end of the world.

And so, satellite, hunger, stars, kerosene lamps, the Milky Way, the Cultural Revolution’s factional civil wars, a light-year, the flood … these seemingly unconnected things melded together and formed the early part of my life, and also molded the science fiction I write today.

在我第一次被光年所震撼的那年,我的家乡附近发生了一场洪水(1975年8月大洪灾)。一天之内,河南驻马店的降雨量突破了100.5厘米。58座大小不一的水坝相继倒塌,24万人死于这场洪灾。洪水退去后不久,我回到村子,已是满目疮痍,到处都是灾民,恍若世界末日的感觉。

于是,卫星、饥饿、繁星、煤油灯、银河、文革、光年、洪水……这些看似无关的事物融合在一起,成为我早年人生的元素,也塑造了我今天的科幻作品。

As a science fiction writer who began as a fan, I do not use my fiction as a disguised way to criticize the reality of the present. I feel that the greatest appeal of science fiction is the creation of numerous imaginary worlds outside of reality. I’ve always felt that the greatest and most beautiful stories in the history of humanity were not sung by wandering bards or written by playwrights and novelists, but told by science. The stories of scienceare far more magnificent, grand, involved, profound, thrilling, strange, terrifying, mysterious, and even emotional, compared to the stories told by literature. Only, these wonderful stories are locked in cold equations that most do not know how to read.

The creation myths of the various peoples and religions of the world pale when compared to the glory of the big bang. The three-billion-year history of life’s evolution from self-reproducing molecules to civilization contains twists and romances that cannot be matched by any myth or epic.

作为一个“科幻迷”出身的科幻作家,我不会用我的小说来隐喻和批判现实。我觉得科幻小说最大的魅力是创造许多现实以外的虚构世界。我一直认为,人类历史上最伟大、最美丽的故事不是由吟诵诗人唱的,不是剧作家和小说家写的,而是由科学讲述的。与文学讲述的故事相比,科学讲的故事更加宏伟壮丽、纷繁复杂、惊悚跌宕、恐怖神秘,甚至更加多愁善感,韵味无穷。只是,这些精彩的故事被锁定在冷方程中,大多数人难以读懂。

与大爆炸的荣耀相比,世界各民族和宗教的创造神话显得苍白无力。生命从可自我复制的分子到智慧文明的30亿年进化史包含着任何神话或史诗都无法比拟的曲折和浪漫。

There is also the poetic vision of space and time in relativity, the weird subatomic world of quantum mechanics … these wondrous stories of science all possess an irresistible attraction. Through the medium of science fiction, I seek only to create my own worlds using the power of imagination, and to make known the poetry of Nature in those worlds, to tell the romantic legends that have unfolded between Man and Universe.

But I cannot escape and leave behind reality, just like I cannot leave behind my shadow. Realitybrands each of us with its indelible mark. Every era puts invisible shackles on those who have lived through it, and I can only dance in my chains. In science fiction, humanity is often described as a collective. In this book, a man named “humanity” confronts a disaster, and everything he demonstrates in the face of existence and annihilation undoubtedly has sources in the reality that I experienced. The wonder of science fiction is that it can, when given certain hypothetical world settings, turn what in our reality is evil and dark into what is righteous and bright, and vice versa. This book and its two sequels try to do just that, but no matter how reality is twisted by imagination, it ultimately remains there.

相对论中有宏观时空的诗意视觉,量子力学中有诡异的亚原子微观世界……这些奇妙的科学故事都具有不可抗拒的吸引力。通过科幻小说的媒介,我利用想象力创造我自己的世界,揭示自然在那些世界中的诗歌,讲述人类和宇宙之间展开的浪漫传说。

但我不能逃避和脱离现实,就像我不能脱离我的影子。现实在每个人身上都标注了不可磨灭的烙印。每个时代都给经历过它的人戴上了无形的枷锁,我只能在这个枷锁中跳舞。在科幻小说中,人类经常被描述为一个整体。在这本书中,一个名叫”人类”的整体面临着灭顶之灾,他们在面对生存和毁灭时所展现出来的一切,无疑都来源于我所经历过的现实。科幻小说的奇迹是, 当我们给某些世界特殊的设定, 它可以把我们现实中邪恶和黑暗的东西变成光明和正义的,反之亦然。《三体》系列试图做到这一点,但无论现实如何被想象力扭曲,它仍然在那里。

I’ve always felt that extraterrestrial intelligence will be the greatest source of uncertainty for humanity’s future. Other great shifts, such as climate change and ecological disasters, have a certain progression and built-in adjustment periods, but contact between humankind and aliens can occur at any time. Perhaps in ten thousand years, the starry skythat humankind gazes upon will remain empty and silent, but perhaps tomorrow we’ll wake up and find an alien spaceship the size of the moon parked in orbit. The appearance of extraterrestrial intelligence will force humanity to confront an Other. Before then, humanity as a whole will never have had an external counterpart. The appearance of this Other, or mere knowledge of its existence, will impact our civilization in unpredictable ways.

我一直觉得外星文明将是人类未来最大的隐忧。其他的大变故,如气候变化和生态灾难,都有一定的过程和缓冲适应期,但人类与外星人的接触随时可能发生。也许一万年后,人类凝视的星空仍将空无一物,寂静无声,但也许明天醒来时,就发现一艘和月球一样大的外星飞船停在地球轨道上。外星文明的出现将迫使人类对抗另一个“他者”。在那之前,人类作为一个整体,从未接触过来自外部的对应物。这个“他者”的出现,或者仅仅知道“他者”的存在,都将对我们的文明产生不可预知的影响。

There’s a strange contradiction revealed by the naïveté and kindness demonstrated by humanity when faced with the universe: On Earth, humankind can step onto another continent, and without a thought, destroy the kindred civilizations found there through warfare and disease. But when they gaze up at the stars, they turn sentimental and believe that if extraterrestrial intelligences exist, they must be civilizations bound by universal, noble, moral constraints, as if cherishing and loving different forms of life are parts of a self-evident universal code of conduct.

I think it should be precisely the opposite: Let’s turn the kindnesswe show toward the stars to members of the human race on Earth and build up the trust and understanding between the different peoples and civilizations that make up humanity. But for the universe outside the solar system, we should be ever vigilant, and be ready to attribute the worst of intentions to any Others that might exist in space. For a fragile civilization like ours, this is without a doubt the most responsible path.

As a fan of science fiction, it has molded my life, and aconsiderable part of the science fiction I’ve read comes from America. The fact that American readers can now enjoy my book makes me both pleased and excited. Science fiction is a literature that belongs to all humankind. It portrays events of interest to all of humanity, and thus science fiction should be the literary genre most accessible to readers of different nations. Science fiction often describes a day when humanity will form a harmonious whole, and I believe the arrival of such a day need not wait for the appearance ofextraterrestrials.

人类面对宇宙时所表现出的天真和善良揭示出一种矛盾:在地球上,人类可以毫无顾忌地踏进另一个大陆,通过战争和瘟疫摧毁那里的同胞。但是,当他们凝望星星时,却变得感性,他们相信,如果外星文明存在,它们当然是受普遍、高尚、道德约束的文明,仿佛珍爱其他文明是理所当然的宇宙行为准则。

我认为应该恰恰相反:让我们把对外星人的善意转移到地球的人类同胞身上,建立不同民族和文明之间的信任和理解。但对于太阳系以外的宇宙,我们应该时刻保持警惕,并将最坏的恶意归于太空中可能存在的任何人。对于像我们这样弱小的文明来说,这无疑是最负责任的道路。

作为科幻小说的粉丝,它塑造了我的生活,我读过的科幻小说中,有一部分来自美国。我很高兴美国读者现在可以享受我的书。科幻小说是属于全人类的文学作品。它描绘了全人类感兴趣的事件,因此科幻小说应该是不同国家读者最易接触到的文学流派。科幻小说经常描述人类将形成一个和谐的整体,我相信这一天的到来不需要等待外星的出现。


PS:大刘也是钓鱼达人了

#三体
2021 年 2 月 22 日 271
曲淡歌
曲淡歌@admin

2021 年 2 月 20 日

图床软件picgo在win10下使用剪贴板上传报错java 

报错代码:

A Java Script error occurred in the main process
Uncaught Exception
Error: spawn powershell ENOENT
at Process. Child Process. handle onexit(internal /child process. js: 264: 19)
at onerrornt(internalchild process. js: 456: 16)
at processticksand Rejections(internal/process/task queues. js: 84: 9)

解决参考:github iusses

#picgo
2021 年 2 月 20 日 158
曲淡歌
曲淡歌@admin

2021 年 2 月 19 日

音频加密的方法讨论 

目标

如果只是单纯的想加密音频,最简单的办法就是用通用的加密方法,比如直接用压缩文件加密。但是如果想要得到一个看似正常的音频,实际上却内含玄机,目前似乎还没有很好的办法。而且如果能得到加密之后还是音频的文件,那么就可以把这些加密文件上传到普通的视频音频网站,用来长期免费的云存储。

预想方案

双声道反相

这个灵感来源于降噪耳机,降噪耳机的原理就是检测外界噪声然后生成一个反相的音波,从而与之抵消。那么如果把两段反相的音频藏在一个文件的左右声道上,那么加密后的文件就是一段空白,虽然与预期的“加密后仍然是有意义的音频”这个目标有一定差距,但是也算不错了。

后来又找到一个类似思路的——把音频等间距拆成两段,组合听就可以得到结果

一种简单的音频加密的思路

传统的位运算加密

参考:

数字信号处理-基于matlab的语音信号的加密解密

matlab-audiowrite函数的使用文档

该作者利用了matlab自带的音频处理函数,把音频转化成二进制,通过密钥运算加密后再逆运算得到新的音频。

利用软件deepsound

参考:

如何像黑客军团主角那样将文件隐藏在音频中

2021 年 2 月 19 日 176

Loading...
载入中

已到底部

没有可加载的页面

C
写微博
S
搜索
J
下一篇微博/评论
K
上一篇微博/评论
R
回复
E
编辑
O
显示隐藏评论
T
回顶部
L
登录
H
显示隐藏帮助
Ctrl+Enter
提交发布
ESC
取消并清除内容