Safely remove SATA disk from a running Linux system

Stop using the disk for anything. Then unmounted any file systems on the disk.

sudo umount ...

Deactivate any LVM groups.

sudo vgchange -an

Prevent disk damage with stop system using disk.

echo 1 | sudo tee /sys/block/{disk}/device/delete

Once you’ve done that, it should be safe to unplug SATA disk from running system.

Update CentOS kernel for deploy Google BBR

BBR (Bottleneck Bandwidth and RTT) is a new congestion control algorithm which is contributed to the Linux kernel TCP stack by Google. With BBR in place, a Linux server can get significantly increased throughput and reduced latency for connections. Besides, it’s easy to deploy BBR because this algorithm requires only updates on the sender side, not in the network or on the receiver side.

Continue reading “Update CentOS kernel for deploy Google BBR”

Kernel tuning for linux server

Kernel sysctl configuration file for Linux

The following is suitable for dedicated web server, mail, file server etc.
place file in /etc/sysctl.d/60-zercle.conf
and run sysctl --system

[Workaround] Override docker systemd service

Make config directory for docker service

mkdir -p /etc/systemd/system/docker.service.d/

Add config file for override etc. /etc/systemd/system/docker.service.d/host.conf

[Service]
ExecStart=
ExecStart=/usr/bin/dockerd

Reload systemd

systemctl daemon-reload

Then can use host directive in /etc/docker/daemon.json

{
        "hosts":["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"],
        "iptables": false,
        "tlsverify": true,
        "tls": true,
        "tlscacert": "/etc/ssl/private/docker/docker-ca.pem",
        "tlscert": "/etc/ssl/private/docker/server-cert.pem",
        "tlskey": "/etc/ssl/private/docker/server-key.pem"
}

Use LZ4 with tar for compress multiple directories

lz4 is an extremely fast lossless compression algorithm, based on byte-aligned LZ77 family of compression scheme. lz4 offers compression speeds of 400 MB/s per core, linearly scalable with multi-core CPUs. It features an extremely fast decoder, with speed in multiple GB/s per core, typically reaching RAM speed limit on multi-core systems. The native file format is the .lz4 format. But lz4 accept input with files only if want to compress directory we need to tar them into tar files before compress it.

First install lz4

apt install liblz4-tool

Then compress it

tar cf - dir1 dir2 dir3 dirX | lz4 -v > file_name.tar.lz4
OR
tar cf - dir_pattern* | lz4 -v > file_name.tar.lz4

Finally decompress it

lz4 -d -v file_name.tar.lz4 | tar xf - -C /target/directory

 

Workaround openmediavault python 3.5 weakref.py error

When you update or install something in openmediavault 4.x and saw theses

Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7fb7d2d82730>
Traceback (most recent call last):
  File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable
Exception ignored in: <function WeakValueDictionary.__init__.<locals>.remove at 0x7fb7d2d82730>
Traceback (most recent call last):
  File "/usr/lib/python3.5/weakref.py", line 117, in remove
TypeError: 'NoneType' object is not callable

You can workaround it with

curl -L https://raw.githubusercontent.com/python/cpython/3.5/Lib/weakref.py > /usr/lib/python3.5/weakref.py

 

 

Thailand ISP’s DNS

AIS
Preferred DNS server 115.178.58.10
Alternate DNS server 115.178.58.26

True
Preferred DNS server 203.144.207.29
Alternate DNS server 203.144.207.49

3BB
Preferred DNS server 110.164.252.222
Alternate DNS server 110.164.252.223

TOT
Preferred DNS server 203.113.127.199
Alternate DNS server 203.113.24.199

SINET
SINET-INET
Preferred DNS server 203.150.213.1
Alternate DNS server 203.150.218.161
SINET-BeeNet
Preferred DNS server 117.121.222.223
Alternate DNS server 117.121.210.111

CAT
Preferred DNS server 61.19.245.245
Alternate DNS server 61.19.245.246

Cloudflare
Preferred DNS server 1.1.1.1
Alternate DNS server 1.0.0.1

GOOGLE
Preferred DNS server 8.8.8.8
Alternate DNS server 8.8.4.4

Change Ubuntu grub background colour

sudo -H gedit /usr/share/plymouth/themes/default.grub

And change the grub background colour as you want with RGBA code, in my case I change grub background to gray (128,128,128,0)

if background_color 128,128,128,0; then
  clear
fi

Then, update grub

sudo update-grub