Blog

Blog

Convert Armbian to iSCSI btrfs root

Convert Armbian to iSCSI btrfs root

In order to have bad SD card worry-free, I decided to convert Armbian root filesystem to btrfs and move to Synology iSCSI LUN.

Pros

  • Backup can be done by iSCSI LUN snapshot
  • Only very small SD card needs to be used
  • iSCSI LUN can increase space easily
  • SD card data can be recreated easily
  • Faster even use slow SD card
  • Harddisk is cheaper than SD card

Steps

Separate /boot and root (/) partition

Move root filesystem to new SD card

This step needs to have another SD card, which needs to be able to hold all the original SD card files.

  • Insert the new SD card via USB card reader

  • Identify the SD card device name using lsblk command, normally should be /dev/sda

  • Format SD card to have two partitions, such as

/dev/sda1          2048  4196351  4194304   2G 83 Linux
/dev/sda2       4196352 33554431 29358080  14G 83 Linux

Note: There are some soft link in /boot filesystem, if /dev/sda1 is vfat, those soft link files will not be copied. I'm not sure if any issue will be encountered.

  • Run nand-sata-install
    • select following option
Boot from SD - system on SATA, USB or NVMe
  • Select /dev/sda2 as destination to install system to /dev/sda2

  • Select btrfs as filesystem type, after that, the system will format /dev/sda2 and transfer all files into this new partition.

  • Once completed, reboot the system

Verify system after reboot

Now, the system should have two filesystems

  • root (/), which is in new USB drive
  • /boot that binds to /media/mmcboot, which point to SD card, /dev/mmcblk0p1.

Copy all files from /boot to /dev/sda1

We create the partition /dev/sda1 has same filesystem type as original partition, and maintain the same structure /boot as well.

mkfs.ext4 /dev/sda1
mount /dev/sda1 /mnt
cp -a /boot /mnt

