Found Two HBA Cards for My NAS

About three weeks ago, I was casually browsing eBay and found this little gem, a Host Bus Adapter that can do PCIe 2.0 x8 (~4 to 8GB/s). This is way better than the one that I purchased earlier (GLOTRENDS SA3116J PCIe SATA Adapter Card) which can operate on a single lane of PCIe 3.0 yielding only 1GB/s. I could not pass it up at a price of only $ 40 CAD, so I purchased two of these to replace the old adapter card I had.

LSI 6Gbps SAS HBA 9200-8i IT Mode ZFS FreeNAS unRAID + 2*SFF-8087 SATA

This new card LSI 6Gbps SAS HBA 9200-8i only supports 8 SATA ports per card, so I had to get two of them to support all of the hard drives that I have. These SAS HBA cards must have the IT (initiator target) mode firmware because the default firmware (IR mode) supports a version of hardware RAID, which I did not want. With the IT mode, the hard drives will be logically separated on the card and only share the physical bandwidth of the PCIe bus. This is a must for ZFS.

With these new cards, my write throughput to my NAS hard drives now averages around 500MB/s. Previously, I was only getting about half of this.

I wish I would have found these sooner. Now I have two spare PCIe SATA expansion cards, one supporting 8 ports, and the other supporting 16 ports. I will place them on another server. Perhaps in a future Proxmox cluster project.

Tesla FSD Trial

Thanks to my cousins who also purchased Tesla using my Tesla referral code, I have some referral credits that I can use to select a 3 months trial of Tesla’s Full Self Driving (FSD) capability. On March 1st, 2024, I turned this feature on.

Today, we went out for lunch at Mr. Congee in Richmond Hill, Ontario. I thought I give this FSD a try.

It was pretty easy to set up. After agreeing with all the legal stuff and enable the feature, I just set the destination, set it to drive mode, wait for the autopilot icon to show, and double tap the right stalk and away we go!

There are three settings to FSD: chill, average, aggressive/assertive. I just left it on the default, average mode.

Pulling out of the driveway, the car was a bit jerky, but once it got on the road, it made all the right decisions. I override the mode on our neighbourhood feeder road from Leslie Street just to make sure that I can override the mode, and then quickly re-engage the FSD.

On this occasion, all traveling was done on regular roads, no highways, so it was more challenging for the car. It made all the turns correctly, but I did have to override it once when it did not recognize the restricted Via Bus Lane on Yonge Street. It even pulled into the parking area at Mr. Congee, but did not fully complete the trip by parking the car. I had to park it manually.

On the way back, it hesitated too much on a left-hand turn. I had to press the accelerator to help it along. Doing this did not override the FSD mode.

I will be driving to Montreal in about 4 weeks, so I will be looking forward to testing FSD on the highway.

My initial assessment is that I probably would not have paid any more money to gain this feature. Once again, thanks to my cousins who allowed me to experience this through the use of my Tesla redemption credits.

LVM to ZFS Migration

In a previous post, I described the hardware changes that I made to facilitate additional drive slots on my NAS Media Server.

We now need to migrate from an LVM system consisting of 40TB of redundant mirrored storage using mdadm to a ZFS system consisting of a single pool and a dataset. Below is a diagram depicting the logical layout of the old and the intended new system.

40TB of Redundant Storage
40TB of Redundant Storage
Logical Volume (LV)
Logical Volume (LV)
EXT 4 File System for Media Storage
EXT 4 File System for Media Storage
Old Storage System
Old Storage System
50TB of Redundant Storage
50TB of Redundant Storage
ZFS Dataset
ZFS Dataset
New Storage System
New Storage System
LV Group of 4 Physical Volumes (PV)
LV Group of 4 Physical Volumes (PV)
PV
PV
10TB
mdadm mirror
10TB…
PV
PV
8TB
mdadm mirror
8TB…
PV
PV
10TB
mdadm mirror
10TB…
PV
PV
12TB
mdadm mirror
12TB…
ZFS Pool
ZFS Pool
12TB
Mirror VDEV
12TB…
10TB
Mirror VDEV
10TB…
8TB
Mirror VDEV
8TB…
10TB
Mirror VDEV
10TB…
6TB
Mirror VDEV
6TB…
4TB
Mirror VDEV
4TB…
512GB
L2ARC Cache
512GB…

Before the migration, we must backup all the data from the LVM system. I cobbled together a collection of old hard drives and then proceeded to create another LVM volume as the temporary storage of the content. This temporary volume will not have any redundancy capability, so if any one of the old hard drives fails, then out goes all the content. The original LVM system is mounted on /mnt/airvideo and the temporary LVM volume is mounted on /mnt/av2.

I used the command below to proceed with the backup.

sudo rsync --delete -aAXv /mnt/airvideo /mnt/av2 > ~/nohup.avs.rsync.out 2>&1 &

I can then monitor the progress of the backup with:

tail -f ~/nohup.avs.rsync.out

The backup took a little more than 7 days to copy around 32 TB of data from our NAS server. During this entire process, all of the NAS services continued to run, so that downtime was almost non-existent.

Once the backup is completed, I wanted to move all the services to the backup before I started to dismantle the old LVM volume. The following steps were done:

  • Stop all services on other machines that were using the NAS;
  • Stop all services on the NAS that were using the /mnt/airvideo LVM volume;
    • sudo systemctl stop apache2 smbd nmbd plexmediaserver
  • Unmount the /mnt/airvideo volume, and create a soft-link of the same name to the backup volume at /mnt/av2;
    • sudo umount /mnt/airvideo
    • sudo ln -s /mnt/av2 /mnt/airvideo
  • Restart all services on the NAS and the other machines;
    • sudo systemctl start apache2 smbd nmbd plexmediaserver
  • Once again, the downtime here was minimal;
  • Remove or comment out the entry in the /etc/fstab file that automatically mounts the old LVM volume on boot. This is no longer necessary because ZFS is remounted by default;

