USBDisplayLinkWorkingHowto

Find USB Equipment

Via lsusb we could find which usb equipment available:

$ sudo lsusb -t 
/:  Bus 02.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/8p, 10000M
    |__ Port 5: Dev 2, If 0, Class=Hub, Driver=hub/4p, 5000M
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/16p, 480M
    |__ Port 2: Dev 2, If 0, Class=Vendor Specific Class, Driver=rtsx_usb, 480M
    |__ Port 3: Dev 3, If 0, Class=Vendor Specific Class, Driver=asix, 480M
    |__ Port 6: Dev 4, If 0, Class=Human Interface Device, Driver=, 12M
    |__ Port 6: Dev 4, If 1, Class=Human Interface Device, Driver=usbhid, 12M
    |__ Port 9: Dev 5, If 0, Class=Hub, Driver=hub/4p, 480M
        |__ Port 1: Dev 7, If 1, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 1: Dev 7, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 2: Dev 9, If 0, Class=Human Interface Device, Driver=usbhid, 12M
        |__ Port 3: Dev 10, If 0, Class=Wireless, Driver=rndis_host, 480M
        |__ Port 3: Dev 10, If 1, Class=CDC Data, Driver=rndis_host, 480M
        |__ Port 4: Dev 12, If 0, Class=Vendor Specific Class, Driver=udl, 480M
    |__ Port 12: Dev 13, If 0, Class=Mass Storage, Driver=usb-storage, 480M
    |__ Port 13: Dev 6, If 1, Class=Video, Driver=uvcvideo, 480M
    |__ Port 13: Dev 6, If 0, Class=Video, Driver=uvcvideo, 480M
    |__ Port 14: Dev 8, If 0, Class=Wireless, Driver=btusb, 12M
    |__ Port 14: Dev 8, If 1, Class=Wireless, Driver=btusb, 12M

And we could found corresponding USB equipments:

$ ls /sys/bus/usb/drivers/usb
1-12  1-13  1-14  1-2  1-3  1-6  1-9  1-9.1  1-9.2  1-9.3  1-9.4  2-5  bind  uevent  unbind  usb1  usb2

Via following command we could unbind/bind DisplayLink equipments:

$ echo '1-9.4' | sudo tee /sys/bus/usb/drivers/usb/unbind
$ echo '1-9.4' | sudo tee /sys/bus/usb/drivers/usb/bind

unbind is equal to unplugin the usb port, bind is equal to insert the usb equipment.

xrandr tips

Via following commands:

$ xrandr --output DVI-I-2-2  --mode 1920x1080 --right-of HDMI-0'

WorkingTipsOnLXCKO

Environment

Ubuntu 18.04.3 LTS, Kernel version:
Linux build 5.3.0-62-generic.

vagrant box image: centos76.

lxc images:

# apt-get install -y kpartx
# cp ~/.vagrant.d/boxes/centos76/0/libvirt/box.img  /media/sdb/
# cd /media/sdb

root@build:/media/sdb# qemu-img convert box.img box1.img
root@build:/media/sdb# qemu-img info box.img
image: box.img
file format: qcow2
virtual size: 200G (214748364800 bytes)
disk size: 655M
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
root@build:/media/sdb# qemu-img info box1.img
image: box1.img
file format: raw
virtual size: 200G (214748364800 bytes)
disk size: 1.3G

# kpartx -av box1.img 
add map loop2p1 (253:2): 0 419428352 linear 7:2 2048
# mount /dev/mapper/loop2p1 /mnt8/
# ls /mnt8/
bin  boot  dev  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
# tar -cvzf rootfs.tar.gz -C /mnt8 .

Create metadata and import lxc images:

# vim metadata.yaml
architecture: "x86_64"
creation_date: 1599622122 # To get current date in Unix time, use `date +%s` command
properties:
architecture: "x86_64"
description: "CentOS 7.6 for lxc"
os: "redhat"
release: "7.6"
# tar czvf metadata.tar.gz metadata.yaml
# lxc image import metadata.tar.gz rootfs.tar.gz --alias "centos76"
Image imported with fingerprint: 9f53f37e869c643049933dccf8cac9c76107856b1f66955cc2a9d3a55329a060
# lxc image ls
+----------+--------------+--------+-------------+--------+----------+-----------------------------+
|  ALIAS   | FINGERPRINT  | PUBLIC | DESCRIPTION |  ARCH  |   SIZE   |         UPLOAD DATE         |
+----------+--------------+--------+-------------+--------+----------+-----------------------------+
| centos76 | 9f53f37e869c | no     |             | x86_64 | 473.97MB | Sep 9, 2020 at 3:29am (UTC) |
+----------+--------------+--------+-------------+--------+----------+-----------------------------+

lxd init using following configuration:

