Month: December 2021

Memory upgrade for Synology DS2419+

Memory upgrade for Synology DS2419+

As mentioned in memorystock.com, Synology DS2419+ can use Dual Rank Memory (16GB DDR4 PC4-19200 2400MHz SODIMM NON-ECC Unbuffered 260pin 1.2V CL15 Dual Rank MemoryStock Part# 977ms-977). But my last upgrade failed using Dual Rank memory, only Single Rank works.

Some people mentioned that Synology NAS can use 32GB RAM, but some people said it will cause data corruption if exceed max supported memory. I just upgraded my DS1812+ more than officially supported memory size, hope it will be ok.

References

Synology 64GB DDR4 Unofficial Memory Upgrade Test for DiskStation NAS
Synology NAS Unofficial Memory Upgrade Guide
Memory Upgrade for Synology DiskStation DS2419+ Computer

Renumber storage pools and volumes in Synology NAS

Renumber storage pools and volumes in Synology NAS

Story

For me, memorizing is a big issue, especially for logicless items. If it is anti-logic environment, I would make many mistakes which causes huge headache.

Numbering in Synology NAS is an issue for me, I got one volume2 but in storage pool 1, the volume1 is in storage pool 2. Normally, my thinking is simple, all packages are installed in volume1 and all iSCSI LUN created in volume1 as well, because I got SSD cache for volume1.

But above configuration confused me when ever received notification, I need to think about which volume got issue because the notification mentioned storage pool instead.

Today, thinking about change storage pool name again, because I know it is a setting hold by Synology, not Linux OS. Then I got answer.

Warning

Luckily I got issue with my DSM6, not DSM7, because they said that this can not be done in DSM7.

Renumber storage pool

Read storage pool number

# synospace --meta -e
[/dev/vg1/volume_1]
---------------------
Descriptions=[]
Reuse Space ID=[]
[/dev/vg1]
---------------------
Descriptions=[]
Reuse Space ID=[reuse_2]

Above result shows device /dev/vg1 is numbered as Storage Pool 2

Set number

To set storage pool number for specific device, use following command

# synospace --meta -s -i reuse_{storage_pool_number} {device_name}

Change volume number

Note: This one, I haven't tested. But if it works, then I might want to try to shink volume next time

Stop services

Stop all docker containers, etc., then stop all services using following command

syno_poweroff_task -d

list LV

lvm lvscan

rename LV

lvm lvrename {VG name} {old LV name} {new LV name}

Reboot

reboot

Shared folders and iSCSI services should be automatically modified and checking all you services are running correctly.

References

Renaming/renumbering storage pools and volumes
Synology Rename Volume and Storage Pool

Unplugged wrong disks in DS2419+

Unplugged wrong disks in DS2419+

Today, made a mistake, unplugged wrong disk in DS2419+, and caused it hang. At that time, I was moving 3 shared folders as well.

After hard reboot, everything back to orginal, I'm quite suprise, this is the second time I unplugged wrong disk in Synology NAS. Quite happy with this product, only one issue for me, they can not handle disk with bad sector well.

Proxmox Virtual Environment

Proxmox Virtual Environment

Proxmox is a KVM hypervisor and Linux Containers (LXC), thinking using it replace TrueNAS. But after research, found that it can not use thin disk, this is a big issue for me to save disk space.

TrueNAS still got some better points compare with Proxmox VE, such as the storage management, TrueNAS ZFS management looks more fesible than Proxmox can do. But Proxmox has some other points, such as support multiple hosts, more complex networking, file based VM image. TrueNAS uses ZFS volume to manage VM image, which creates many snapshots, hope the TrueNAS can have lesser bugs, especially on ZFS snapshots.

In the end, I think I will still use TrueNAs, I need ZFS pool feature to avoid disk issue.

References

Proxmox Virtual Environment

Make keys behave like Windows on MacOS

Make keys behave like Windows on MacOS

I tried, but failed for Control Arrow Keys. Anyway I decided drop this idea, because it is a partial solution, the Control Arrow Keys doesn't work.

Steps

Create a file ~/Library/KeyBindings/DefaultKeyBinding.dict has following contents

{
  "\UF729"  = moveToBeginningOfLine:; // home
  "\UF72B"  = moveToEndOfLine:; // end
  "$\UF729" = moveToBeginningOfLineAndModifySelection:; // shift+home
  "$\UF72B" = moveToEndOfLineAndModifySelection:; // shift+end
  "^\UF729" = moveToBeginningOfDocument:; // ctrl+home
  "^\UF72B" = moveToEndOfDocument:; // ctrl+end
  "^$\UF729" = moveToBeginningOfDocumentAndModifySelection:; // ctrl+shift+home
  "^$\UF72B" = moveToEndOfDocumentAndModifySelection:; // ctrl+shift+end
  "^\UF702" = "moveWordBackward:"; // ctrl+leftarrow
  "^\UF703" = "moveWordForward:"; // ctrl+rightarrow
  "^$\UF702" = "moveWordBackwardAndModifySelection:"; // shift+ctrl+leftarrow
  "^$\UF703" = "moveWordForwardAndModifySelection:"; // shift+ctrl+rightarrow
}

Alternatively, change Line to Paragraph, depending on your prefers.

References

Make Home & End keys behave like Windows on Mac OS X

Server Overlay and Serverless

Server Overlay and Serverless

Can application layer isolated from OS layer?

Overlay

Docker uses overlay system, but it requires docker file to rebulid docker image. My colleague was asking me about the image patching and I told him that upper layer can overwrite the lower layer, there is no way to prevent this.

Layering

If the layering can be done in managed way, then it could be a better option to deploy applications. So the ideal is to separate platform to more layers as below

  • OS layer - Kernal and all OS packages are sitting in this layer
  • OS configuration layer - This layer consists of operating system configurations, such as network configuration, application filesystem configuration, etc.
  • OS to APP Patch layer - Some specific OS requirements for specific application.
  • Middleware layer - This includes middleware packages
  • Data layer - This includes all data required to run application
  • Application layer - This is the actual application

Docker or Containerd

The Docker or Containerd packages can be in OS layer, but the actual configuration should be Middleware layer.

CoreOS

The CoreOS implementation is a good example for this layering.

Sample implementation

solve raspbian SD card corruption issues with read-only mounted root partition

Steps

  • Copy the script in next section to /sbin/overlayRoot.sh and make it executable
sudo chmod +x /sbin/overlayRoot.sh
  • Disable swap:
sudo dphys-swapfile swapoff
sudo dphys-swapfile uninstall
sudo update-rc.d dphys-swapfile remove
  • Add following line to the end of cmdline.txt file in the boot partition:
init=/sbin/overlayRoot.sh
  • reboot

Script

The copy of script is listed below

#!/bin/sh
#  Read-only Root-FS for Raspian using overlayfs
#  Version 1.1
#
#  Version History:
#  1.0: initial release
#  1.1: adopted new fstab style with PARTUUID. the script will now look for a /dev/xyz definiton first 
#       (old raspbian), if that is not found, it will look for a partition with LABEL=rootfs, if that
#       is not found it look for a PARTUUID string in fstab for / and convert that to a device name
#       using the blkid command. 
#
#  Created 2017 by Pascal Suter @ DALCO AG, Switzerland to work on Raspian as custom init script
#  (raspbian does not use an initramfs on boot)
#
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see
#    <http://www.gnu.org/licenses/>.
#
#
#  Tested with Raspbian mini, 2018-10-09
#
#  This script will mount the root filesystem read-only and overlay it with a temporary tempfs 
#  which is read-write mounted. This is done using the overlayFS which is part of the linux kernel 
#  since version 3.18. 
#  when this script is in use, all changes made to anywhere in the root filesystem mount will be lost 
#  upon reboot of the system. The SD card will only be accessed as read-only drive, which significantly
#  helps to prolong its life and prevent filesystem coruption in environments where the system is usually
#  not shut down properly 
#
#  Install: 
#  copy this script to /sbin/overlayRoot.sh, make it executable and add "init=/sbin/overlayRoot.sh" to the 
#  cmdline.txt file in the raspbian image's boot partition. 
#  I strongly recommend to disable swapping before using this. it will work with swap but that just does 
#  not make sens as the swap file will be stored in the tempfs which again resides in the ram.
#  run these commands on the booted raspberry pi BEFORE you set the init=/sbin/overlayRoot.sh boot option:
#  sudo dphys-swapfile swapoff
#  sudo dphys-swapfile uninstall
#  sudo update-rc.d dphys-swapfile remove
#
#  To install software, run upgrades and do other changes to the raspberry setup, simply remove the init= 
#  entry from the cmdline.txt file and reboot, make the changes, add the init= entry and reboot once more. 

fail(){
    echo -e "$1"
    /bin/bash
}

# load module
modprobe overlay
if [ $? -ne 0 ]; then
    fail "ERROR: missing overlay kernel module"
fi
# mount /proc
mount -t proc proc /proc
if [ $? -ne 0 ]; then
    fail "ERROR: could not mount proc"
fi
# create a writable fs to then create our mountpoints 
mount -t tmpfs inittemp /mnt
if [ $? -ne 0 ]; then
    fail "ERROR: could not create a temporary filesystem to mount the base filesystems for overlayfs"
fi
mkdir /mnt/lower
mkdir /mnt/rw
mount -t tmpfs root-rw /mnt/rw
if [ $? -ne 0 ]; then
    fail "ERROR: could not create tempfs for upper filesystem"
fi
mkdir /mnt/rw/upper
mkdir /mnt/rw/work
mkdir /mnt/newroot
# mount root filesystem readonly 
rootDev=`awk '$2 == "/" {print $1}' /etc/fstab`
rootMountOpt=`awk '$2 == "/" {print $4}' /etc/fstab`
rootFsType=`awk '$2 == "/" {print $3}' /etc/fstab`
echo "check if we can locate the root device based on fstab"
blkid $rootDev
if [ $? -gt 0 ]; then
    echo "no success, try if a filesystem with label 'rootfs' is avaialble"
    rootDevFstab=$rootDev
    rootDev=`blkid -L "rootfs"`
    if [ $? -gt 0 ]; then
        echo "no luck either, try to further parse fstab's root device definition"
        echo "try if fstab contains a PARTUUID definition"
        echo "$rootDevFstab" | grep 'PARTUUID=\(.*\)-\([0-9]\{2\}\)'
        if [ $? -gt 0 ]; then 
        fail "could not find a root filesystem device in fstab. Make sure that fstab contains a device definition or a PARTUUID entry for / or that the root filesystem has a label 'rootfs' assigned to it"
        fi
        device=""
        partition=""
        eval `echo "$rootDevFstab" | sed -e 's/PARTUUID=\(.*\)-\([0-9]\{2\}\)/device=\1;partition=\2/'`
        rootDev=`blkid -t "PTUUID=$device" | awk -F : '{print $1}'`p$(($partition))
        blkid $rootDev
        if [ $? -gt 0 ]; then
        fail "The PARTUUID entry in fstab could not be converted into a valid device name. Make sure that fstab contains a device definition or a PARTUUID entry for / or that the root filesystem has a label 'rootfs' assigned to it"
        fi
    fi
fi
mount -t ${rootFsType} -o ${rootMountOpt},ro ${rootDev} /mnt/lower
if [ $? -ne 0 ]; then
    fail "ERROR: could not ro-mount original root partition"
fi
mount -t overlay -o lowerdir=/mnt/lower,upperdir=/mnt/rw/upper,workdir=/mnt/rw/work overlayfs-root /mnt/newroot
if [ $? -ne 0 ]; then
    fail "ERROR: could not mount overlayFS"
fi
# create mountpoints inside the new root filesystem-overlay
mkdir /mnt/newroot/ro
mkdir /mnt/newroot/rw
# remove root mount from fstab (this is already a non-permanent modification)
grep -v "$rootDev" /mnt/lower/etc/fstab > /mnt/newroot/etc/fstab
echo "#the original root mount has been removed by overlayRoot.sh" >> /mnt/newroot/etc/fstab
echo "#this is only a temporary modification, the original fstab" >> /mnt/newroot/etc/fstab
echo "#stored on the disk can be found in /ro/etc/fstab" >> /mnt/newroot/etc/fstab
# change to the new overlay root
cd /mnt/newroot
pivot_root . mnt
exec chroot . sh -c "$(cat <<END
# move ro and rw mounts to the new root
mount --move /mnt/mnt/lower/ /ro
if [ $? -ne 0 ]; then
    echo "ERROR: could not move ro-root into newroot"
    /bin/bash
fi
mount --move /mnt/mnt/rw /rw
if [ $? -ne 0 ]; then
    echo "ERROR: could not move tempfs rw mount into newroot"
    /bin/bash
fi
# unmount unneeded mounts so we can unmout the old readonly root
umount /mnt/mnt
umount /mnt/proc
umount /mnt/dev
umount /mnt
# continue with regular init
exec /sbin/init
END
)"