Now that the services are all up and running, we can then start destroying the old LVM volume (airvideovg2/airvideo) and volume group (airvideovg2). We can obtain a list of all the physical volumes that make up the volume group.

sudo pvdisplay -C --separator ' | ' -o pv_name,vg_name

  PV | VG
  /dev/md1 | airvideovg2
  /dev/md2 | airvideovg2
  /dev/md3 | airvideovg2
  /dev/md4 | airvideovg2
  /dev/nvme0n1p1 | airvideovg2

The /dev/mdX devices are the mdadm mirror devices, each consisting of a pair of hard drives.

sudo lvremove airvideovg2/airvideo
Do you really want to remove and DISCARD active logical volume airvideovg2/airvideo? [y/n]: y
  Flushing 0 blocks for cache airvideovg2/airvideo.
Do you really want to remove and DISCARD logical volume airvideovg2/lv_cache_cpool? [y/n]: y
  Logical volume "lv_cache_cpool" successfully removed
  Logical volume "airvideo" successfully removed

sudo vgremove airvideovg2
  Volume group "airvideovg2" successfully removed

At this point, both the logical volume and the volume group are removed. We say a little prayer to ensure nothing happens with our temporary volume (/mnt/av2), that is currently in operation.

We now have to disassociate the mdadm devices from LVM.

sudo pvremove /dev/md1
Labels on physical volume "/dev/md1" successfully wiped.
sudo pvremove /dev/md2
Labels on physical volume "/dev/md2" successfully wiped.
sudo pvremove /dev/md3
Labels on physical volume "/dev/md3" successfully wiped.
sudo pvremove /dev/md4
Labels on physical volume "/dev/md4" successfully wiped.
sudo pvremove /dev/nvme0n1p1
Labels on physical volume "/dev/nvme0n1p1" successfully wiped.

You can find the physical hard drives associated with each mdadm device using the following:

sudo mdadm --detail /dev/md1
#or
sudo cat /proc/mdstat

We then have to stop all the mdadm devices and zero their superblock so that we can reuse the hard drives to set up our ZFS pool.

sudo mdadm --stop /dev/md1
mdadm: stopped /dev/md1
sudo mdadm --stop /dev/md2
mdadm: stopped /dev/md2
sudo mdadm --stop /dev/md3
mdadm: stopped /dev/md3
sudo mdadm --stop /dev/md4
mdadm: stopped /dev/md4

# Normally you also need to do a --remove after the --stop,
# but it looks like the 6.5 kernel did the remove automatically.
#
# For all partitions used in the md device

for i in sdb1 sdc1 sdp1 sda1 sdo1 sdd1 sdg1 sdn1
do
	sudo mdadm --zero-superblock /dev/${i}
done

Now with all of the old hard drives freed up, we can repurpose them to create our ZFS pool. Instead of using the /dev/sdX reference of the physical device, it is recommended to use /dev/disk/by-id with the manufacturer’s model and serial number so that the ZFS pool can be moved to another machine in the future. We also used the -f switch to let ZFS know that it is okay to erase the existing content on those devices. The command to create the pool we named vault is this:

zpool create -f vault mirror /dev/disk/by-id/ata-ST10000VN0008-2JJ101_ZHZ1KMA0-part1 /dev/disk/by-id/ata-WDC_WD101EFAX-68LDBN0_VCG6VRWN-part1 mirror /dev/disk/by-id/ata-ST8000VN0022-2EL112_ZA1E8GW4-part1 /dev/disk/by-id/ata-ST8000VN0022-2EL112_ZA1E8S0V-part1 mirror /dev/disk/by-id/ata-ST10000VN0004-1ZD101_ZA2C69FN-part1 /dev/disk/by-id/ata-ST10000VN0004-1ZD101_ZA2964KD-part1 mirror /dev/disk/by-id/ata-ST12000VN0008-2YS101_ZRT008SC-part1 /dev/disk/by-id/ata-ST12000VN0008-2YS101_ZV701XQV-part1

# The above created the pool with the old drives from the old LVM volume group
# We then added 4 more drives, 2 x 6TB, and 2 x 4TB drives to the pool

# Adding another 6TB mirror:

sudo zpool add -f vault mirror /dev/disk/by-id/ata-WDC_WD60EFRX-68L0BN1_WD-WX31D87HDU09-part1 /dev/disk/by-id/ata-WDC_WD60EZRZ-00GZ5B1_WD-WX11D374490J-part1

# Adding another 4TB mirror:

sudo zpool add -f vault mirror /dev/disk/by-id/ata-ST4000DM004-2CV104_ZFN0GTAK-part1 /dev/disk/by-id/ata-WDC_WD40EZRX-00SPEB0_WD-WCC4E0354579-part1

We also want to add the old NVMe as ZFS L2ARC cache.

ls -lh /dev/disk/by-id/nvme-Samsung_SSD_970_EVO_Plus_500GB_S4P2NF0M419555D

lrwxrwxrwx 1 root root 13 Mar  2 16:02 /dev/disk/by-id/nvme-Samsung_SSD_970_EVO_Plus_500GB_S4P2NF0M419555D -> ../../nvme0n1

sudo zpool add vault cache /dev/disk/by-id/nvme-Samsung_SSD_970_EVO_Plus_500GB_S4P2NF0M419555D 

We can see the pool using this command:

sudo zpool list -v vault

