T2SDE - hpaluch/hpaluch.github.io GitHub Wiki

T2 SDE Linux

By chance - finding YT video about Wayland issues with VirGL TESTED: Qemu VirGL - what could possibly go wrong? OpenSource Mesa 3D I found "T2 SDE" Linux (which means "T2 System Development Environment".

Personally I see it as something between Arch (binary packages) and Gentoo (build from source) and Buildroot (custom build system based on Bash). There are some unique features (cross-building on other system etc...)

Homepage: https://t2sde.org/ - please read T2 description there.

What I like on T2 SDE:

NOTE: T2 is based on Rock Linux (original web https://www.rocklinux.net/) - it is reason why you can find "rocknet" and other scripts with "rock" in name (and reason why package manager is called "stone"). I strongly suggest to download old handbook from: http://dl.exactcode.de/t2-handbook/ps%2Bpdf/t2-handbook.pdf where you can find for example Network configuration (see real page 49, internal number 37) - these sections are also in latest T2 Handbook, but somehow old versions is easer to read for me.

Download:

  • go to: https://dl.t2sde.org/binary/2025/

  • in my case I downloaded:

    curl -fLO https://dl.t2sde.org/binary/2025/t2-25.1-x86-64-base-wayland-glibc-gcc-nocona.sha256
    curl -fLO https://dl.t2sde.org/binary/2025/t2-25.1-x86-64-base-wayland-glibc-gcc-nocona.iso
    sha256sum -c t2-25.1-x86-64-base-wayland-glibc-gcc-nocona.sha256
    

Installation:

Handling i386-ieee1275 error

If you have above old medium you will encounter following error when installing GRUB in BIOS mode:

grub2-install: error: /usr/lib64/grub/i386-ieee1275/modinfo.sh doesn't exist. Please specify --target or --directory.

There are 2 ways how to fix it:

Option A (short):

  • once error message appears, use Alt-F2 to switch to free console (it has advantage that while installation program is running there is mounted target under /mnt with required /mnt{/dev,/proc,/sys} filesystem
  • and run this command:
    chroot /mnt /usr/sbin/grub2-install --target i386-pc /dev/vda
    

Option B - rebuild and reinstall fixed grub:

  • GRUB was fixed in r73844, also in git: https://github.com/rxrbln/t2sde/commit/64af6b8a18f817d087c43a902ac1a6ea2adfa0b3
  • once error message appears, use Alt-F2 to switch to free console
    chroot /mnt
    PS1="(chroot) $PS1"
    dhclient eth0  # setup network
    # checkout/updated to latest repo
    cd /usr/src/t2-src
    svn up
    svn diff -c r73844 # verify that GRUB fix is present
    t2 config # just Exit - required to create config/default/ files
    # we have to use "install -force" to also build new deps
    t2 install -force grub2
    # Ooops error:
    # less /var/adm/logs/9-grub2.err
    # ...../wrapper/x86_64-t2-linux-gnu-strip: line 9: exec: x86_64-t2-linux-gnu-strip: not found
    # workaround:
    ( cd /usr/bin &&	ln -s strip x86_64-t2-linux-gnu-strip )
    t2 build grub2 # now build will also install
    ls -l /usr/sbin/grub2-install  # check date - must be today
    # fixed: command below should finish without error
    /usr/sbin/grub2-install /dev/vda
    

NOTE: Installer will offer reboot using kexec (Kernel Exec) mechanism to installed system, however kexec was never designed for that (kexec purpose is to on main kernel crash just boot another "safe" kernel to dump crashed kernel and halt). So I recommend to answer "No" and reboot via shutdown -r or reboot or halt system with poweroff.

Example creating user user:

useradd -m -G wheel,kvm,video,audio -s /bin/bash user
passwd user

Building and installing additional packages

  • NOTE: I use latest packages from source - for experienced users only!
  • example (SVN URLs are from page https://t2sde.org/download/continue.html):
  • please see also: https://t2sde.org/kb/8/
  • WARNING! It is time consuming because I update repo to latest trunk
  • note: default config is in /etc/SDE-CONFIG/config you can use also t2 config to edit it with GUI
# run all commands as root
# seed prepared repo - this make also keep system wide link "t2" functional:
cd /usr/src/t2-src
svn up
# Upgrade strongly recommended otherwise there could be toolchain inconsistency after repo update to trunk(!):
# To just quickly install few packages you can sometimes skip command below:
t2 upgrade
# this will take lot of time and disk space!

# eample to install btop package:
./t2 find btop
./t2 inst btop
# finally try to run 'btop' command...

If you selected 'Full installyou can also run sway (your user must be in groupvideoto proceed). Just typesway`. Most important commands:

  • Win+ENTER - runs terminal
  • Win+NUMBER - switch (or create and switch) to workspace NUMBER
  • Win+Arrows - focus to other Window in arrow direction
  • Win+S Win+W Win+E - will switch differnet Windows layouts
  • Win+Shift+E - Exit (must confirm Yellow mesage at the top to exit)

Upgrade T2 Linux to latest development version

Here is how I'm performing upgrade, in my case:

  • installed version: 25.1 from t2-25.1-x86-64-base-wayland-glibc-gcc-nocona.iso (default install - desktop)
  • wanted upgrade to latest SVN revision: 74596 (Tue, 04 Mar 2025)

I did as root:

( . /etc/SDE-CONFIG/config && echo $SDECFG_PKGSEL_TMPL )
# => base-wayland   # template used for install, but do NOT use for build

( . /etc/os-release && echo $VERSION )
# => 25.1 (2025-02-02)

cd /usr/src/t2-src
t2 up
svn info | grep Revision:
# => Revision: 74596

# creates config files:
t2 config # ensure that Target Distribution stays "(none)" and exit
# WARNING! Selecting any other Template will mask many packages required for proper builds!

# jinja2: required by udev
t2 install perl perl-xml-parser python python-installer setuptools pip jinja2 ninja meson libtool libxml autoconf
# above command should finish without error
ls -lrt /var/adm/logs/ # there should be no .err files

#
# !!! Please backup your system now !!!
#

# command below will take lot of time!
# run from local console or using tmux
t2 upgrade # listed 66 packages
# on VM with: 8 cores, 16GB RAM, 48GB BTRFS on NVMe: build took 1h and 45minutes

# there were 26 broken packages
ls -lrt /var/adm/logs/*.err
  -rw-r--r-- 1 root root   598 Mar  4 16:35 /var/adm/logs/9-rsync.err
  -rw-r--r-- 1 root root 17937 Mar  4 16:43 /var/adm/logs/9-rustc.err
  -rw-r--r-- 1 root root  4195 Mar  4 16:47 /var/adm/logs/9-mesa.err
  -rw-r--r-- 1 root root 21049 Mar  4 17:00 /var/adm/logs/9-thunderbird.err
  -rw-r--r-- 1 root root 22021 Mar  4 17:01 /var/adm/logs/9-firefox.err
  -rw-r--r-- 1 root root 12656 Mar  4 17:01 /var/adm/logs/9-vte.err
  -rw-r--r-- 1 root root 18842 Mar  4 17:03 /var/adm/logs/9-xfsprogs.err
  -rw-r--r-- 1 root root 18333 Mar  4 17:05 /var/adm/logs/9-libxfce4windowing.err
  -rw-r--r-- 1 root root 16687 Mar  4 17:05 /var/adm/logs/9-xfce4-panel.err
  -rw-r--r-- 1 root root  1824 Mar  4 17:06 /var/adm/logs/9-qemu.err
  -rw-r--r-- 1 root root  9921 Mar  4 17:07 /var/adm/logs/9-libreoffice.err
# let's find what'is missing:
t2 install rsync
# problem with download - corrupted file:
file download/mirror/r/rsync-3.4.1.tar.gz.extck-err
# => download/mirror/r/rsync-3.4.1.tar.gz.extck-err: data
# should return gzip
# fixed with: found link on: https://www.linuxfromscratch.org/blfs/view/svn/basicnet/rsync.html
curl -fLo download/mirror/r/rsync-3.4.1.tar.gz  https://www.samba.org/ftp/rsync/src/rsync-3.4.1.tar.gz
file download/mirror/r/rsync-3.4.1.tar.gz
rm download/mirror/r/rsync-3.4.1.tar.gz.extck-err
# again try build it:
t2 install rsync
# ok
# next one:
less /var/adm/logs/9-rustc.err
# error[E0463]: can't find crate for `core`
# Huh, this does nealry the trick
mine -r rustc # removes /opt/rust, forces downloading it
t2 install rustc
# Notice important message that fixes above bug:
# =>  No compatible rustc, Rust will download binaries to bootstrap
# Hmm now some symbol errors:
#  = note: some arguments are omitted. use `--verbose` to show all linker arguments
#  = note: /usr/lib64/gcc/x86_64-t2-linux-gnu/14.2.0/../../../../x86_64-t2-linux-gnu/bin/ld: /usr/src/t2-src/src.rustc.250304.182136.25251/rustc-1.85.0-src/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-t2-linux-gnu/release/deps/librustc_driver-58d7a7d82b3d1507.so: undefined reference to `crc32'
#          /usr/lib64/gcc/x86_64-t2-linux-gnu/14.2.0/../../../../x86_64-t2-linux-gnu/bin/ld: /usr/src/t2-src/src.rustc.250304.182136.25251/rustc-1.85.0-src/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-t2-linux-gnu/release/deps/librustc_driver-58d7a7d82b3d1507.so: undefined reference to `compressBound'
#          /usr/lib64/gcc/x86_64-t2-linux-gnu/14.2.0/../../../../x86_64-t2-linux-gnu/bin/ld: /usr/src/t2-src/src.rustc.250304.182136.25251/rustc-1.85.0-src/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-t2-linux-gnu/release/deps/librustc_driver-58d7a7d82b3d1507.so: undefined reference to `compress2'
#          /usr/lib64/gcc/x86_64-t2-linux-gnu/14.2.0/../../../../x86_64-t2-linux-gnu/bin/ld: /usr/src/t2-src/src.rustc.250304.182136.25251/rustc-1.85.0-src/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-t2-linux-gnu/release/deps/librustc_driver-58d7a7d82b3d1507.so: undefined reference to `uncompress'
# trying:

What is wrong:

readelf -d /usr/src/t2-src/src.rustc.250307.074659.19382/rustc-1.85.0-src/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-t2-linux-gnu/release/deps/librustc_driver-21c1949fb3d9c236.so | fgrep NEEDED

 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [ld-linux-x86-64.so.2]

Problem: librustc_driver is clearly missing dependency on libz

Fix here: https://github.com/rxrbln/t2sde/commit/f7723465adb44e43e6e8e8c4ff45a227abd3171e

--- /dev/null
+++ b/package/rust/rustc/rustdriver-libz-fix.patch
@@ -0,0 +1,6 @@
+--- rustc-1.85.0-src/compiler/rustc_driver_impl/build.rs.orig  2025-03-07 08:23:55.930000000 +0100
++++ rustc-1.85.0-src/compiler/rustc_driver_impl/build.rs       2025-03-07 08:22:18.863368826 +0100
+@@ -0,0 +1,3 @@
++fn main() {
++    println!("cargo:rustc-link-lib=dylib=z");
++}

Rust error fixed with: https://github.com/rxrbln/t2sde/pull/211

Continuing:

t2 upgrade
# on mesa:
# meson.build:813:20: ERROR: Program 'bindgen' not found or not executable
t2 install mesa  # install will trigger installing deps
t2 upgrade
# goes well until thunderbird...
t2 install thunderbird

# we have to enable introspection and rebuild all packages
# that wil generate .gir files, following https://t2sde.org/kb/8/
t2 install -f gobject-introspection glib gdk-pixbuf pango harfbuzz at-spi2-core graphene gtk
# new addition:
t2 install -f libxfce4util
t2 upgrade

# corrupted icu4c mirror:
curl -fLo download/mirror/i/icu4c-75_1-data.zip https://github.com/unicode-org/icu/releases/download/release-75-1/icu4c-75_1-data.zip
file download/mirror/i/icu4c-75_1-data.zip
rm -f download/mirror/i/icu4c-75_1-data.zip.extck-err
# force installation of build deps:
t2 install libreoffice

New gtk-update-icon-cache conflict:

There is rename hook in package/gnome/gtk+/gtk+.conf

var_append INSTALL_WRAPPER_FILTER '|' \
        'sed s/gtk-update-icon-cache/gtk3-update-icon-cache/'

But it seems to not work for meson builds. So trying this patch package/gnome/gtk+/fix-icon-cache-conflict.patch:

--- gtk-3.24.49/gtk/meson.build.vanilla	2025-03-09 18:08:57.589000000 +0100
+++ gtk-3.24.49/gtk/meson.build	2025-03-09 18:09:15.729431152 +0100
@@ -1138,7 +1138,7 @@
 endif
 
 gtk_update_icon_cache = executable(
-  'gtk-update-icon-cache',
+  'gtk3-update-icon-cache',
   'updateiconcache.c',
   extra_update_icon_cache_objs,
   c_args: gtk_cargs,

And then:

mine -r gtk+ gtk+2
t2 install -f gtk+
t2 install -f gtk+2

On one computer building linux will fail because pahole will not find shared libraries. There is bug in package dwarves that installs shared libraries into /usr/usr/lib64 - notice 2 times /usr.

  • as quick and dirty workaround I copied shared libraries to correct directory /usr/lib64

Package tips

Some tips:

# restore /opt/rust that I removed
mine -i PATH_TO_ISO/25.1-generic-x86-64-nocona-cross-linux/pkgs/rustc-1.84.0.tar.zst

$ /opt/rust/bin/rustc --print target-list | fgrep t2

x86_64-t2-linux-gnu

$ /opt/rust/bin/rustc --print target-libdir

/opt/rust/lib64/rustlib/x86_64-t2-linux-gnu/lib

cd /usr/src/t2-src/src.rustc.250305.180720.14475
./debug.sh
cd rustc-1.85.0-src/
./x.py build -v
# ignoring fingerprint - no such file or directory errors - warnings

Managing binary packages

You can use mine command.

To query installed packages:

mine -q

To remove package bluez (no confirmation!):

mine -r bluez

To install package bluez:

  • mount installation CD/DVD using mount -r /dev/cdrom /mnt
  • and try:
    mine -i /mnt/25.1-generic-x86-64-nocona-cross-linux/pkgs/bluez-5.79.tar.zst
    
  • to query package bluez:
    $ mine -q bluez
    
    bluez 5.79 25.1
    

Notes

Non-privileged user does not see processes of other users - so you have to run top or btop as root to see all processes.

Editing run-levels: example for acpid service:

# run as root:
stone runlevel edit_srv acpid

Installing on BTRFS sub-volume

Defult installer handles propelry only BTRFS root target, but not subvolume (I use one big BTRFS partition where each OS is installed into subvolume - in my example T2 Linux is installed into T2-ROOT subvolume).

First you need to properly create and remount BTRFS before install (use shell on other terminal of installation CD):

mkfs.btrfs /dev/vdaX
mount /dev/vdaX /mnt
cd /mnt
btrfs su cr T2-ROOT
cd /
umount /mnt
mount -o subvol=T2-ROOT /dev/vdaX /mnt

Now run install and simply skip fdisk part (it will detect that /mnt is mounted and will proceed with installation).

At grub stage you have to use above workaround to install it:

chroot /mnt /usr/sbin/grub2-install --target i386-pc /dev/vda

After reboot, initrd will drop into shell, because it will mount Top of BTRFS (not subvolume). To continue boot you need to this in initrd shell:

umount /mnt
mount -o subvol=T2-ROOT -t btrfs /dev/vdaX /mnt
mount -t none -o move {,/mnt}/dev
mount -t none -o move {,/mnt}/sys
mount -t none -o move {,/mnt}/proc
exec switch_root /mnt /sbin/init

System should continue boot - but we need to fix ramdisk and grub config: To fix ramdisk do this:

Installing on BTRFS sub-volume: fix variant A

We can now (since 2024-02-26) use latest SVN repository with enhancement - support for rootflags= parameter:

cd /root
svn co https://svn.exactcode.de/t2/trunk t2-trunk
cd t2-trunk/
svn diff -c r74424 # show fix
./t2 install -force mkinitrd
./t2 install ipconfig # Oops! missing required dependency
/sbin/mkinitrd

Example /boot/grub/grub.cfg entry:

# ... grub header omitted ...
menuentry "T2/Linux" {
	linux /T2-ROOT/boot/vmlinuz root=/dev/disk/by-uuid/KEEP_YOUR_ORIGINAL_DISK_UUID ro rootflags=subvol=T2-ROOT
	initrd /T2-ROOT/boot/initrd
}

Installing on BTRFS sub-volume: fix variant B

Deprecated - without checkout of SVN repo:

  • unpack ramdisk:
    cd /root
    mkdir u
    cd u
    zstdcat /boot/initrd | cpio -ivm
    
  • now apply this patch to /root/u/init:
--- init.orig	2025-02-26 16:38:07.259999994 +0100
+++ init	2025-02-26 17:32:55.000459997 +0100
@@ -48,6 +48,7 @@
 
 # get the root device, init, early swap
 [ -e /proc/cmdline ] && cmdline="$(< /proc/cmdline)"
+rootflags="rootflags= $cmdline" rootflags=${rootflags##*rootflags=} rootflags=${rootflags%% *}
 root="root= $cmdline" root=${root##*root=} root=${root%% *}
 init="init= $cmdline" init=${init##*init=} init=${init%% *}
 swap="swap= $cmdline" swap=${swap##*swap=} swap=${swap%% *}
@@ -62,6 +63,8 @@
     esac
 done
 
+[ -n "$rootflags" ] && mountopt="$rootflags"
+
 # diskless network root?
 addr="${root%:*}"
 if [ "$addr" != "$root" -o "${addr%%,*}" = "/dev/nfs" ]; then

Basically we will allow passing rootflags as mount options.

Now create new ramdisk:

cd /root/u
find . | cpio -ov -H crc > ../initrd2
cd ..
zstdmt initrd2
cp initrd2.zst /boot

Finally you have to edit your /boot/grub/grub.cfg and in menuentry add subvolume name (in my case T2-ROOT) in 3 places:

# ... grub header omitted ...
menuentry "T2/Linux" {
	linux /T2-ROOT/boot/vmlinuz root=/dev/disk/by-uuid/KEEP_YOUR_ORIGINAL_DISK_UUID ro rootflags=subvol=T2-ROOT
	initrd /T2-ROOT/boot/initrd2.zst
}

Notice that I used temporarily different path to initrd (ending with initrd2.zst).

Finally reboot - it should work.

NCDU issues

[!WARNING] Work in progress (some build errors are still unresolved

[!INFO] Last minute note: found original source with Zig 0.14 fixes:

NCDU is handy full-screen disk usage utility. But it is not easy to build:

t2 inst zig
t2 inst ncdu # errors

Error is (from /var/adm/logs/9-ncdu.err):

/usr/src/t2-src/src.ncdu.250302.093025.5394/ncdu-2.0.1/build.zig:6:21: error: root source file struct 'std' has no member named 'build'
/usr/lib/zig/std/std.zig:1:1: note: struct declared here
Due to previous errors, no 9-ncdu.log file!

Trying:

t2 update ncdu 2.7
t2 build ncdu

Hmm:

src/main.zig:66:5: error: invalid builtin function: '@setCold'
src/ui.zig:40:5: error: invalid builtin function: '@setCold'
src/bin_reader.zig:66:5: error: invalid builtin function: '@setCold'
src/json_export.zig:76:9: error: invalid builtin function: '@setCold'
src/json_import.zig:86:9: error: invalid builtin function: '@setCold'
src/json_import.zig:136:9: error: invalid builtin function: '@setCold'
src/bin_export.zig:121:9: error: invalid builtin function: '@setCold'

Trying:

cd src.ncdu.250302.094804.13662/ncdu-2.7/
sed -e '/@setCold/d'

for i in `fgrep -rl '@setCold' src/`;do sed -i -e '/@setCold/d' $i;done
make

Another error:

/usr/lib/zig/std/atomic.zig:13:27: error: @fence is deprecated, use other atomics to establish ordering
        pub const fence = @compileError("@fence is deprecated, use other atomics to establish ordering");
                          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/bin_export.zig:54:50: error: no field named 'Enum' in union 'builtin.Type'
const MAX_ITEM_LEN = 2 + 11 * @typeInfo(ItemKey).Enum.fields.len;

Another hellish inovation:

( cd /usr/src && svn co https://svn.exactcode.de/t2/trunk t2-cleanest )

next fix:

Another innovation:

Or here:

Creating install ISO

[!WARNING] Work in progress - finally I resolved weird 0-glibc issue (forget to install python and other mandatory packages to Host system).

I plan to create minimal version of installation ISO from latest SVN source.

First testing same version as installed system (25.1):

svn list https://svn.exactcode.de/t2/tags/
cat /etc/os-release  # 25.1 in my case
cd /usr/src
svn co https://svn.exactcode.de/t2/tags/25.1 t2-src-25-1
cd t2-src-25-1
rm -rf build/
# WARNING! Do not mess up Host's "default" config - we will create new one called "isomin"
./t2 config -cfg isomin
# just changed: "base" -> "Base package selection" and "Print Build-Output to terminal while building"

# preview list of  required packages:
grep '^X' config/isomin/packages
# only then we may call:
./t2 build-target -cfg isomin
./t2 create-iso isomin

Random tips

Coloured diff in SVN

Vertical system dock

If you look on older video there is fancy vertical dock with CPU disk network and other statistics. It is called "gkrellm", homepage on http://www.muhri.net/gkrellm/

To build it under T2 (using t2 install gkrellm) there are following problems:

  1. URL not found, resolved with:
    curl -flo download/mirror/g/gkrellm-2.3.4.tar.bz2 \
       http://ftp.iij.ad.jp/pub/linux/momonga/7/Everything/source/SOURCES/gkrellm-2.3.4.tar.bz2
    
  2. Build error:
    /usr/lib64/gcc/x86_64-t2-linux-gnu/14.2.0/../../../../x86_64-t2-linux-gnu/bin/ld: plugins.o: undefined reference to symbol 'g_module_close'
    

All issues resolved here:

Resources

My GitHub projects related to T2SDE Linux