Living a Simple Life is a Happy Life

有饭吃,自由自在,就非常开心

ZFS Cheat

| Comments

特别提示

在各种折腾之前,先看看你买的大容量硬盘自带的缓存开了没有;有一些矿盘,不知道是何原因,默认缓存没有开

1
2
3
4
5
# 查看是否开了写缓存
$ hdparm -W /dev/sdx

# 开启
$ hdparm -W1 /dev/sdx

然后,看看你的SATA接口当前速率是2.0还是3.0,有人就是这么粗心,拿着3.0的盘,插着2.0的线;

1
$ smartctl -a /dev/sdx

ZFS 使用命令小集

列出zpool磁盘

1
zfs list

查看pool状态

1
zpool status

Lnd Low Rescan Speed for Startup

| Comments

Lnd启动的时候需要扫描最近数百个区块来验证安全性,做rescan动作的时候慢的出奇,有时候需要30分钟才能完成这个动作:

https://github.com/lightningnetwork/lnd/issues/760

如果单独启动Lnd可以耐着性子等,但是如果用Lit(lightning-network-termial) 启动的话,因为它集成了数个服务,所以在等Lnd RPC服务就绪前,往往等不到扫描完毕就超时退出了…

因为Lit Debug Log没有打全,我对于这个问题百思不得其解,其在bitcoin Regnet, Testnet, Mainnet上面的表现各不相同….

最后找到的一劳永逸的解决办法有两个:

  1. 换btcd,不要用bitcoin core了

  2. 换ssd硬盘,花钱解决

话说,bitcoin core还好一点,Ethereum一个全节点的成本已经越来越高了,硬盘需求已经直奔2T SSD了;对于个人来说,在AWS上启动一个2T云硬盘的vps着实花费不小;

How to Allow Non-root Process to Bind to Low-numbered Ports

| Comments

Use CAP_NET_BIND_SERVICE to grant low-numbered port access to a process:

With this you can grant permanent access to a specific binary to bind to low-numbered ports via the setcap command:

1
sudo setcap CAP_NET_BIND_SERVICE=+eip /path/to/binary

For more details on the e/i/p part, see cap_from_text.

After doing this, /path/to/binary will be able to bind to low-numbered ports. Note that you must use setcap on the binary itself rather than a symlink.

FROM:

https://superuser.com/questions/710253/allow-non-root-process-to-bind-to-port-80-and-443

How to Hide a Password Passed as Command Line Argument?

| Comments

有部分软件设计的时候没有考虑命令行参数之外传递密码的途径,无法用环境变量或配置传递密码;导致任何用户用ps一看都能看到,这是重大的安全隐患;

解决方法很tricky:

https://serverfault.com/questions/592744/how-to-hide-a-password-passed-as-command-line-argument

https://stackoverflow.com/questions/3830823/hiding-secret-from-command-line-parameter-on-unix

做软件设计的时候一定要考虑命令行传递密码的替代方案;

How to Enable VNC+xfce on Ubuntu16

| Comments

安装桌面环境和vncserver

1
sudo apt-get install xfce4 vnc4server

启动vncserver

1
vncserver

修改配置文件

1
2
3
4
5
6
7
8
9
10
11
vim ~/.vnc/xstartup


#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey

修改配置文件后,运行如下命令结束掉之前产生的窗口:1

1
vncserver -kill :1

用vnc client连接后,tab键自动补全用不了,可以进行如下设置

settings -> window manager -> keyboard -> switch window for same application -> clear

Linux下块设备缓存Bcache设置

| Comments

Bcache简介

Bcache是Linux内核块设备层cache,支持多块HDD使用同一块SSD作为缓存盘。它让SSD作为HDD的缓存成为了可能。由于SSD价格昂贵,存储空间小,而HDD价格低廉,存储空间大,因此采用SSD作为缓存,HDD作为数据存储盘,既解决了SSD容量太小,又解决了HDD运行速度太慢的问题。

Bcache是从Linux-3.10开始正式并入内核主线的,因此,要使用Bcache,需要将内核升级到3.10及以上版本才行。