NAME                                                    SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP    HEALTH  ALTROOT
vault                                                  45.4T  31.0T  14.4T        -         -     0%    68%  1.00x    ONLINE  -
  mirror-0                                             9.09T  8.05T  1.04T        -         -     0%  88.5%      -    ONLINE
    ata-ST10000VN0008-2JJ101_ZHZ1KMA0-part1                -      -      -        -         -      -      -      -    ONLINE
    ata-WDC_WD101EFAX-68LDBN0_VCG6VRWN-part1               -      -      -        -         -      -      -      -    ONLINE
  mirror-1                                             7.27T  6.49T   796G        -         -     0%  89.3%      -    ONLINE
    ata-ST8000VN0022-2EL112_ZA1E8GW4-part1                 -      -      -        -         -      -      -      -    ONLINE
    ata-ST8000VN0022-2EL112_ZA1E8S0V-part1                 -      -      -        -         -      -      -      -    ONLINE
  mirror-2                                             9.09T  7.54T  1.55T        -         -     0%  82.9%      -    ONLINE
    ata-ST10000VN0004-1ZD101_ZA2C69FN-part1                -      -      -        -         -      -      -      -    ONLINE
    ata-ST10000VN0004-1ZD101_ZA2964KD-part1                -      -      -        -         -      -      -      -    ONLINE
  mirror-3                                             10.9T  8.91T  2.00T        -         -     0%  81.7%      -    ONLINE
    ata-ST12000VN0008-2YS101_ZRT008SC-part1                -      -      -        -         -      -      -      -    ONLINE
    ata-ST12000VN0008-2YS101_ZV701XQV-part1                -      -      -        -         -      -      -      -    ONLINE
  mirror-4                                             5.45T  23.5G  5.43T        -         -     0%  0.42%      -    ONLINE
    ata-WDC_WD60EFRX-68L0BN1_WD-WX31D87HDU09-part1         -      -      -        -         -      -      -      -    ONLINE
    ata-WDC_WD60EZRZ-00GZ5B1_WD-WX11D374490J-part1         -      -      -        -         -      -      -      -    ONLINE
  mirror-5                                             3.62T  17.2G  3.61T        -         -     0%  0.46%      -    ONLINE
    ata-ST4000DM004-2CV104_ZFN0GTAK-part1                  -      -      -        -         -      -      -      -    ONLINE
    ata-WDC_WD40EZRX-00SPEB0_WD-WCC4E0354579-part1         -      -      -        -         -      -      -      -    ONLINE
cache                                                      -      -      -        -         -      -      -      -  -
  nvme-Samsung_SSD_970_EVO_Plus_500GB_S4P2NF0M419555D   466G  3.58G   462G        -         -     0%  0.76%      -    ONLINE

Once the pool is created, we wanted to set some pool properties so that in the future when we replace these drives with bigger drives, the pool will automatically expand.

zpool set autoexpand=on vault

With the pool created, we can then create our dataset or filesystem and its associated mount point. We also want to ensure that the filesystem also supports posixacl.

zfs create vault/airvideo
zfs set mountpoint=/mnt/av vault/airvideo
zfs set acltype=posixacl vault
zfs set acltype=posixacl vault/airvideo

We mount the new ZFS filesystem on /mnt/av because the /mnt/airvideo is soft-linked to the temporary /mnt/av2 volume that is still in operation. We first have to re-copy all our content from the temporary volume to the new ZFS filesystem.

sudo rsync --delete -aAXv /mnt/av2/ /mnt/av > ~/nohup.avs.rsync.out 2>&1 &

This took around 4 days to complete. We can all breathe easy again because all the data now have redundancy again! We can now bring the new ZFS filesystem live.

sudo systemctl stop apache2.service smbd nmbd plexmediaserver.service
sudo rm /mnt/airvideo
sudo zfs set mountpoint=/mnt/airvideo vault/airvideo
sudo systemctl start apache2.service smbd nmbd plexmediaserver.service

zfs list

NAME             USED  AVAIL     REFER  MOUNTPOINT
vault           31.0T  14.2T       96K  /vault
vault/airvideo  31.0T  14.2T     31.0T  /mnt/airvideo

The above did not take long and the migration is completed!

df -h /mnt/airvideo

Filesystem      Size  Used Avail Use% Mounted on
vault/airvideo   46T   32T   15T  69% /mnt/airvideo

Getting the capacity of our new ZFS filesystem shows that we now have 46TB to work with! This should last for at least a couple of years I hope.

I also did a quick reboot of the system to ensure it can come back up with the ZFS filesystem in tack and without issues. It has now been running for 2 days. I have not collected any performance statistics, but the services all feel faster.

Media Server Storage Hardware Reconfiguration

Our media server has reached 89% utilization and needs storage expansion. The storage makeup on the server uses Logical Volume Manager (LVM) and software RAID called mdadm. I can expand the storage by swapping out the hard drives with the least capacity with new hard drives with a larger capacity like I have previously done.

I thought I try something different this time around. I would like to switch from LVM to ZFS, an LVM alternative that is very popular with modern mass storage systems, especially with TrueNAS.

All filled with 8 drives

Before I can attempt the conversion, I will first need to backup all of the content from the media server. The second issue is that I needed more physical expansion space on the server to house more hard drives. The existing housings are all filled except for a single slot, which is going to be insufficient.

A related issue is that I no longer have any free SATA slots available for the new hard drives, so I purchased GLOTRENDS SA3116J PCIe SATA Adapter Card with 16 SATA Ports. Once this is installed, I have more than enough SATA ports for additional storage.

PCIe SATA Card Installed

One downside of the SATA card is that it is limited to PCIe 3.0 x1 speed. This means data transfer is limited to a theoretical maximum of 1GB/s. Given that the physical hard drives top out at 200MB/s, I don’t think we need to be too concerned about this bottleneck. We will see in terms of practical usage in the future.

I am so lucky to have extra SATA power cables and extension cables laying around and my 850W existing power supply has ample power for the additional hard drives.

How do we store the additional hard drives with a full cabinet? I went to Amazon again and purchased a hard drive cage, Jaquiain 3.5 Inch HDD Hard Drive Cage 8X3.5 Inch HDD Cage. I did not have to buy any new hard drives yet, because I had plenty of old hard drives laying around. After I put together the cage with 8 really old and used hard drives, it looks something like this:

With this new additional storage, I am now able to backup the media content from my media server. However, before I do that there is one last thing that I need to do, and that is to experiment with an optimal ZFS pool configuration that will work with my content and usage. I will perform this experimentation with the additional storage before reconfiguring the old storage with ZFS. Please stay tuned for my findings.