root@build:/media/sdb# lxd init
Would you like to use LXD clustering? (yes/no) [default=no]: 
Do you want to configure a new storage pool? (yes/no) [default=yes]: 
Name of the new storage pool [default=default]: 
Name of the storage backend to use (btrfs, dir, lvm) [default=btrfs]: 
Create a new BTRFS pool? (yes/no) [default=yes]: 
Would you like to use an existing block device? (yes/no) [default=no]: ^C
root@build:/media/sdb# lxd init
Would you like to use LXD clustering? (yes/no) [default=no]: 
Do you want to configure a new storage pool? (yes/no) [default=yes]: 
Name of the new storage pool [default=default]: 
Name of the storage backend to use (btrfs, dir, lvm) [default=btrfs]: dir
Would you like to connect to a MAAS server? (yes/no) [default=no]: 
Would you like to create a new local network bridge? (yes/no) [default=yes]: 
What should the new bridge be called? [default=lxdbr0]: 
What IPv4 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: 
What IPv6 address should be used? (CIDR subnet notation, “auto” or “none”) [default=auto]: none
Would you like LXD to be available over the network? (yes/no) [default=no]: 
Would you like stale cached images to be updated automatically? (yes/no) [default=yes] 
Would you like a YAML "lxd init" preseed to be printed? (yes/no) [default=no]: 

Create a bridge profile:

# lxc profile create bridge
root@build:/media/sdb# cat bridge.profile 
config:
  linux.kernel_modules: ip_tables,ip6_tables,netlink_diag,nf_nat,overlay,br_netfilter
  raw.lxc: "lxc.apparmor.profile=unconfined\nlxc.cap.drop= \nlxc.cgroup.devices.allow=a\nlxc.mount.auto=proc:rw sys:rw"
  security.nesting: "true"
  security.privileged: "true"
description: Bridge LXD profile
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: br0
    type: nic
  root:
    path: /
    pool: default
    type: disk
name: bridge
root@build:/media/sdb# lxc  profile edit bridge < bridge.profile 
root@build:/media/sdb# lxc profile list
+---------+---------+
|  NAME   | USED BY |
+---------+---------+
| bridge  | 0       |
+---------+---------+
| default | 0       |
+---------+---------+

Create a instance:

# lxc launch centos76 ko1 --profile bridge
Creating ko1
# lxc ls
+------+---------+-----------------------+------+------------+-----------+
| NAME |  STATE  |         IPV4          | IPV6 |    TYPE    | SNAPSHOTS |
+------+---------+-----------------------+------+------------+-----------+
| ko1  | RUNNING | 10.137.149.190 (eth0) |      | PERSISTENT | 0         |
+------+---------+-----------------------+------+------------+-----------+

How KO Works

Bug fix1: conf/my.cnf mapping.
Bug fix2: could not running on lxc’s docker-compose.

On adding Ubuntu

Via following commands, we could use lxc for ubuntu20.04.

# qemu-img convert box.img box1.img
# kpartx -av box1.img 
# lvscan
# mount /dev/vgubuntu/root /mnt7/
# tar -czvf rootfs.tar.gz -C /mnt7 .
# vim metadata.yaml
architecture: "x86_64"
creation_date: 1600908919 # To get current date in Unix time, use `date +%s` command
properties:
architecture: "x86_64"
description: "ubuntu20.04 for lxc"
os: "ubuntu"
release: "20.04"
# tar czvf metadata.tar.gz metadata.yaml
# lxc image import metadata.tar.gz  rootfs.tar.gz --alias "ubuntu20.04"

On adding storage in cluster

Via following commands:

lxc cluster list
# for getting the member name. 

lxc storage create fastPool dir source=/media/md0/lxd --target arm-a1
lxc storage create fastPool dir source=/media/md0/lxd --target arm-a2
lxc storage create fastPool dir source=/media/md0/lxd --target arm-a3
lxc storage create fastPool dir

x86 working tips

working tips for creating lxd cluster:

sudo apt install linux-image-extra-virtual linux-generic
cat /proc/sys/net/bridge/bridge-nf-call-iptables
1
lxc profile copy default k8s
lxc profile edit k8s 
config:
  environment.TZ: Asia/Bangkok
  raw.lxc: |
    lxc.apparmor.profile=unconfined
    lxc.cgroup.devices.allow = a
    lxc.mount.auto=proc:rw sys:rw
    lxc.cap.drop=
  security.nesting: "true"
  security.privileged: "true"
description: Default LXD profile
devices:
  apparmor:
    path: /sys/module/apparmor/parameters/enabled
    source: /dev/null
    type: disk
  eth0:
    name: eth0
    nictype: bridged
    parent: br10
    type: nic
  hashsize:
    path: /sys/module/nf_conntrack/parameters/hashsize
    source: /dev/null
    type: disk
  kmsg:
    path: /dev/kmsg
    source: /dev/kmsg
    type: unix-char
  root:
    path: /
    pool: default
    type: disk
