Red Flag Linux Tutorials

Учебники по Red Flag Linux

红旗 Linux 安装教程

Versions: 2.0, 3.0, Apple TV

Overview

Red Flag Linux is a Linux distribution developed by Red Flag Software. It was heavily promoted by the Chinese government as a replacement for foreign operating systems to ensure national information security.

This documentation portal serves as an archival tutorial hub for installing early, historically significant versions of the OS, specifically the rare 2.0 and 3.0 releases from the early 2000s, as well as experimental ports to non-standard hardware like the Apple TV.

Use the navigation tabs above to read specific installation instructions and technical details for each release.

Video Showcase

Note: This video features a full English dub! You can switch the audio track in the YouTube player settings.

Disclaimer
The author of this portal ('errordan') does not own the rights to Red Flag OS, associated software, or distribution materials. This project is created strictly for historical archival and educational purposes. The author bears no responsibility for any potential damage, data loss, or issues arising from the use of these materials.

Note: Due to the extreme age of these systems, the provided tutorials may not work perfectly in all cases. If you encounter issues, you can contact errordan for help or search for solutions independently.
About the development of this project...
Please note that Artificial Intelligence was used during the development of this project. Complex tasks such as reverse engineering the legacy kernels, patching Mach-O headers, and working with raw hex code were beyond the author's technical capabilities and were accomplished with the help of AI.

Version 2.0 (2000) Installation

Red Flag OS 2.0 is a very old (2001) Chinese Linux distribution based on kernel 2.2. It cannot be run "out of the box" on modern emulators due to incompatibilities between the old kernel and modern virtual devices.

Red Flag OS 2.0 Screenshot
Important Notice
This guide is verified and works ONLY under Linux (tested on Ubuntu). Using QEMU on Windows for old OSes often leads to critical errors.

1. Preparation and Installation

First, create a 6GB virtual hard drive:

qemu-img create -f qcow2 redflag2_hdd.qcow2 6G

Start the installation from the CD-ROM. You must use the Cirrus video card (-vga cirrus), as the standard QEMU video adapter will cause the XFree86 installer to crash:

qemu-system-x86_64 -m 256 -cdrom redflag2.0.iso -hda redflag2_hdd.qcow2 -boot d -vga cirrus

Proceed with the standard installation process.

2. Fixing Fatal Post-Installation Errors

If you simply try to boot the installed system, you will encounter multiple issues:

  • Freezing at Partition check: hda: lost interrupt (kernel loses interrupts because DMA is too fast).
  • Kernel panic: requires TSC (the old kernel does not understand QEMU default CPU).
  • The GUI will "spin" and crash due to a conflict between old acceleration and QEMU.

To fix this, you need to mount the virtual disk to your host system (Linux) and make edits:

# 1. Mount the disk
sudo modprobe nbd max_part=8
sudo qemu-nbd -c /dev/nbd0 redflag2_hdd.qcow2
sudo mkdir -p /mnt/redflag2
sudo mount /dev/nbd0p1 /mnt/redflag2

# 2. Install extlinux bootloader (replaces broken LILO)
sudo apt-get install -y extlinux syslinux-common
sudo extlinux --install /mnt/redflag2/boot
sudo bash -c 'dd if=/usr/lib/syslinux/mbr/mbr.bin of=/dev/nbd0 bs=440 count=1 conv=notrunc'

# 3. Create a proper bootloader config with DMA disabled (ide=nodma)
sudo bash -c 'cat > /mnt/redflag2/boot/extlinux.conf << EOF
DEFAULT linuxup
TIMEOUT 30
PROMPT 1
LABEL linuxup
  KERNEL /boot/vmlinuz-2.2.16-22
  INITRD /boot/initrd-2.2.16-22.img
  APPEND root=/dev/hda1 ro ide=nodma
EOF'

# 4. Disable hardware acceleration in XFree86 so graphics do not break
sudo sed -i 's|    Driver\t\t"cirrus"|    Driver\t\t"cirrus"\n    Option "noaccel"\n    Option "no_bitblt"|' /mnt/redflag2/etc/X11/XF86Config

# 5. Unmount the disk
sudo umount /mnt/redflag2
sudo qemu-nbd -d /dev/nbd0

3. Correct System Startup

Now that the system is patched, you can boot it using this command:

qemu-system-x86_64 -m 256 -cpu pentium3 -hda redflag2_hdd.qcow2 -boot c -vga cirrus

Here we limit memory to 256 MB (1 GB makes the 2.2 kernel go crazy) and emulate a pentium3 to bypass the TSC error.

How to log in:

  • At startup, the bootloader will automatically select linuxup (uniprocessor kernel). Be sure to use this, as the multiprocessor kernel (linux) will freeze in QEMU.
  • During system boot, wait for the graphical boot window to appear and press Ctrl + C to skip it (or skip a hung step).
  • Wait for the text login prompt to appear (localhost login). Enter the login root and the password you set during installation.
  • Start the graphical shell with the command: startx

Done! You will land on the desktop of a stable running Red Flag OS 2.0.

Version 3.0 Installation

Red Flag OS 3.0 is a rare Chinese Linux distribution from the early 2000s. When installing and running this system, enthusiasts often encounter built-in protection: a requirement to enter a "License Code" of a specific format. This guide shows how to run the system in QEMU and permanently disable the license check.

Red Flag OS 3.0 Screenshot
Host OS Notice
It is highly recommended to perform the installation on Linux. Attempting to install in QEMU under Windows often leads to specific bugs (e.g., fatal errors during package unpacking). Installation runs stably on Linux.

Step 1. System Installation

Create a hard drive (e.g., 6 GB):

qemu-img create -f qcow2 redflag_hdd.qcow2 6G