After booting the system with 16 hard drives, I measured the power usage and it was hovering around 180W. This is not too bad, less than 2 traditional incandescent light bulbs.


Addendum:

During my setup, I had to spend hours deciphering an issue. My system did not recognize my old hard drives. After many trials, I finally narrowed down that the GLOTRENDS card is not compatible with an old 2TB Western Digital Enterprise Drive. This is the first time that I came across SATA incompatibilities.

There is another possibility that these drives were damaged by the usage of an incorrect modular power cable. I found that these drives also do not work with my USB3.0 HDD external dock as well. This gives additional credence that the physical drive has been damaged.

The troubled drive with the SATA card

All my other drives worked fine with the card.

Another discovery is that not all modular power cables will work with my ASUS ROG STRIX 850W power supply. Initially, I thought I would use an 8-pin PCIe to 6-pin adapter along with a 6-pin to SATA power cable designed for Corsair power supplies.

PCIe Power Adapter from Amazon
OwlTree PCI-e 6 Pin Male to 4 SATA 1 to 4 SATA Female Power Supply Splitter Supply Cable for Corsair Modular RM650X RM750X RM850X RM1000X

Using the above cables will cause the power supply not to start. I had to hunt for the original cables that came with the STRIX power supply.

Learned a lot from rejigging this media server. My reward is to see my server boot up with 16 hard drives and 2 NVMe SSD drives recognized. I have never built a system with so many drives and storage before.

What is the Chinese Government?

Recently I have been faced with questions and accusations on how corrupt and dictatorial the Chinese government is to its population. Most of these comments come from people who have not visited and experienced China. Their conclusion largely stems from the feeding of Western mainstream media.

I provide this post as a source of “alternative” information so that anyone can get a quick introduction of what is the Chinese government and how is it being run?

Take a look at this TED talk by Eric Li. He quickly summarizes the differences between the Chinese government that are based on merit versus one that is based on votes practiced by the West.

Eric Li’s TED Talk: A tale of two political systems

Once you finished the above video, I encourage you to read the following answer to the Quora question included below. You can click on the question to go directly to the Quora site and gain additional insights from the other answers. I just happen to particularly like this one.


Don’t people in China wish to live in a democratic country?

Answered by YN Chen on Quora on Nov 5, 2023

I am a Chinese, have studied in the UK and traveled to many countries.

For me, China is democratic – probably even more democratic than western countries.

Of course, I am referring to the original meaning of the word democracy – the power of the state belongs to the people and the people have the right to rule the government.

Nowadays, democracy in the west often refers to multi-party competition, where the ruling party are elected by universal suffrage.

But this approach has some significant problems. As voters are ordinary people who has no specialized knowledge on managing the country, the core competitiveness of the election process becomes the ability to publicize public opinion, personal affinity, and persuasion, which have little to do with whether they can actually formulate and implement policies well, but are more relevant to the resources of the society and the media operation behind them.

In the west, the rule of the people is in a single choice question of political preference, and the frequency of being able to make a choice is once every four years. If you are the minority voter, you will not be able to get a satisfactory result in those four years.

In contrast, China’s “democracy” works like this:

  1. A huge system of officials that everyone can enter by studying and taking exams – from the smallest local township government to the central government, all within the same pyramid-tested promotion system. For Chinese graduates, it is a very common career selection to pick an official position related to their major from an open government list, take a test on logic and issue processing skills, and become a government official. All newcomers need to start from the basic positions and get enough practical results before they are internally elected with promotion.
  2. The criterion value of the government affairs is “people first”. The most important judgment dimension is whether they can improve the life of the majority and satisfy the people.
  3. Public opinion monitoring and feedback mechanism. All levels of government have set up channels to receive public opinion, such as emails, petitions reception, or social media. For every actual problem, the government must give feedback or specific plans within a period of time; and after a period of time, they must do regular follow-up visits to ensure that the problem has been solved satisfactorily. All this is counted in the KPIs of government staff. If the people are not satisfied with this government’s response, they can complain to a higher level of government, which has absolute power over the next level of government, and the government department complained against will be penalized and monitored.

In China, the rule of the people is in the government’s “people first” evaluation criteria, and in the mechanism of feedback and resolution of specific issues that are highly valued. However, if your opinion is detrimental to the interests of the underprivileged, or if you are not looking for a solution, but simply venting your negative feelings and trying to get more people to share your negative feelings, then your opinion might be refused or ignored, or be deferred in to future considerations.

I think this is why people say: in the west, you can change the government, but you can’t change the policies; however in China, you can’t change the government, but you can change the policies.

Of course, both mechanisms have their own drawbacks. For example, since the core competence of universal suffrage is the ability of influencing public opinion, so having control of the media and enough money is almost equivalent to having a high probability of obtaining the highest power in the country; in China, it is very difficult to make the complex internal promotion completely transparent, and it is not easy for the people to monitor inefficiencies and corruption inside the system.

But for me and at least 80%+ Chinese people, the current one party Chinese government is still very satisfactory.

As for the so-called “Communist Party is not the same as government”: in fact, the CCP is not the same as the Soviet Union type of “communism”, for example, China has its market economy system and is running well. Actually when there is only one political party, the notion of party advocacy would be extremely weakened. In the case of China, people would tend to feel that the Chinese system is more like a parliamentary system even within the government. China is a country with a secular culture, and ideology discussion is not really that important, what matters to this government council is simply about insisting with the people-oriented value, and making people living in better lives.

To be honest, I think that the vast majority of the world’s people don’t care about politics.

People care more about their own lives – whether they can live healthy and happy lives with the people they love, whether the society is fair, safe and free, whether they can enjoy their civil rights as a human being, whether their problems can be solved and whether their dreams can be realized.

Also, I agree that China is better for ordinary people, small and medium-sized entrepreneurs to live in, but not for the extremely rich guys. If you are a rich tycoon or celebrity and has no interest in benefiting ordinary people, then the Chinese government might supervising you with very strict rules, you will have more freedom and power in the West.