name: k8s
used_by:
- /1.0/containers/k1
- /1.0/containers/k2
- /1.0/containers/k3
lxc launch ubuntu:18.04 k1 -p k8s

Workingtiponaarchftp

ftpd服务端

加载镜像:

# docker load<ftpd.tar
Loaded image: gists/pure-ftpd:arm64
# docker images | grep ftpd
gists/pure-ftpd                                                            arm64               1b3e76d8756b        3 months ago        5.77MB

运行以下命令, 创建一个pure-ftpd实例, 当前目录下的ftpd含有ftpd的配置文件(pureftpd)及存储目录(data):

# mkdir ftpd
# cd ftpd
# mkdir pureftpd data
# docker run -d --restart unless-stopped --name pure-ftpd  -e MIN_PASV_PORT=40000 -e MAX_PASV_PORT=40009 -p 21:21  -p 40000-40009:40000-40009  -v $(pwd)/pureftpd:/etc/pureftpd  -v $(pwd)/data:/home/ftpuser gists/pure-ftpd:arm64

运行以下命令配置pure-ftpd的权限,以及添加test用户,并刷新pure-ftpd本地配置文件:

 docker exec -it pure-ftpd chown ftpuser:ftpuser -R /home/ftpuser
 docker exec -it pure-ftpd pure-pw useradd test -m -u ftpuser -d /home/ftpuser/test
 docker exec -it pure-ftpd pure-pw mkdb

客户端

举winscp ftp连接为例, 新建一个ftp连接:

./images/2020_09_07_10_25_02_615x286.jpg

直接在winscp里拖拉实现上传下载:

./images/2020_09_07_10_26_36_990x327.jpg

进度:

./images/2020_09_07_10_29_46_649x286.jpg

OfflineArm64DesktopEnvSetup

Download via docker

Run a docker instance via:

$ sudo docker run -v /mnt:/mnt -it ubuntu:focal-20200115 /bin/bash

In docker instance, do following:

rm -f /etc/apt/apt.conf.d/docker-clean
sed -i 's/ports.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
cd /mnt
apt-get -d -o dir::cache=`pwd` -o Debug::NoLocking=1 install xubuntu-desktop xubuntu-core chromium-browser  firefox xrdp virt-manager ubuntu-wallpapers xubuntu-community-wallpapers xubuntu-community-wallpapers-focal xubuntu-wallpapers lxd lxc
apt-get install -y snapd
snap download lxd
snap download chromium

Transfer

Transfer these packages into the offline environments, and do following:

# cd ~/pkgs
# dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz

Install

In a ubuntu base environment, do following:

# vim /etc/apt/sources.list
deb [trusted=yes] file:///home/test/focal/ ./
# apt-get update -y
# apt-get install -y  xubuntu-desktop xubuntu-core  firefox xrdp virt-manager ubuntu-wallpapers xubuntu-community-wallpapers xubuntu-community-wallpapers-focal xubuntu-wallpapers

Configure xrdp

Configure xrdp via:

$ sudo systemctl status xrdp
$ sudo adduser xrdp ssl-cert  
$ sudo systemctl restart xrdp
$ sudo ufw disable
$ echo xfce4-session >~/.xsession
$ sudo vim /etc/xrdp/startwm.sh
#!/bin/sh

if [ -r /etc/default/locale ]; then
  . /etc/default/locale
  export LANG LANGUAGE
fi

startxfce4
$ sudo systemctl restart xrdp

So now you could use xfce4 as your remote desktop to linux.

snapd installation

In docker run:

# sudo apt-get install -y snapd
# snap download lxd
# snap download chromium
# snap download gtk-common-themes
# snap download core
# snap download core18

Install sequence:

# snap install  (core/core18/gtk-common-themes/lxd/chromium)
chromium_1253.snap  core18_1888.snap  core_9806.snap                 gtk-common-themes_1506.snap  lxd_16946.snap
chromium_1253.assert  core18_1888.assert  core_9806.assert  gtk-common-themes_1506.assert  lxd_16946.assert   

Updated

xrdp configuration:

#!/bin/sh -e

# Install XRDP.
sudo apt install -y xrdp
sudo sed -e 's/^new_cursors=true/new_cursors=false/g' \
     -i /etc/xrdp/xrdp.ini
sudo systemctl enable xrdp
sudo systemctl restart xrdp

# Load Ubuntu config.
echo "xfce4-session" > ~/.xsession
D=/usr/share/xfce4:/usr/share/xubuntu:/usr/local/share
D=${D}:/usr/share:/var/lib/snapd/desktop:/usr/share
cat <<EOF > ~/.xsessionrc
export XDG_SESSION_DESKTOP=xubuntu
export XDG_DATA_DIRS=${D}
export XDG_CONFIG_DIRS=/etc/xdg/xdg-xubuntu:/etc/xdg:/etc/xdg
EOF