Thinking about the future of Chef

Thinking about the future of Chef

DevOps tools

These few days, I was thinking about how to manage my servers. Thinking about any DevOps tools to be used.

Looking for Ansible, the center management tool, which is called Ansible Tower, offers free for handling up to 10 nodes...

Looking for Chef, free for 25 nodes? That was 2014. Then now, free for 5 nodes...

Looking for Puppet, I bad experience in the past due to it's OS support, and I'm a scripter, perfer Chef's imperative language, not Puppet's declarative language.

Serverless

Chef people mentioned the word Serverless couple of years back, read some on-line documents, didn't understand how Chef goes serverless...

Today, After read another document, understand the real serverless meaning. It means Stateless for all servers, such as Core OS, no Chef required. True?

Ruby

Is Ruby hard to learn? I really don't feel it, and I think it is easy comparing with other OO Languages. But some people from DevOps team told me Ansible is easy, Ruby is hard. Hmmm...

Ruby is dying, maybe, it is not an OS default language, will not be the choice for sysadm.

JavaScript and Python

Running some servers using NodeJS, it solved some issues, but not a well structured programming language. Easy to start, hard to master.

Python, learnt and coded AI program, felt messy. Maybe I'm wrong.

A nature language is easy to start but hard to master, will this be the future of programming language as well? Or, nothing to master, just tell enough...