Note: The boot partition files can be in subdirectory of /mnt/boot, as well as in /mnt. If they are in /mnt/, then the path in /etc/fstab` needs to be changed. If failed to do this, the system is still bootable, just can not mount boot filesystem and taking time to scan filesystems as well.

Modify root partition UUID

Note: This should have been updated., because the root (/) is already running on new SD card

  • Find out the UUIDs for root (/) filesystem and /boot filesystem.
blkid
  • Update following line in /mnt/boot/armbianEnv.txt to root UUID if required.
rootdev=UUID=1c82450c-9013-43d9-9554-1049c264bfb8
  • Update root (/) filesystem UUID in /etc/fstab if required.

  • Update /boot filesystem UUID in /etc/fstab if required.

Shutdown

  • Shutdown the system
  • Take out old SD card from SD card slot
  • Remove new SD card USB device
  • Insert new SD card into SD card slot
  • Then power on system

Verify system

Now, the system should have /boot and root (/) filesystems on new SD card.

Move root to iSCSI

Install/configure iSCSI service

  • Install iSCSI package
apt install open-iscsi
  • Edit /etc/iscsi/initiatorname.iscsi, update following line
InitiatorName=<YOUR_INITIATOR_NAME>

Note: The YOUR_INITIATOR_NAME is the iSCSI client name

  • Edit /etc/iscsi/iscsid.conf, update following lines
node.session.auth.authmethod = CHAP
node.session.auth.username = <YOUR_USERNAME>
node.session.auth.password = <YOUR_PASSWORD>
  • Enable iscsid service and restart it
systemctl enable iscsid
systemctl restart iscsid
  • Login into iSCSI
# iscsiadm --mode discovery --type sendtargets --portal <YOUR_TARGET_IP>
# iscsiadm --mode node --targetname <YOUR_TARGET_NAME> --portal <YOUR_TARGET_IP> --login

Note: If can not login, restart iscsid and try again.

systemctl restart iscsid

Identify block device

Use lsblk command to identify device file, normally should be /dev/sda.

Partitioning

Creating two partitions using fdisk, the first partition is to prepare following for future used, such as

/dev/sda1          2048  2099199  2097152   1G 83 Linux
/dev/sda2       2099200 33554431 31455232  15G 83 Linux

Note: The first partition can be used for iSCSI boot or /boot filesystem backup

Update initramfs

This is to enable kernel load iscsi driver during boot up

touch /etc/iscsi/iscsi.initramfs
update-initramfs -v -k $(uname -r) -c

Configure iSCSI kernel parameters

extraargs=ip=<ip_address>::<gateway>:<mask>:<host>:<interface_name>::<dns0>:<dns1>: ISCSI_INITIATOR=<ISCSI_INITIATOR> ISCSI_TARGET_NAME=<ISCSI_TARGET_NAME> ISCSI_TARGET_IP=<ISCSI_TARGET_IP> ISCSI_TARGET_PORT=3260 ISCSI_USERNAME=<YOUR_USERNAME> ISCSI_PASSWORD=<YOUR_PASSWORD> rw

Note: This includes IP configuration for fix IP. If use dhcp, just change to ip=dhcp

Reboot and verify

Make sure the iSCSI drive automatically loaded after reboot, and IP address assigned correctly.

This is to confirm that iSCSI is working during reboot.

Disable iscsi stop action

Disable iscsid service stop action is to prevent reboot hanging issue.

There is no need to logout as Allow multiple sessions is set to true in Synology iSCSI Target configuration, and the iSCSI Initiator used in both kernel and iscsid configure are the same.

systemctl edit --full open-iscsi.service

Comment out following line

#ExecStop=/lib/open-iscsi/logout-all.sh

Move root filesystem to iSCSI LUN

  • Run nand-sata-install, select following option
Boot from SD - system on SATA, USB or NVMe
  • Select /dev/sda2 as destination to install system to /dev/sda2

  • Select btrfs as filesystem type, then the system will format /dev/sda2, and transfer all files into this new partition.

  • Once completed, reboot the system

Verify system after reboot

Now, the system should have two filesystems

  • root (/), which is in iSCSI drive
  • /boot, binds to /media/mmcboot, which point to SD card, mmcblk0p1.

Other consideration

Recreate /boot/boot.scr

To make sure /boot/boot.scr is up to date, run following command is necessary especially if /boot/boot.cmd was modified.

mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr

Backup /boot to iSCSI

Create filesystems

  • Create filesystem in iSCSI LUN
mkfs.ext4 /dev/sda1
  • Copy files into /dev/sda1
mount /dev/sda1 /mnt
cp -a /boot /mnt
umount /mnt

Recreate /boot SD card

Assuming the new SD card is named as /dev/sdb

  • Create /boot partition using fdisk

  • Create filesystem

mkfs.ext4 /dev/sdb1
  • Copy files
mount /dev/sdb1 /mnt
cp -a /boot /mnt
umount /mnt
  • Find out /dev/sdb1 UUID using command blkid

  • Modify /etc/fstab

    Update /boot filesystem UUID, which should be under /media/mmcboot entry.

  • Change SD card to the new card and reboot

SD card as cache

Thinking of how to use rest of space in SD card. Maybe can use it as bcache caching device to reduce the network traffic.

References

quick way to create SD card with separate /boot and / partitions?
Mounting the root filesystem via NFS (nfsroot)
Setting a Static IP Address Using the Kernel Command Line
Shutdown hang on 16.04 with iscsi targets
mkimage - Generate image for U-Boot
How to install to eMMC, NAND, SATA & USB?
Diskless iSCSI boot with PXE HOWTO

SD Card Speed

SD Card Speed

To select correct SD card for correct task, SD card speed is important.

Speed

SD Card Speed

Tasks

SD Card Speed for Video Capturing

Fragmentation and Speed

Although SD card is not a sequential writing device, but it is still has fragmentation issue.

References

SD Standard for Video Recording
Introduction to SD Card Classes and Speeds
A guide to speed classes for SD and microSD Cards

ESXi with UEFI iSCSI boot on Raspberry Pi

ESXi with UEFI iSCSI boot on Raspberry Pi

Steps

Setup iSCSI disk

  • Create iSCSI Target and LUN in Synology
  • Download RPi4 UEFI Firmware, and unzip it to a SD card which formatted as FAT32 partition
  • Boot from the SD card, and perform following tasks using UEFI menu
    • Disable 3G memory limit
      Device Manager => Raspberry Pi Configuration => Advanced Configuration => Limit RAM to 3 GB)
    • Create device which mapped to iSCSI target
      Device Manager => iSCSI Configuration => Add an Attempt

After Attempt 1 created, Reset (restart) Raspberry Pi. Now, in Boot Manager, should see UEFI SYNOLOGY iSCSI Storage.

Setup boot order

  • Change Boot order and let it before other network boot, otherwise, there will be too much waiting time.

Prepare ESXi installation disk

  • Download and flush VMware-VMvisor-Installer-7.0.0-xxxx.aarch64.iso to USB device

Install ESXi

  • Reset (Reboot) again, and in UEFI menu select boot from USB device
  • Then perform ESXi installation, and select iSCSI disk as target

After installation completed, take out ESXi installation USB, then another reset is required,

Configure ESXi

  • Boot into iSCSI
  • Change ESXi name, etc.

Troubleshooting

Unable to see iSCSI disk in Boot Manager

Most likely is the iSCSI configuration wrong.

  • Check iSCSI Target Name
  • Check iSCSI Target IP
  • Check iSCSI LUN ID (This issue costed me a few hours)
  • Check User/Password

Synchronous Exception

After installation complete, suddenly cannot boot into any destination, and just show error Synchronous Exception.

End up, I have to recopy UEFI image into micro SD card, redo iSCSI configuration. Luckily the iSCSI has no issue, which contains installed ESXi image.

References

Boot ESXi-Arm Fling on a Raspberry Pi 4 Using ISCSI
Raspberry Pi 4 UEFI Firmware Images
ESXi on Arm 10/22 更新
Raspberry Pi 4 Model B 8GBにESXi for ARM 7.0.0をインストール
Synchronous Exception at 0x00000000371013D8 #97

Mi Bluetooth Audio Receiver User Manual

Mi Bluetooth Audio Receiver User Manual

Pros

This bluetooth audio receiver is very light, very suitable for sports.

Cons

Can not adjust volume, and also can not use the headset to adjust the volume if the headset has volume control.

Only support bluetooth 4.2. Anyway, for sports, it is very good as audio quality is not that important.

Picture

Specifications

97mAh built-in battery
Maximum continuous playing time: 4 hours
Working distance: 10 meters
Charging port: Micro USB
Wireless connection: bluetooth version 4.2
Input parameters: 5V1A
Implementation of the standard: Q / WMSX007-2017
CMIIT ID: 2017DP3366
bluetooth protocol: HFP / HSP / A2DP / AVRCP
Compatible with external headphones: support 3-segment 3.5mm plug stereo headphones; support 4-segment 3.5mm plug GB and American standard phone headset (OMTP/CTIA automatic identification switch)

Package Included

1 x Xiaomi bluetooth Remote 4.2 Audio Wireless Receiver
1 x 3.5mm Audio Cable

Manual

Mi Bluetooth Audio Receiver User Manual

References

YPJSQ01JY Mi Bluetooth Audio Receiver User Manual Tiinlab Acoustic Technology (Shenzhen)

OBS capturing error

OBS capturing error

OBS is a software can be used to capture, streaming from an USB capturing device. I bought one HD Video Capture USB dongle, trying to use it to monitor Pine64 OS installation.

Error occurred when view files, such as below.

The screen was not only display wrongly, but also blinking from the point of error. I think the cause this issue is due to encoding and decoding error, because the blinking screen was follwoing the error line.

Try to change the encoding method, but could not be seen in OBS menu.

I think if it is decoding issue, then need to change USB dongle setting.

Permission error when run Fusion VM

Permission error when start Fusion VM

Error

When trying to start a newly created virtual machine in VMware Fusion, following error occurred

Error: Could not open /dev/vmmon...

This is because Fusion has no permssion to open device file required.

Steps

  • Navigate to System Preferences > Security & Privacy on the host macOS (High Sierra, Mojave and Catalina).
  • Under the General tab towards the bottom of the window, you see error similar to following message with option to click on “Allow”:
System software from vendor "VMware, Inc." was blocked from loading.
  • Click Allow.
  • Restart Fusion, and start virtual machine again.
  • If some other permission errors occurr again, repeat above steps.

References

Error: Could not open /dev/vmmon: Broken pipe, while launching the Virtual Machine (80467)

Remap Windows keyboard to Mac layout

Remap Windows keyboard to Mac layout

MacOS keyboard preference can remap keys for individual keyboard. This is not a global key remapping, it will not impact other keyboards except the one selected.

Steps

  • Go to System Preferences
  • Click on Keyboard
  • Click on Modifier Keys
  • Select keyboard to be modified in Select keyboard option
  • Map Option key to Command key, and Command key to Option key

How-To: Remap Windows keyboards to match the Mac keyboard layout