Start the virtual machine booting from CD-ROM (-boot d):

qemu-system-x86_64 -m 1024 -cdrom redflag3.0.iso -hda redflag_hdd.qcow2 -boot d -vga std

Proceed with the standard installation process (disk selection, package installation).

Step 2. The License Window Problem

After installation is complete and the system reboots, you will be greeted by a graphical window asking for a "License Code".

Why does this happen? The Red Flag developers cleverly embedded the key check directly into the KDE welcome screen (KDM) specifically in the /usr/lib/libKdmGreet.so library. Guessing the key or finding a working one online is practically impossible today.

Solution: Since the check is only hardcoded into KDM, we can simply switch the system to use the alternative display manager GDM (GNOME), which is already installed by default!

Step 3. Bypassing the Check (HDD Patch)

Close QEMU. Mount your virtual hard drive on a Linux system:

# Load Network Block Device module
sudo modprobe nbd max_part=8
# Connect disk image as block device
sudo qemu-nbd -c /dev/nbd0 redflag_hdd.qcow2
# Mount the first partition
sudo mkdir -p /mnt/redflag
sudo mount /dev/nbd0p1 /mnt/redflag

Now change the display manager configuration to force GNOME (GDM) instead of KDE (KDM):

sudo bash -c 'echo "DESKTOP=GNOME" > /mnt/redflag/etc/sysconfig/desktop'

Unmount the disk and disconnect the device:

sudo umount /mnt/redflag
sudo qemu-nbd -d /dev/nbd0

Step 4. Boot and Login

Now run QEMU booting from the hard drive (-boot c):

qemu-system-x86_64 -m 1024 -hda redflag_hdd.qcow2 -cdrom redflag3.0.iso -boot c -vga std

Instead of the license window, the standard GDM (GNOME) login screen will load. Enter the login root and your installation password to access the desktop with full administrator rights.

Alternatively: You can simply download a pre-patched disk image with Red Flag OS 3.0 already installed and the license bypassed!

Apple TV Port

The Apple TV 1G features an Intel Pentium M and an ICH7M chipset but lacks a standard BIOS, relying on a 32-bit Apple EFI implementation. Running a 2001 Linux distribution (kernel 2.4.7) on this hardware required overcoming specific boot and hardware initialization issues.

Red Flag OS Apple TV Port Screenshot
View Technical Porting Phases (Phases 1-5)

Phase 1: EFI Boot Process

The Apple TV bootloader requires a macOS style boot.efi and mach_kernel. We used an atv-bootloader to wrap the Linux kernel. A Mach-O header patch was applied because the EFI expected a specific page size:

xxd mach_kernel | sed -e "s/ffff ffff 1000/0100 0000 1000/" | xxd -r - mach_kernel_patched

Phase 2: Hybrid MBR and File System

The Linux 2.4.7 kernel does not natively support GPT partitions. Using gdisk, we created a Hybrid MBR to expose the Linux partition to the legacy kernel while preserving the GPT structure for EFI.

Additionally, formatting the ext3 partition required using a 128 byte inode size (rather than the modern 256 byte default) for kernel compatibility.

Phase 3: IDE Controller and Root Device

Early boot resulted in a Kernel Panic due to failing to probe the IDE IRQ and attempting to mount the wrong root device (error 19 mounting ext3).

We used a Python script to hex patch the bzImage header at offset 0x1FC, changing the default root device from 0x0305 (hda5) to 0x0302 (hda2). The IDE interrupt issue was resolved by passing kernel parameters ide0=0x1f0,0x3f6,14 combined with acpi=off noapic pci=biosirq idle=poll via com.apple.Boot.plist.

Phase 4: USB controller and Interrupt Routing

Initializing USB involved handling the ICH7M LEGSUP registers. The usb-uhci.o driver initially failed with a NULL pointer dereference because it could not recognize the ICH7M PCI Device ID.

The solution was achieved by combining the kernel boot parameters (acpi=off noapic pci=biosirq idle=poll) with a startup script (rc.local). The script used setpci (e.g., setpci -d 8086:27c8 C0.w=8f00) to clear the legacy support registers before loading the USB modules.

Phase 5: Finalizing Device Support

While modifying the uhci.o driver binary directly was explored, the final configuration successfully loaded the USB drivers through proper setpci register initialization and ensuring that IRQ 10 was correctly assigned for the controller to function. With these adjustments, Red Flag OS 3.0 successfully boots to the GNOME desktop with fully functioning USB inputs and hub support.

Universal Assembly Tools

The assembly tools developed during this project (memwrite, disable_ioapic, elcr) are 100 percent universal for any 32-bit Linux distribution. They will reliably configure the ICH7M chipset on the Apple TV regardless of the operating system. You can use these tools to boot other legacy distributions such as Slackware, Mandrake, or Debian.

Why are they universal? These utilities were written in pure NASM x86 assembly without relying on the C standard library (libc) or any modern GCC compiler optimizations (which caused Floating point exception crashes on older CPUs due to SSE instructions). By exclusively using basic 80386 instructions and direct Linux kernel system calls (int 0x80) for raw memory and I/O port access (inb/outb), these statically linked binaries are completely portable across virtually all 32-bit Linux kernels from the era.

Important: When using the elcr tool for the Apple TV USB controller, it is mandatory that the interrupt is set specifically to IRQ 10 for the hardware to function properly.

Download and Install

Download the compressed 3.9 GB .img.gz disk image. Use the provided Linux bash script to write it to a drive for the Apple TV.

chmod +x install_redflag_appletv.sh
sudo ./install_redflag_appletv.sh

The script writes the drive using oflag=direct to bypass cache and ends by executing sgdisk -e to rebuild the GPT backup header for the new disk size.