# Disable light-locker for avoiding error.
sudo cp /usr/bin/light-locker /usr/bin/light-locker.orig
cat <<EOF | sudo tee /usr/bin/light-locker
#!/bin/sh

# The light-locker uses XDG_SESSION_PATH provided by lightdm.
if [ ! -z "\${XDG_SESSION_PATH}" ]; then
  /usr/bin/light-locker.orig
else
  # Disable light-locker in XRDP.
  true
fi
EOF
sudo chmod a+x /usr/bin/light-locker

Final script

Final script is listed as following:

#!/bin/bash
sudo cp -r focal /home/test/
echo 'deb [trusted=yes] file:///home/test/focal/ ./'|sudo tee -a /etc/apt/sources.list
sudo apt-get update -y
sudo apt-get install -y xubuntu-desktop xubuntu-core  firefox xrdp virt-manager ubuntu-wallpapers xubuntu-community-wallpapers xubuntu-community-wallpapers-focal xubuntu-wallpapers 
sudo adduser xrdp ssl-cert  
sudo systemctl restart xrdp
sudo ufw disable

sudo sed -e 's/^new_cursors=true/new_cursors=false/g' \
	     -i /etc/xrdp/xrdp.ini
sudo systemctl enable xrdp
sudo systemctl restart xrdp

# Load Ubuntu config.
echo "xfce4-session" > ~/.xsession
D=/usr/share/xfce4:/usr/share/xubuntu:/usr/local/share
D=${D}:/usr/share:/var/lib/snapd/desktop:/usr/share
cat <<EOF > ~/.xsessionrc
export XDG_SESSION_DESKTOP=xubuntu
export XDG_DATA_DIRS=${D}
export XDG_CONFIG_DIRS=/etc/xdg/xdg-xubuntu:/etc/xdg:/etc/xdg
EOF

# Disable light-locker for avoiding error.
sudo cp /usr/bin/light-locker /usr/bin/light-locker.orig
cat <<EOF | sudo tee /usr/bin/light-locker
#!/bin/sh

# The light-locker uses XDG_SESSION_PATH provided by lightdm.
if [ ! -z "\${XDG_SESSION_PATH}" ]; then
  /usr/bin/light-locker.orig
else
  # Disable light-locker in XRDP.
  true
fi
EOF
sudo chmod a+x /usr/bin/light-locker

# Install snapd
sudo snap ack snap/chromium_1253.assert
sudo snap ack snap/core18_1888.assert
sudo snap ack snap/core_9806.assert
sudo snap ack snap/gtk-common-themes_1506.assert
sudo snap ack snap/lxd_16946.assert

sudo snap install snap/core_9806.snap
sudo snap install snap/core18_1888.snap
sudo snap install snap/gtk-common-themes_1506.snap
sudo snap install snap/chromium_1253.snap
#sudo snap install snap/lxd_16946.snap

New user will be added if you want to create new session.

BBBHIDWorkingTips

Preparation

The system is:

debian@beaglebone:~$ cat /etc/issue
Debian GNU/Linux 9 \n \l
BeagleBoard.org Debian Stretch imgtec Image 2020-04-06
Support: http://elinux.org/Beagleboard:BeagleBoneBlack_Debian
default username:password is [debian:temppwd]
debian@beaglebone:~$ uname -a
Linux beaglebone 4.14.108-ti-r131 #1stretch SMP PREEMPT Tue Mar 24 19:18:37 UTC 2020 armv7l GNU/Linux

Change password via passwd.
Enlarge the partition from 4GB to 32GB(32 GB disk)

root@beaglebone:/home/debian# /opt/scripts/tools/grow_partition.sh 
# vim /etc/network/interfaces
auto eth0
iface eth0 inet dhcp
# reboot
##### Checking #############
debian@beaglebone:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            217M     0  217M   0% /dev
tmpfs            49M  5.2M   44M  11% /run
/dev/mmcblk0p1   30G  2.5G   26G   9% /

Edit the sources.list configuration:

$ cat /etc/apt/sources.list
deb http://mirrors.ustc.edu.cn/debian stretch main contrib non-free
#deb-src http://mirrors.ustc.edu.cn/debian stretch main contrib non-free

deb http://mirrors.ustc.edu.cn/debian stretch-updates main contrib non-free
#deb-src http://mirrors.ustc.edu.cn/debian stretch-updates main contrib non-free

deb http://mirrors.ustc.edu.cn/debian-security stretch/updates main contrib non-free
#deb-src http://mirrors.ustc.edu.cn/debian-security stretch/updates main contrib non-free
#  apt-get update -y 
# apt-get install -y libudev-dev libusb-dev awesome iotop

USB HID