OpenStick Debian System Tuning: Wi-Fi AP and Compression Optimization

USB mode switching, AP setup considerations, and filesystem compression tuning for small-storage OpenStick devices.

USB Mode Switching

When switched to host mode, the device can use USB peripherals (including Wi-Fi adapters).
When switched to gadget mode, it can expose USB networking/ADB to a PC.

Switch to host mode

1
echo host > /sys/kernel/debug/usb/ci_hdrc.0/role

Switch back to gadget mode

1
echo gadget > /sys/kernel/debug/usb/ci_hdrc.0/role

Auto-switch at boot

Add to /etc/rc.local before exit 0:

1
2
3
4
5
6
7
# usb auto host
sleep 3
grep 0 /sys/kernel/debug/usb/ci_hdrc.0/device | grep speed
if [ $? -eq 0 ]
then
  echo host > /sys/kernel/debug/usb/ci_hdrc.0/role
fi

This checks whether a PC connection is present; if not, it switches to host mode for external USB devices.

Compression Optimization for Limited Internal Storage

Some Wi-Fi sticks have very limited storage (for example 4GB). Enabling stronger compression can significantly reduce usage.

Use Btrfs (supports transparent compression)

Convert root image to Btrfs (ensure kernel has Btrfs support):

1
btrfs-convert root.img

Tune mount options

Higher zstd levels reduce size further but use more CPU. For performance balance, adjust to your device.

Example remount test:

1
sudo mount -o remount,defaults,noatime,compress=zstd:6,commit=120 /dev/mmcblk0p14 /

Recompress existing files

1
sudo btrfs filesystem defragment -r -v -czstd /

In the original test, stronger compression reduced used space notably.

记录并分享
Built with Hugo
Theme Stack designed by Jimmy