Blog

Blog

ROCKPro64 with SATA card

ROCKPro64 with SATA card

ROCKPro64 is single board computer (SBC) equipped with a PCIe x4 open ended slot. I'm planing to replace my Buffalo NAS mother board, and reuse the Buffalo NAS case.

SATA card

According to compatibility list, ROCKPro64 supports 6 ports SATA card, Ziyituod SATA Card ASM 1062+1093 6-Port.

But I purchased one 10 ports SATA card, 10port 4x 1xJMB575 + 1xASM1166.

References

ROCKPro64 Hardware Accessory Compatibility
ROCKPro64

Synology vi modify file ACL unintentionally

Synology vi modify file ACL unintentionally

When using vi editor in Synology SSH session, the ACL changed upon saving. This causes issue for permission sensitive application, such as SSH.

Cause

The vi command creates a new file, and write new contents into that file, and the new file doesn't follow the ACL of original file.

Update ACL using GUI

If SSH is not available, for example, the permission authorized_keys changed, and only public key access was opened. If the file was shared, GUI is allowed to change ACL in user's home directory.

The ACL page can be accessed using following steps.

  • Login DSM webpage
  • Right click on the file
  • Select Properties
  • Click on Permission Tab

View ACL from command line

In Synology, use following command to check file ACL

/usr/syno/bin/synoacltool -get <PATH>

Remove ACL from command line

To remove ACL, using following command

/usr/syno/bin/synoacltool -del <PATH>

Edit ACL from command line

For example, remove @users group from usbshare1

/usr/syno/sbin/synoshare --setuser usbshare1 RW - "@users"

Other options

More options can be found using following command

/usr/syno/bin/synoacltool -h

References

Manage Windows ACL with Command Line Interface ?

Turn off iMac Display Only

Turn off iMac Display Only

The iMac might not auto sleep sometimes, so what do you like to do before you go for quick snack? Turn off iMac display only. But there is not switch on monitor, luckily there are some ways to do.

Keyboard with Eject key

  • Control + Shift + Eject

Keyboard with Power key

  • Control + Shift + Power

Keyboard without Eject/Power

Go to login screen

  • Control + Command + Q

Then at the login screen

  • Escape

Keyboard with Touch Bar

Configure

  • Select System Preferences
  • Open Keyboard
  • Click Customize Control Strip...
  • Drag Screen Lock icon into the Touch Bar
  • Click Done.

Perform

Go to login screen

  • Tap the the Screen Lock icon on your Touch Bar

Then at the login screen

  • Escape to turn off the display immediately.

Mouse

Configure

  • Select System Preferences
  • Open Mission Control
  • Click Hot Corners
  • Choose Put Display to Sleep for one of the corner

Perform

  • Move your mouse to the corner configured

Terminal

Run the following command:

pmset displaysleepnow

References

[How to Turn Off Your Mac's Display Without Putting Your Computer to Sleep}(https://www.iclarified.com/76166/how-to-turn-off-your-macs-display-without-putting-your-computer-to-sleep)

Reconfigure iCloud in MacOS

Table of Contents

Reconfigure iCloud in MacOS

Many days headache was fixed this morning...

Story

The problem with iCloud on my newly installed MacOS, which is High Sierra, 10.13.6, out of support by Apple.

The machine was installed via Internet, and the MacOS was Mountain Lion, then upgraded to High Sierra, the lastest can be installed in this 2011 iMac.

Issue

When connecting to iCloud at beginning, the iCloud can not sync Keychains, it is quite an issue for me, because I need to register all credentials to this iMac separately.

Then I decided to reconfigure iCloud by re-login to iCloud again.

But iCloud could not be registered any more after logout, I thought it could be issue with my unsupported OS.

Symptom

The symptom was repeating asking for iCloud user and password, no matter which iCloud I like to use. In the email account list, the account is just appear in very short period, then closed immediately.

Fix

This morning I tried to send email, found out that I could not add iCloud account, I decided to search solution in Internet.

The solution works for delete all files related to iCloud and system configuration. It is works for my newly configured iMac, because I have nothing in it.

Steps

Run following commands in terminal

rm ~/Library/Application Support/iCloud
rm ~/Library/Preferences/com.apple.systempreferences.plist01
rm ~/Library/Keychains

Then reboot

sudo reboot

References

Mac Can’t Connect to iCloud? Here Are 7 Ways to Fix It

Chinese Steamed Buns (馒头)

Chinese Steamed Buns (馒头)

Ingredients

  • 300g all-purpose flour
  • 1.5 teaspoon instant yeast
  • 2 tablespoons sugar (optional)
  • 150g water or 20ml more if needed
  • a tiny pinch of salt (around 1.5% of the dough)

Steps

  • Add ingredients
  • Stir using chopsticks
  • Use hand to knead dough
  • Till dough's surface becomes smooth
  • Put dough into container, use wet tower cover it up
  • First rising, until double size (can be 1 hour, 3 hours, or even longer. Such as overnight in refrigerator)
  • Knead dough till it become normal size
  • Separate it into smaller pieces
  • Put them into steam box resting for 10 minutes
  • Set up steamer with cold water
  • Boiling
  • Steam 18-20 minutes after boiling
  • Turn off fire
  • Wait for 5 minutes
  • Pick them up

References

Chinese Steamed Buns (Mantou)

Raspberry Pi Commands Basic

Table of Contents

Raspberry Pi Commands Basic

Update

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo rpi-update

Hardware Info

cat /proc/cpuinfo discover information about the Raspberry Pi's CPU
cat /proc/meminfo displays details about the Raspberry Pi's memory.
cat /proc/partitions reveals the size and number of partitions on your SD card or HDD.
cat /proc/version shows you which version of the Pi you are using.
vcgencmd measure_temp reveals the CPU temperature (vital if you're concerned about airflow).
vcgencmd get_mem arm && vcgencmd get_mem gpu will reveal the memory split between the CPU and GPU, which can be adjusted in the config screen.
free -o -h will display the available system memory.
top d1 checks the load on your CPU, displaying details for all cores.

Shutdown

sudo shutdown -h now will commence the shutdown process with immediate effect.
sudo shutdown -h 21:55 Schedule a timed shutdown at 21:55

References

Raspberry Pi Terminal Commands: A Quick Guide for Raspberry Pi Users

Docker container restart policy

Docker container restart policy

Policy types

To configure the restart policy for a container, use the --restart flag when using the docker run command. The value of the --restart flag can be any of the following:

Flag Description
no Do not automatically restart the container. (the default)
on-failure Restart the container if it exits due to an error, which manifests as a non-zero exit code.
always Always restart the container if it stops. If it is manually stopped, it is restarted only when Docker daemon restarts or the container itself is manually restarted. (See the second bullet listed in restart policy details)
unless-stopped Similar to always, except that when the container is stopped (manually or otherwise), it is not restarted even after Docker daemon restarts.

Command

Following command set restart policy of container redis to unless-stopped.

docker update --restart unless-stopped redis

References

Start containers automatically

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