References

Who killed the Chef? The case against Opscode Chef in 2020
Introduction to is Ansible free?
Chef Enterprise Now Free Up to 25 Nodes
Open Source Chef vs Hosted Chef vs. On Premises Chef
Chef vs. Puppet: Methodologies, Concepts, and Support

Upgrade Synology DS1812+ Memory

Upgrade Synology DS1812+ Memory

As the Synology DS1812+ NAS officially only supports 3GB RAM, I used 3GB RAM NAS for many years.

Recently, I got one 1Rx8 4GB DDR3 RAM, wanted to try to see whether DS1812+ can use it.

After installed, luckily it is working. Plus 1GB on board memory, it has about 5GB memory now.

root@ds1812:~# free
              total        used        free      shared  buff/cache   available
Mem:        5072432      901144      323456       15908     3847832     3761546
Swap:       5140404      460920     4679484
root@ds1812:~# cat /proc/meminfo 
MemTotal:        5072432 kB
MemFree:          890332 kB
Buffers:            6104 kB
Cached:          3018256 kB
SwapCached:        29084 kB
Active:           662768 kB
Inactive:        2548468 kB
Active(anon):      94080 kB
Inactive(anon):   108664 kB
Active(file):     568688 kB
Inactive(file):  2439804 kB
Unevictable:        5804 kB
Mlocked:            5804 kB
SwapTotal:       5140404 kB
SwapFree:        4675032 kB
Dirty:             18444 kB
Writeback:          3860 kB
AnonPages:        188544 kB
Mapped:            76504 kB
Shmem:             15376 kB
Slab:             261456 kB
SReclaimable:      63788 kB
SUnreclaim:       197668 kB
KernelStack:       14400 kB
PageTables:        69604 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:     7676620 kB
Committed_AS:    4152632 kB
VmallocTotal:   34359738367 kB
VmallocUsed:      478460 kB
VmallocChunk:   34359221580 kB
DirectMap4k:       16876 kB
DirectMap2M:     5214208 kB
root@ds1812:~#