But as for me, China is not bad.


Finally, to get a deeper dive, I recommend the following book:

The New China Playbook: Beyond Socialism and Capitalism (by: Keyu Jin)

Wake-on-LAN for Linux

My sons upgraded their gaming computers last Christmas, and I ended up using their old parts to build a couple of Linux servers running Ubuntu servers. The idea is to use these extra servers as video encoders since they will have dedicated GPUs. However, the GPUs are also pretty power-hungry. Since they don’t need to be up 24 hours a day, I thought keeping these servers asleep until they are required would be good. At the same time, it would be pretty inconvenient to go to the servers to physically power them up when I needed them. The thought of configuring their Wake-on-LAN came to mind.

I found this helpful article online. I first found out that the Network Interface on the old motherboards supports Wake-on-LAN (WOL). Below is a series of commands that I executed to find out whether WOL is supported or not, and if so, then enable the support.

% sudo nmcli connection show
NAME                UUID                                  TYPE      DEVICE
Wired connection 1  d46c707a-307b-3cb2-8976-f127168f80e6  ethernet  enp2s0

% sudo ethtool enp2s0 | grep -i wake
	Supports Wake-on: pumbg
	Wake-on: d

The line that reads,

Supports Wake-on: pumbg

indicates the WOL capabilities, and the line that reads,

Wake-on: d

indicates its current status. Each letter has a meaning:

  • d (disabled), or
  • triggered by
    • p (PHY activity), 
    • u (unicast activity),
    • m (multicast activity),
    • b (broadcast activity), 
    • a (ARP activity),
    • g (magic packet activity)

We will use the magic packet method. Below are the commands used to enable WOL based on the magic packet trigger.

% sudo nmcli connection modify d46c707a-307b-3cb2-8976-f127168f80e6 802-3-ethernet.wake-on-lan magic

% sudo nmcli connection up d46c707a-307b-3cb2-8976-f127168f80e6
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)

% sudo ethtool enp2s0 | grep -i wake
	Supports Wake-on: pumbg
	Wake-on: g

The above changes will persist even after the machine reboots. We put the machine to sleep by using the following command:

% sudo systemctl suspend

We need the IP address and the MAC address of the machine to wake the computer up using the wakeonlan utility.

