A rapid way to erase multiple partition tables on Ubuntu/Debian Linux

When doing labs / playing with ZFS on Linux, ZFS pool may creates a few partitions on each drive, we may want to erase all the playground partition table to start from scratch again(though it may not be required), if we have many drives like more than 10, and we want to erase them all, it’ll take a while to finish the job.

Here is a rapid method to do it, using the non-interactive command sgdisk from package gdisk – the GPT fdisk text-mode partitioning tool, with parameter -Z or -o (both work in my case):

$ sudo sgdisk -Z /dev/sda
GPT data structures destroyed! You may now partition the disk using fdisk or other utilities.
$ sudo sgdisk -o /dev/sdb
The operation has completed successfully.

According to the help message, by specifing parameters -Z, it’ll zap (destroy) the GPT and MBR data structures and exit, and by specifing parameters -o, it’ll clear out all partition data. This includes GPT header data, all partition definitions, and the protective MBR.

Because the command sgdisk is non-interactive, so we can simply integrate the whole massive partition clean up job with shell scripts, for example:

#!/bin/bash
sudo sgdisk -Z /dev/sda &
sudo sgdisk -Z /dev/sdb &
sudo sgdisk -Z /dev/sdc &
sudo sgdisk -Z /dev/sdd &
sudo sgdisk -Z /dev/sde &
sudo sgdisk -Z /dev/sdf &
sudo sgdisk -Z /dev/sdg &

That’s it! Happy hacking!

ZFS on Ubuntu 18.04 基本設定/初始化

Ubuntu 在 15.10 開始測試 ZFS16.04 LTS 的時候正式加入了 ZFS 的支援,背後用的是 ZFS On Linux 的實做,這邊筆記一下已經使用在 Ubuntu 18.04 上了好一陣子的 ZFS 初始化過程

先安裝所需要的套件:

$ sudo apt install zfsutils-linux -y

接著建立 ZFS Pool

接著會使用到 zpool 這個指令,相關的操作都需要要有 root 權限,我這邊是要直接拿完整的整顆硬碟來用,不另外做分割,測試的時候方便起見可以直接用 /dev/sda /dev/sdb 這樣的路徑,所以一路從 sda 用到 sdz,名稱取叫 pool-ftp ,做 raidz3 讓這組 pool 一次最多可以掉三顆硬碟不掉資料,不怕掉資料可以不加這個設定、效果會等同 RAID0 ,硬碟數量如果沒這麼多但想要有個保險也可以用 raidz 或 raidz2 就好,分別為容許一顆和兩顆的硬碟失效,要 RAID1 的效果可以用 mirror 這個選項:

$ sudo zpool create pool-ftp raidz3 /dev/sda /dev/sdd /dev/sde /dev/sdf /dev/sdg /dev/sdh /dev/sdi /dev/sdj /dev/sdk /dev/sdl /dev/sdm /dev/sdn /dev/sdo /dev/sdp /dev/sdq /dev/sdr /dev/sds /dev/sdt /dev/sdu /dev/sdv /dev/sdw /dev/sdx /dev/sdy /dev/sdz

不過正式環境還是建議不要使用 sda / sdb 而是使用 Disk ID / Label / UUID 的方式來認硬碟,就不用擔心未來順序可能改變或亂掉的問題,如果是整批相同型號的硬碟要做處理,透過 Disk ID 其實也很方便,例如:

$ command ls /dev/disk/by-id/ata-ST8000NM0055* | xargs sudo zpool create ftp-pool

如果過程中出現了這樣的訊息,在確認硬碟上沒有其他資料的情況下可以加 -f 的參數:

/dev/sdz does not contain an EFI label but it may contain partition information in the MBR.
閱讀全文

tmux: open terminal failed: missing or unsuitable terminal: xterm-256color

Trying to upgrade my Pi-hole host from Raspbian Stretch to Buster, during the upgrade process, I detached the tmux session and left for a while, when I came back, I can’t create or attach my tmux session anymore, got error message as below:

pi@pi-hole ~ $ tmux a
open terminal failed: missing or unsuitable terminal: xterm-256color

pi@pi-hole ~ $ tmux
open terminal failed: missing or unsuitable terminal: xterm-256color

Workaround:

export TERM=xterm

This will make tmux work again.

