Blog

GCP Rclone Mount性能测试

WIP

购买了Google Suite帐号以后,我的备份需求大部分迁移到了Google Drive上,以下是一些与GCP Virtual Instance有关的性能测试

  • 机器类型 : GCP f1-micro (1 vCPU, 617 MiB 内存)
  • 地区: us-west-1
  • 磁盘大小: 30 GiB HDD
  • Swap:2048MiB

1. Rclone Mount Flags #

Rclone Mount Config

rclone mount gd: /mnt/gdrive  --buffer-size 1G --vfs-read-chunk-size 256M --vfs-read-chunk-size-limit 2G  --allow-non-empty --allow-other   --dir-cache-time 12h  >/dev/null 2>&1 &

后来发现这套mount config是针对mount plex share这种只读文件使用的,对于只写不读的情况应该更改另外两个flag

rclone mount --config ~/.config/mountconfig.conf [Mountname] [LOCATION] --drive-chunk-size 32M --buffer-size 256M --vfs-read-chunk-size 64M --vfs-read-chunk-size-limit 1G --vfs-cache-mode writes --vfs-cache-max-age 0h0m10s --allow-non-empty --allow-other --dir-cache-time 12h > /dev/null 2>&1 &

根据这个github issue, –drive-chunk-size 会影响传输速度,default 8M其实已经够用了,这里调到32M,其他几个flag对读取有帮助,对写入帮助不大

...

Use docker to deploy emby and v2ray on your VPS

Work in progress…

Update 2020/05/11 Caddy V2 has been released! I will upgrade the Caddyfile to v2 format(JSON).

Some useful bash script #

  1. BBR plus https://github.com/chiakge/Linux-NetSpeed
  2. Virtual memory https://www.moerats.com/usr/shell/swap.sh

Cloudflare CNAME setup #

Go to https://cdn.moeelf.com/ Login using cloudflare credentials

Set up a CNAME or A entry to origin server, then add the cloudflare *.cdn.cloudflare.net CNAME to your DNS service provider

You can enable CDN as well

Install Caddy #

Set up Caddyfile #

touch /etc/caddy/Caddyfile
v.lightsailjp.zb8.stream {
  gzip
  tls {
      dns cloudflare
  }
  log /var/log/caddy/caddy.v2ray.log
  proxy /leet 127.0.0.1:13337 {
    websocket
    header_upstream -Origin
  }
}

t.lightsailjp.zb8.stream {
  gzip
  tls {
      dns cloudflare
  }
  log /var/log/caddy/caddy.trojan.log
  proxy / https://baidu.com
  proxy /leet 127.0.0.1:13338 {
    websocket
    header_upstream -Origin
  }
}


embyjp.zb8.stream {
  gzip
  tls {
      dns cloudflare
        }
  log /var/log/caddy/caddy.emby.log
  proxy / 127.0.0.1:8096 {
   header_upstream -Origin
  websocket
        }
}

Set up logs #

mkdir /var/log/caddy

Install Caddy as a systemd service #

Download https://raw.githubusercontent.com/caddyserver/caddy/master/dist/init/linux-systemd/caddy.service to /etc/systemd/systemd

...

Use of const in c

C

The use of const is very tricky in C.

char *p;	// P points to any char, you can modify the char

const char *p; // P can point to any char, you can't modify the char via *p

char * const p = &a; // P only points to address &a and connot be changed. However the char content can be modified via *p.

const char * const p; = &b; //P only points to address &b and cannot be changed. You can't modify the char content via *p.

The code snipet above illustrated three way to use const with pointer. This still looks very confusing. There is a rule to check where const applies to.

...

Get Arch working properly as a Guest under vmware

One thing bothers me the most is that last time I installed Arch on a VMware Workstation guest VM. I was not able to get open-vm-tools functions working. This includes drag/drop between host and guest, shared folder, and clipboard share. This time I tried I managed to get it working on a KDE based Arch. I’m not sure if the issue is DE-specific as last time when I tried it I was using Xfce4 as my DE. Anyways here is how I got it to work.

...

Backup and restore Archlinux using tar

Backup OS #

#1. Clean Pacman Cache
sudo -i
pacman -Scc

#2. Create a exclude list
cat /root/backup/exclude.txt
/tmp/*
/root/backup/*
/proc
/dev
/sys
/home #If home is mount to another partition you need to exclude home here
/boot/EFI

#3. Create tarball
tar --exclude-form=/root/backup/exclude.txt -czpvf /root/backup/arch-back.tar.gz /

Fix grub #

You may ignore this setp if you have a live cd to recover the OS. If you don’t, it would be great to have a second minimal OS installed in your disk. In my case I have a debian intalled in my disk’s /dev/sda5 partition (Arch uses /dev/sda1-4). In this case, if I format /dev/sda2(where arch’s root fs is located). I should be able to boot into debian to recover the tarball I backed up.

...

Partition tools on arch livecd

gdisk #

Gdisk is more like a interactive tool. Below is the setup for a BIOS/GPT configuration

o #create new table
n [default] [+1M] [ef02] # create a 1MiB space for grub
n [default] [+20G] [8300] # create rootfs
n [default] [+4G] [8200] # create swap
n [default] [+20G] [8300] # create home
n [default] [default] [8300] # remaining is used by other os
w

And here is a partition scheme for UEFI/GPT configuration:

/dev/sda1 100M UEFI ef00
/dev/sda2 1000M Boot 8000
/dev/sda3 20G Root 8304
/dev/sda4 20G Home 8300
/dev/sda5 4G Swap 8200

Notes on Linux Installation on a BIOS/GPT configuration #

A mebibyte partition needs to be located in first 2TB of the disk. For details, check arch wiki arch wiki

...

Arch installation notes

Archlinux 安装笔记 #

This post was written by me a few years ago. I decide to post it here cuase I might need it later.

安装流程 #

Step0: Connect to WIFF #

如果有使用wifi的话,使用如下命令连接到Wifi

iwconfig #List all wireless network interface #

wifi-menu [Interface] #Connect to network #

OR Use Android USB Tethering

ls /sys/class/net
dhcpcd interface

Step1:检测是否uefi enabled #

ls /sys/firmware/efi/efivars #

Step2: 调整时间 #

timedatectl set-ntp true #

Step3: 分区 #

一般而言,如果uefi启动,需要分一个100m的fat32分区作为uefi使用

...

Install MSYS2 on Windows

MSYS2 #

I’m used to the bindings provided by Oh-my-zsh git plugin in my archlinx. However when working on my main Windows 10 workstations the git windows client comes with mingw bash. Thus I was looking for a way to get zsh installed on windows. There are actually two way to do this. You can use WSL(Windows Subsystem for Linux) or MSYS2. I tried WSL for a few month. It was pretty good. However the cavet is although you can install zsh via package manager. You cannot set it as default shell. So I have to put zsh in my .bashrc and have bash run zsh. This is not a elegant solution. Then I found another way to do this, which is a tool called MSYS2.

...

Vmware Photon OS

Photon #

Photon by Vmware is an container enabled os. It comes with docker preinstalled as a minimal ova file. (https://github.com/vmware/photon/wiki/Downloading-Photon-OS)

Add multiple NIC #

Follow (https://github.com/vmware/photon/blob/master/docs/photon_admin/setting-up-networking-for-multiple-nics.md)

Remember the number indicates the priority of the if. The lower the number, the higher the priority.

Default iptables #

Photon’s default iptables drop all incoming traffice. Edit iptables to change the firewall rule. To presist the changes:

/etc/systemd/scripts/iptables is a script thats executed on iptables service start. so you can add your rules at the end of that script and the restore will be automatic.

...