% ifconfig
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.168.185  netmask 255.255.255.0  broadcast 192.168.168.255
        inet6 fd1a:ee9:b47:e840:6cd0:bf9b:2b7e:afb6  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::41bc:2081:3903:5288  prefixlen 64  scopeid 0x20<link>
        inet6 fd1a:ee9:b47:e840:21b9:4a98:dafd:27ee  prefixlen 64  scopeid 0x0<global>
        ether 1c:1b:0d:70:80:84  txqueuelen 1000  (Ethernet)
        RX packets 33852015  bytes 25769211052 (25.7 GB)
        RX errors 0  dropped 128766  overruns 0  frame 0
        TX packets 3724164  bytes 4730498904 (4.7 GB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

We use the above ifconfig to find the addresses highlighted in bold. Once we have the required information, we can then wake the computer up remotely by executing the wakeonlan command from another computer.

% wakeonlan -i 192.168.168.255 -p 4343 1c:1b:0d:70:80:84
Sending magic packet to 192.168.168.185:4343 with 1c:1b:0d:70:80:84

Note that the above IP address used is the broadcast address and not the machine’s direct IP address. Now I can place these servers to sleep and only turn them on remotely when I need them.

EXT4-fs Errors on NVME SSD

In my previous post, I replaced my NVME boot disk on our media server thinking that the disk was defective because the file system (EXT4-fs) was reporting numerous htree_dirblock_to_tree:1080 errors.

The errors continue to persist with the new disk, so I can eliminate the possibility of hardware as the cause of the issue.

I noticed that the htree_dirblock_to_tree:1080 errors were caused by the tar command and the time in which these errors occur coincided when the media server is being backed up. Apparently, the backup process is causing these errors with the tar command.

This backup process has remained unchanged for quite some time and has worked really well for us. I guess for some reason there is a bug in the kernel or in the tar command that is not quite compatible with NVME devices.

I had to resort to finding an alternative backup methodology. I ended up using the rsync method instead.

sudo rsync --delete \
  --exclude 'dev' \
  --exclude 'proc' \
  --exclude 'sys' \
  --exclude 'tmp' \
  --exclude 'run' \
  --exclude 'mnt' \
  --exclude 'media' \
  --exclude 'cdrom' \
  --exclude 'lost+found' \
  --exclude 'home/kang/log' \
  -aAXv / /mnt/backup

It looks like this method is faster and can perform incremental backup. However, instead of backing up to an archive file, which I later need to extract and prepare during the restoration process, I have to back it up to a dedicated backup device. Since the old NVME disk is perfectly fine, I reused it as my backup device. I have partitioned this backup device in the same layout as the current boot disk.

Device          Start        End    Sectors   Size Type
/dev/sdi1        2048    2203647    2201600     1G Microsoft basic data
/dev/sdi2     2203648 1921875967 1919672320 915.4G Linux filesystem
/dev/sdi3  1921875968 1953523711   31647744  15.1G Linux swap

The only exception is that the first partition is not marked as boot and esp, so during the restoration process I will have to mark that partition accordingly with the parted command by using the following commands:

set 1 boot on
set 1 esp on

The idea is that at 3am every night/morning, I will backup the root filesystem to the second partition of the backup drive. If anything happens with the current boot disk, the backup drive can act as an immediately available replacement, after a grub-install preparation as mentioned in the previous article.

Let us see how this new backup process works and hopefully, we can bid a final farewell to the htree_dirblock_to_tree:1080 errors!

Update: 2023-12-22

It looks like even with the rsync command, the htree_dirblock_to_tree:1080 errors still came back during the backup process. I decided to upgrade the kernel from vmlinuz-5.15.0-91-generic to vmlinuz-6.2.0-39-generic. Last night (2023-12-23 early morning) was the first backup after the kernel upgrade, and no errors were recorded. I hope this behavior persists and it is not a one-off.

Replacing NVME Boot Disk

A few months ago, the boot disk of our media server begin to incur some errors, such as the ones below:

Dec 17 03:01:35 avs kernel: [32515.068669] EXT4-fs error (device nvme1n1p2): htree_dirblock_to_tree:1080: inode #10354778: comm tar: Directory block failed checksum
Dec 17 03:02:35 avs kernel: [32575.183005] EXT4-fs error (device nvme1n1p2): htree_dirblock_to_tree:1080: inode #13500463: comm tar: Directory block failed checksum
Dec 17 03:02:35 avs kernel: [32575.183438] EXT4-fs error (device nvme1n1p2): htree_dirblock_to_tree:1080: inode #13500427: comm tar: Directory block failed checksum

The boot disk is a NVME device and I thought it may be due to over heating, so I purchased a heat sink and installed it. Unfortunately the errors persisted after the heat sink.

I decided to replace the boot disk with the exact same model which was the Samsung 980Pro 1TB. This should have been a pretty easy maintenance task. We clone the drive, and swap in the new drive. However, Murphy is sure to strike!

My usual goto cloning utility is Clonezilla, unfortunately this utility did not like cloning NVME drives. The utility resulted in a kernel panic after trying multiple versions. I am not sure what is the problem here. It could be Clonezilla or the USB 3.0 NVME enclosure that I was using for the new disk.

I resigned to using the dd command:

dd if=/dev/source of=/dev/target status=progress

Unfortunately this would have taken way too long something like 20+ hours, so I gave up with this approach.

I decided to do a good old restore of the nightly backup. I started by cloning the partition table:

sfdisk -d /dev/olddisk | sfdisk /dev/newdisk

I then proceeded with the restore of the nightly backup. Murphy strikes twice! The nightly backup was corrupted! I guess it is not surprising when the root directory’s integrity is in question. The whole reason why we are doing this exercise.

Without the nightly backup, I had to resort to a live backup. I booted system again, and performed:

sudo su -
mount /dev/new_disk_root_partition /mnt/newboot
cd /
tar -cvpf - --exclude=/tmp --exclude=/home/kang/log --exclude=/span --exclude="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Cache" --one-file-system / | tar xvpzf - -C /mnt/newboot --numeric-owner

The above took about an hour. I then copy the /span directory manually, because this directory tends to change while the server is up and running.

With all the contents copied, I forgot how to install grub and had to re-teach myself again. I had to use a live copy Ubuntu USB and use that to boot up the machine, and then mount both the root and efi partitions respectively.

nvme1n1                              259:0    0 931.5G  0 disk
├─nvme1n1p1                          259:1    0     1G  0 part  /boot/efi
├─nvme1n1p2                          259:2    0 915.4G  0 part  /
└─nvme1n1p3                          259:3    0  15.1G  0 part  [SWAP]

And install GRUB.

sudo su -
mkdir /efi
mount /dev/nvme1n1p1 /efi
mount /dev/nvme1n1p2 /mnt
grub-install --efi-directory /efi --root-directory /mnt

I also have fix the /etc/fstab to ensure the root partition and /boot/efi partition are properly referenced by their corresponding, correct UUID. The blkid command came in handy to find the UUID. For the swap partition, I had to use the mkswap command before I get the UUID.

After I rebooted, I reinstalled GRUB one more time with the following as super user:

grub-install /dev/nvme1n1

I also updated the initramfs using:

update-initramfs -c -k all

For something that should have taken less than an hour, it took the majority of the day. The server is now running with the new NVME replacement disk. Hopefully this resolves the file system corruptions. We have to wait and see!

Update: The Day After

The same errors occurred again! I noticed that these corruptions occur when we do a system backup. How ironic! I later confirmed that performing the tar command on the root directory during the backup process can cause such an error. I now have to see why this is. I will disable the system backup for the next few days to see if the errors come back or not.

How China Got Rich

After watching the documentary called “How China Got Rich” by Michael Woods, originally released in 2019, from my Amazon Prime subscription, I thought while my China experiences and memories are still fresh in my mind, I provide a few of my own takeaways here. Not all of these thoughts stem from the video itself. Some of these ideas have been toiling in my mind for quite some time and the video has just triggered them to the surface. I have articulated some of these ideas on Quora before but have never really put them in a long and organized form, which I will attempt to do here.

The video starts with the transition from Mao Zedong (毛泽东) to Deng Xiaoping (邓小平), where Chinese leadership collectively recognized that the focus on ideology alone cannot be the sole recipe for success. Sooner or later practicality, along with social improvement is required. One can debate whether the Communist Party of China (CPC) took too long to recognize this change, or that it took the passing of Mao for this change to be realized, the important takeaway here is that the government recognized the need for change and carried it out. The documentary even gave some examples where certain changes were carried out within weeks of the decision to formulate the Special Economic Zones.

Although a peaceful change in government is one of many foundational ideas in a Western-style democracy, a similar change of equal magnitude in the West will be challenging. The concept of when people are unhappy with the government, they can use their voting power to change it, sounds really attractive, and the West habitually points out that Communist China lacks this governing feature.

The theory of these peaceful changes fails to deliver on the actual progress desired by the majority of us. The new government often runs similar policies to the previous government because many of the appointed civil servants, advisors, and lobbyist groups remain unchanged. One can even argue that the voted-in politicians are nothing more than figureheads, while true decision and policy-making power stems from the people behind the scenes. Yes, policy changes do happen, but at a much slower pace and with a lot of back-and-forth debates. These debates culminate in grandstanding and ego projections instead of converging to constructive agreements.

An example of a change that occurs at a glacier pace is that to this day, Toronto subway systems still lack modern data services to their passengers while riding on the train. Meanwhile from the inception of mobile services to today, Chinese cities have built (many from scratch) modern subway systems with full 5G data coverage for their ridership.

The West meanders changes through cycles of elections. When social discourse is in harmony, progress is still made at a snail’s pace. When social division is the norm, like today, change in power represents flip-flopping of decisions, and taking one step forward and two steps back.

Although centralized power is disliked by the West, China’s leaders understand that their centralized power stems from the people. As architects of the previous revolution, they understand how unhappy people can be quickly mustard to form a strong force against the incumbent government. Therefore they are more compelled to listen and truly reflect on their own policies and institute potential changes. Any disagreement by the public nearing social disruptions, is rapidly answered by the government. Examples are:

  • Failure of regional banks which incites loud demonstrations by local customers forced the government to guarantee all of their deposits;
  • A rapidly transmitting and lethal disease in 2019 called COVID-19 caused public outcry due to government inaction. The government was compelled to change from its original decision of censorship to immediate action leading to a rapid city lockdown of Wuhan;
  • Once COVID-19 has mutated to be less deadly and containment proved to be too challenging, public opinion shifted to open the gates. The government hesitated but ultimately relented to the gradual opening up of the entire society;

The documentary gave numerous accounts where the CPC’s primary focus is the betterment of the livelihood of ordinary people, lifting them from their impoverished state. It is not about world domination, or increasing the country’s soft power over other nations. It was all about improving people’s day-to-day life.

CPC’s foreign policy is one of many instruments towards the goal of what makes an average Chinese life better. The same is true of its monetary, economic, climate, and other policies. The end results of these policies are being interpreted by the West as threats of domination or have the potential of tainting the way of life of the West. These grievances are just envious (but despicable) interpretations of China’s rapid social, economic, technological, and military progress. The primary focus of the CPC is the average life of a Chinese living in China. And yes, this includes the Chinese in Taiwan.

In China, once they set out on a goal, their path to executing that goal is unrelenting. Any distractions or distractors are removed as soon as they are realized to be inhibitors of the ultimate plan. Sacrifices are weighed and hard decisions are taken with the assumption that the plan is better for the entire society. And it is okay that certain individuals’ welfare or organizations are sacrificed for the greater cause.

The idea that the populace must hold the country’s interest to be higher than a family’s or individual’s interest is a concept that is very difficult for the West to accept, since individual freedom and property ownership is a core value to the West’s concept of liberty. In Chinese society, social stability is paramount, and they are tolerant if they have to make certain minority groups unhappy to achieve their goals. Personal happiness is simply secondary to social well-being.

The video mentions that the CPC made an early and conscious decision to embark on economic liberalization but retain political centralization. This is an important decision by the CPC so that they have the power to execute on the big economic changes. These changes undoubtedly will cause some amount of short-term inequity and they have to be endured. In short, the massive economic change over the past 40 years did not create happiness for everyone, for the majority, yes.

The CPC realizes that the macro economy of any society is simply too complex to be planned out every five years. The capitalist free market model allows for a self-adjusting system, which determines the most optimal products and services to be made and delivered, and a self-regulation of demand based on a value-based system. This value-based system requires the natural flow and ebb of market pricing to work, creating a self-prioritization of goods and services, through the use of natural price elasticity, which is driven by market forces of supply and demand. The root driver of this economic momentum and self-adjustment is a degree of inequity in the system. Without profit which is an inequity between revenue and cost, the free market ceases to function.

The CPC realizes the benefit of such a market force and pursues this agenda through Special Economic Zones like Shenzhen. In these zones, a market is allowed to be established, and businesses (and their owners) can prosper (get wealthy) in developing and choosing the most optimal products that are in need, for both domestic and global consumption.

At the same time, political changes (such as a move to a Western style of democratization), are avoided and prohibited. In this way, the CPC can keep Chinese society focused on its primary goal, improving people’s lives. Changing both the political and economic system will be one change too many.

If China does not have a central authority and lacks the one-party system, the pace we witness today simply will not exist. Think of China as a big technology corporation. The CPC is the management authority within this company. The CPC sets up R&D divisions within the company. These divisions are akin to the Special Economic Zones. Once the CPC figures out what works and what does not, the management mechanism rolls it forward to the rest of the country or company.

The evolution of the Chinese market has allowed a growing income gap to form. Initially, this is tolerated because the CPC needs to allow innovation and there is no greater incentive and motivation than getting rich individually. However, the existence of an income gap is counter to the beliefs of the betterment for all. This income inequity is a deviation from the CPC’s primary goal. The economic zones created huge opportunities for millions of people but certainly did not spread the wealth equally to all people in China, especially those in the rural areas of China.

To balance the nature of a free market and a means of wealth distribution such that more of the population benefits from the country’s continual development, and yet not upsetting the rich too much, a central form of control is required. A Western democratic system will cause the rapid growth of the free market uncontrollable. CPC today has the power to reel in the corruption of those in authority and manage the influence of the rich. An excellent example is the dismantling of the financial instruments provided by the Ant Group (a Jack Ma’s company) before it is allowed to impact the country’s financial systems.

CPC’s central authority is the primary mechanism by which the party can influence its population. You can call it brainwashing, propaganda, or education. However you choose to categorize or term this form of control, it is how the CPC coaches its population to ensure each member of the “team” knows the direction of the goal. Every five years the CPC develops a new Five-Year-Plan that is effectively a playbook to guide members of society so that they kick the ball towards the goal(s) in the most efficient and unified fashion possible. I think this is ultimately the secret sauce in China’s acceleration to its rapid pace in accumulating its wealth and capabilities.

Most of the West believes in the Invisible Hand of the economy, and that the government should allow the market to function without much intervention. This belief has worked during economic revolutions spanning from the industrial to the information revolution. During these revolutions, the biggest challenge of modern governments was the management of poverty and the middle-classes. Some are more successful than others. However, as we enter into the era of artificial intelligence (AI) when human economic value is effectively being eroded or eliminated, we may not be able to depend on the Invisible Hand to ensure our livelihoods. The Chinese system is well positioned to regulate AI in its economy and provides a thicker security blanket to people’s well-being from potential threats from AI.

China’s implementation of its development is to leverage the Invisible Hand of the free market forces to determine what works and guide it with its Strong Hand of central authority such that the focus on its primary goal is not lost. The speed of development is the result of walking this balance.

Controversies

We now live in a world where if you live in the West, democracy is good, and authoritarian or dictatorship is bad. The mechanism and structure of the government are automatically used to categorize whether the government is good or bad for its people. The debates summarily center around what democracy provides, which is freedom and liberty, versus repressions and restrictions that non-democratic governments project. These ideas have been entrenched in us since our early education, that it is extremely difficult for a person in the West to have an open mind regarding non-democratic societies. Interestingly, we allow for different religions to be practiced, but in terms of the types of government, it is democracy and nothing else.

Many of us will not measure the true effectiveness of a government by observing the results that the government yields for its people. Instead, we flock to the core idea of the ability to vote, and the assumption that our voting power gives us the ability to affect change in our government. Elections are held every four to five years, and hold the firm belief that we can participate in the change of government and elect representatives that then decide what is best for us for the next four to five years. However, these elections are nothing more than pacifying events creating an illusion of power to change. In reality, it is simply a hand-waving motion that takes place every four to five years.

In effect, if an individual really wants to implement change in the current government, one needs to be politically active. Similar to starting a company and seeking funding to operate its business, the same holds true for any political ventures in the West. Politicians are therefore at the mercy of the wealthy who can allocate the money required to enable the politicians to play within the political system. It is therefore easy to see how political representation is ultimately biased towards the people who are funding you instead of those who directly voted for you.

The Chinese governing system is a meritocracy, where leaders are first proven with smaller responsibilities at the county or municipal level, and subsequently appointed to larger portfolios such as city and province levels. Eventually through competition, political maneuvering, and when the stars and planets finally align, you can attain the top position of the party and the presidency of the country. Throughout this ascension, a party member holding a leadership position acquires skills to make people’s lives better, from thousands to ultimately billions of people.

It is easy to debate which type of government is procedurally (and theoretically) better, but in the end, what matters to the people is a government that delivers a better livelihood to its people. I compare this debate to an argument about which Apple Pie recipe tastes better. However, the recipe (procedure or mechanics) is not enough in the sole determination of how tasty the final pie will taste to one’s palate. Other factors exist to determine the success of the pie, such as the sourcing of the ingredients, the cook’s skill in carrying out the recipe with his experience, and the final presentation and delivery of the pie. There are simply too many other variations other than the recipe.

Debating the form of government is unproductive. It is more valid to debate what the government actually accomplishes for its people. Otherwise, we are just debating on ideological differences, something to be avoided if we do not want a reoccurrence of the Crusades when Christianity was pitted against the religion of Islam.

Results

China’s combination of a centralized government and a market economy gives it a unique power to solve some large social issues, with both efficiency and focus. They are not perfect and mistakes have been made. However, they also can self-reflect and take corrective actions. And yes sometimes unfair decisions are made in the process.

People that I have met and discussed within China certainly do not feel oppressed. They feel free and lucky to be living in a country, where they can now enjoy many of the same goods and services that are available in the West. People who are 35 years of age and older will have witnessed this improvement, which they directly credit the CPC.

Except for Hong Kong and Macau, the Chinese can take advantage of their convenient and cheap transportation system and enjoy their vast country with beautiful geological sceneries, and diverse ethnic cultures. Why the exception to Hong Kong and Macau? The working theory is to protect Hong Kong and Macau’s market development. Imagine if people can freely move into the former colonies, their markets will be diluted and it will be harder for them to remain globally competitive.

With that said, there are still people in China who prefer to live in the West. These are typically upper middle class or higher, who have made their riches and do not want to experience the potential of the CPC to relevel their wealth. This is quite understandable from an individual perspective. Managing a sustainable income gap is one of CPC’s core challenges.

Other Thoughts

My thoughts on the subject of China have led me to come to some other conclusions in the following areas:

  • The true meaning of rights and freedoms within a society;
  • Intellectual properties and what it really means to a society;
  • The concept of profit, income, and debt, and how we are all manipulated by the modern financial system;
  • The right to project one’s will and values on another based on one’s moral high ground;
  • The justification of censorship vs. free speech;

This post is already quite lengthy, so I think will come back to the above topics and address each one in turn.

Fenggang to Toronto

We spent the remaining days of November in Fenggang and then took our flight home via Tokyo on December 1st.

Not much exciting happened in the remaining days other than relaxing and going about what locals do. Effectively, we enjoyed the native life in Fenggang County (县), Dongguan City (市), Guangdong Province (省). I fell ill, so there was zero energy in me to do much travelling. Our original plan of visiting Shenzhen had to be scuttled.

We completed some final banking businesses, and also learned that our access to our Chinese banking accounts may be difficult through our Nihao Mobile numbers, but it was a bit too late to make this change. If we had to do things differently next time, we would probably get a number from one of the big three mobile operators in China, which are: China Mobile (中国移动), China Telecom (中国电信), and China Unicom (中国联通). The primary reason is that Nihao Mobile numbers cannot be active outside of China, but the others can be roamed in Canada and receive SMS messages for authentication services, which are essential for banking applications. We will get this fix on our next trip, which we plan to go at about the same time next year.

Our last leg home was on a flight through Air Canada. Every time I fly this leg from the Far East to Toronto, I swear that I will not be flying on Air Canada ever again on the same route. However the cheap the fare was, it was not worth the hassle. The disorganized boarding process, the narrow seats, the low quality of the food and sometimes adversarial cabin service, and finally the baggage handling delays, all would make me regret in saving a few bucks. Cathay Pacific all the way next time for sure, or one of the Chinese airlines.

Below are the remaining and final videos from Carol documenting our Asian Trip. It has been a blast.

November 28th: Grocery shopping
November 29th: Sampling more restaurants from Fenggang
November 30th: Sampling all the wontons from different restaurants
December 1st: Coming home via Hong Kong and Tokyo