Some instructions will tell you to kill the tmux server and start a new one:

tmux kill-server

This will lose the current session which is not preferred, especially during the system upgrade process.

Geekbench benchmark of different AWS EC2 instances

接續上一篇 sysbench CPU benchmark of different AWS EC2 instances ,這邊改用 Geekbench 來做效能測試,Geekbench 是跨平台的效能測試工具,有支援 Windows、Linux、macOS、Android 和 iOS 等系統,測試環境、比較對象和上一篇相同。

測試環境

  • Ubuntu: 18.04.3 LTS
  • Linux kernel: 4.15.0-1052-aws
  • Geekbenck: 5.0.3

比較對象

  • General purpose
    • T2
    • T3
    • T3a
    • M4
    • M5
    • M5a
  • Compute optimized
    • C4
    • C5
  • Memory optimized
    • R4
    • R5
    • R5a

T 系列的機器也都同樣是開 Unlimited Mode 下去跑測試讓 CPU 可以全速運轉

執行時不用特別帶參數,像下面這樣

測試畫面

$ ./Geekbench-5.0.3-Linux/geekbench5 
Geekbench 5.0.3 Tryout : https://www.geekbench.com/

Geekbench 5 is in tryout mode.

Geekbench 5 requires an active Internet connection when in tryout mode, and 
automatically uploads test results to the Geekbench Browser. Other features 
are unavailable in tryout mode.

Buy a Geekbench 5 license to enable offline use and remove the limitations of 
tryout mode.

If you would like to purchase Geekbench you can do so online:

  https://store.primatelabs.com/v5

If you have already purchased Geekbench, enter your email address and license 
key from your email receipt with the following command line:

  ./Geekbench-5.0.3-Linux/geekbench5 -r <email address> <license key>

  Running Gathering system information
System Information
  Operating System              Ubuntu 18.04.3 LTS 4.15.0-1052-aws x86_64
  Model                         Amazon EC2 t3a.large
  Motherboard                   Amazon EC2
  BIOS                          Amazon EC2 1.0

Processor Information
  Name                          Intel Pentium II/III
  Topology                      1 Processor, 1 Core, 2 Threads
  Identifier                    AuthenticAMD Family 23 Model 1 Stepping 2
  Base Frequency                2.20 GHz
  L1 Instruction Cache          64.0 KB
  L1 Data Cache                 32.0 KB
  L2 Cache                      512 KB
  L3 Cache                      64.0 MB

Memory Information
  Size                          7.71 GB

Single-Core
  Running AES-XTS
  Running Text Compression
  Running Image Compression
  Running Navigation
  Running HTML5
  Running SQLite
  Running PDF Rendering
  Running Text Rendering
  Running Clang
  Running Camera
  Running N-Body Physics
  Running Rigid Body Physics
  Running Gaussian Blur
  Running Face Detection
  Running Horizon Detection
  Running Image Inpainting
  Running HDR
  Running Ray Tracing
  Running Structure from Motion
  Running Speech Recognition
  Running Machine Learning

Multi-Core
  Running AES-XTS
  Running Text Compression
  Running Image Compression
  Running Navigation
  Running HTML5
  Running SQLite
  Running PDF Rendering
  Running Text Rendering
  Running Clang
  Running Camera
  Running N-Body Physics
  Running Rigid Body Physics
  Running Gaussian Blur
  Running Face Detection
  Running Horizon Detection
  Running Image Inpainting
  Running HDR
  Running Ray Tracing
  Running Structure from Motion
  Running Speech Recognition
  Running Machine Learning

Uploading results to the Geekbench Browser. This could take a minute or two 
depending on the speed of your internet connection.

Upload succeeded. Visit the following link and view your results online:

  https://browser.geekbench.com/v5/cpu/535166

Visit the following link and add this result to your profile:

  https://browser.geekbench.com/v5/cpu/535166/claim?key=185887

測試結果

接著看測試結果,免費版的 Geekbench 測試時必須要有網路連線,結果不會直接顯示在本機,要上傳到他們的伺服器上看,好處應該是比較不怕造假(假設有對資料做應該有的基本驗證機制)或弄錯,畫面呈現如下,除了效能測試的分數以外,也一些作業系統、CPU、記憶體等資訊:

下面是這次測試全部結果的連結:

閱讀全文