Building Unreal Engine 5.8 from Source on Ubuntu 24.04

A step-by-step guide to building Unreal Engine 5.8 from source on Ubuntu 24.04. This article focuses on environment setup only and does not cover runtime issues such as Vulkan rendering, GPU memory, or project-specific troubleshooting.


Introduction

Unlike Windows, Unreal Engine on Linux is typically built directly from source because Epic Games Launcher is not available.

This article documents the complete environment setup process, including:

  • Obtaining Unreal Engine source access
  • Downloading the source code
  • Installing dependencies
  • Building the engine
  • Configuring the NVIDIA driver
  • Launching Unreal Editor

This guide intentionally excludes runtime troubleshooting, which will be covered separately.


Prerequisites

Before starting, make sure you have:

  • Ubuntu 24.04 LTS
  • Git
  • A GitHub account
  • An Epic Games account

You must link your GitHub account to your Epic Games account.

After accepting Epic’s GitHub organization invitation, you’ll gain access to the Unreal Engine repository.


1. Clone Unreal Engine

Create a workspace:

mkdir -p ~/projects_ue5
cd ~/projects_ue5

Clone the engine:

git clone https://github.com/EpicGames/UnrealEngine.git

The initial clone requires tens of gigabytes of disk space, so ensure sufficient free storage before starting.


2. Download Dependencies

Enter the source directory:

cd UnrealEngine

Run:

./Setup.sh

This script automatically downloads:

  • Third-party libraries
  • Toolchains
  • ShaderCompileWorker dependencies
  • Platform SDKs

During execution, you may notice references to distributions such as Rocky Linux.

This is completely normal.

The script downloads dependencies for multiple supported Linux environments, even when running on Ubuntu.


3. Generate Project Files

Run:

./GenerateProjectFiles.sh

During the first execution, Unreal Engine automatically downloads and configures the required .NET SDK.

If the output reports that the Android SDK is missing, it can safely be ignored unless Android development is required.


4. Build Unreal Engine

The simplest build command is:

make -j$(nproc)

Alternatively, Unreal provides its own build script:

Engine/Build/BatchFiles/Linux/Build.sh UnrealEditor Linux Development

The initial build can take anywhere from tens of minutes to several hours depending on your hardware.

After a successful build, the editor executable is located at:

Engine/Binaries/Linux/UnrealEditor

5. Launch Unreal Editor

Launch the editor:

Engine/Binaries/Linux/UnrealEditor

Or open a specific project:

Engine/Binaries/Linux/UnrealEditor MyProject.uproject

The first launch usually takes significantly longer than subsequent launches because Unreal Engine needs to perform several initialization tasks, including:

  • Starting ShaderCompileWorker
  • Compiling shaders
  • Initializing the Derived Data Cache (DDC)

This behavior is expected.


6. NVIDIA Driver Considerations

When launching Unreal Engine, you may encounter a warning similar to:

Installed Driver: xxx.xx
Recommended Driver: xxx.xx

Avoid upgrading the driver immediately.

Instead, check the Unreal Editor log first.

If the log explicitly reports missing Vulkan extensions, then upgrading the NVIDIA driver is appropriate.

After upgrading, verify the installation using:

nvidia-smi

It is also recommended to verify the Vulkan runtime:

vulkaninfo

Ensure that Vulkan initializes correctly before attempting to launch Unreal Engine again.


7. Verify the Environment

After completing the previous steps, create a new Unreal Engine project.

For the initial verification, it is recommended to use:

  • Games
  • Blank
  • Blueprint

This provides the simplest project configuration for confirming that the development environment has been built successfully.

Once the editor opens correctly, the environment setup is complete.


Useful Commands

Check the NVIDIA driver

nvidia-smi

Check the Vulkan runtime

vulkaninfo

Find large directories

sudo du -xh --max-depth=1 /

Conclusion

Building Unreal Engine 5.8 on Ubuntu mainly consists of the following steps:

  1. Obtain Epic Games source access
  2. Clone the Unreal Engine repository
  3. Run Setup.sh
  4. Run GenerateProjectFiles.sh
  5. Build the engine
  6. Verify or update the NVIDIA driver if necessary
  7. Launch Unreal Editor and create a test project

Although Linux requires source compilation, the overall workflow is straightforward once the environment has been configured correctly.

This article focuses solely on setting up the development environment. Runtime topics such as Vulkan configuration, rendering features, GPU memory management, and Linux-specific troubleshooting will be covered in separate articles.

Ubuntu SSH Port Configuration: Switch Between ssh.service and ssh.socket

Option 1: Restore Traditional ssh.service Mode

This approach is the easiest to understand and is suitable if you previously managed the SSH port through /etc/ssh/sshd_config.

Disable Socket Activation and Enable SSH Service

sudo systemctl disable --now ssh.socket
sudo systemctl enable --now ssh.service

Check Current SSH Port Configuration

grep -n '^Port' /etc/ssh/sshd_config /etc/ssh/sshd_config.d/* 2>/dev/null

If no custom port is configured, add the following line to /etc/ssh/sshd_config:

Port <CUSTOM_PORT>

Restart SSH Service

sudo systemctl restart ssh.service

Verify Listening Port

sudo ss -ltnp | grep <CUSTOM_PORT>

If you see output such as:

*: <CUSTOM_PORT>

or

0.0.0.0:<CUSTOM_PORT>

then the configuration has been applied successfully.


Option 2: Keep ssh.socket and Change the Listening Port

If you prefer Ubuntu’s newer socket-activation approach, modify ssh.socket instead of sshd_config.

Create a Systemd Override

sudo mkdir -p /etc/systemd/system/ssh.socket.d
sudo nano /etc/systemd/system/ssh.socket.d/listen.conf

Add the following content:

[Socket]
ListenStream=
ListenStream=<CUSTOM_PORT>

Reload and Restart

sudo systemctl daemon-reload
sudo systemctl restart ssh.socket
sudo systemctl status ssh.socket
sudo ss -ltnp | grep <CUSTOM_PORT>

Important Note

The following line is critical:

ListenStream=

It clears the default listening port before setting the new one.

Without this line, systemd may continue listening on both the default SSH port and the custom port simultaneously.

Granting Sudo or Write Access to Non-Interactive AI Agents on Linux

When you let an AI coding agent (Codex, Claude Code, or any CLI agent) operate on a remote Linux server over SSH, you eventually hit a wall the moment it tries to run sudo:

sudo: a password is required

The agent is not “broken.” It is simply running in a non-interactive shell, with no TTY attached, so sudo has nowhere to read the password from. Even if you know the password, you cannot type it into a remote process the agent spawned.

This post documents two practical ways to fix this. They solve the same symptom from very different angles.


The Root Cause

Non-interactive shell + sudo asking for password = deadlock
agent ──ssh──> remote bash (no tty) ──> sudo ──> "Password:"
↑
nobody can answer

There are three theoretical escape routes:

  1. Make the operation not need sudo (file-level permissions / ACL)
  2. Make sudo stop asking for a password (NOPASSWD in sudoers)
  3. Force a pseudo-TTY and pipe the password (works locally, fragile remotely)

Approach 3 is rarely worth the trouble on a remote machine. Below are the two that actually scale.


Approach A — NOPASSWD in sudoers

Tell sudo to skip the password prompt for a specific user. The agent still calls sudo, but it goes through without authentication friction.

When to use

  • The agent legitimately needs root-level operations across the system
  • The target paths are spread across multiple root-owned locations
  • You are comfortable granting (a scoped or full) passwordless root

Setup

Always edit sudoers through visudo — it validates syntax before saving. Direct vim /etc/sudoers* is dangerous: one typo can lock the entire sudo subsystem.

# Use visudo with vim as the editor
sudo EDITOR=vim visudo -f /etc/sudoers.d/your-agent

Full passwordless root (simplest, but broadest):

your-user ALL=(ALL) NOPASSWD: ALL

Scoped to specific commands (safer):

Cmnd_Alias TARGET_OPS = \
/bin/cp * /opt/your-app/target-dir/*, \
/bin/mv * /opt/your-app/target-dir/*, \
/bin/mkdir /opt/your-app/target-dir/*, \
/bin/rm /opt/your-app/target-dir/*
your-user ALL=(ALL) NOPASSWD: TARGET_OPS

Fix permissions (visudo usually does this automatically):

sudo chmod 440 /etc/sudoers.d/your-agent
sudo chown root:root /etc/sudoers.d/your-agent

Verification

sudo su your-user
sudo -n cp /tmp/src /tmp/dst
OutputMeaning
Silent successNOPASSWD is active
sudo: a password is requiredConfig not picked up — check filename, syntax, permissions
cp: cannot stat '...'sudo already passed; this is a cp error, not a permission issue

Filename rules for /etc/sudoers.d/

RuleDetail
Allowed charactersletters, digits, -, _
Forbidden. and ~ — sudo silently ignores files containing these
File mode0440, owner root:root
Load orderalphabetical; later files override earlier ones

Trade-offs

  • ✅ Simple, well-understood, standard for CI / agents
  • ✅ Works for any command, including ones that need real root (package installs, service restarts)
  • ⚠️ NOPASSWD: ALL effectively gives that account unrestricted root
  • ⚠️ Hard to express “any operation on this directory” — sudoers matches on commands, not on paths as a primary concept
  • ⚠️ Shell redirection (>) and pipes are handled by the shell, not sudo, so sudo echo x > file doesn’t work the way you’d expect

Approach B — POSIX ACL (setfacl)

Step back and ask the more useful question: does the agent actually need sudo, or does it just need write access to one directory?

If the answer is the latter, the cleanest solution doesn’t touch sudo at all. You give the user filesystem-level permission to the directory and the agent runs every command without sudo.

When to use

  • The agent only needs to write to a specific directory tree
  • You want to avoid granting any form of sudo
  • You want shell redirection, sed -i, git, rsync, tar, etc. to all “just work”

Setup

TARGET=/opt/your-app/target-dir
# Grant rwx on existing files and directories
sudo setfacl -R -m u:your-user:rwx "$TARGET"
# Default ACL so newly created files inherit the permission
sudo setfacl -R -d -m u:your-user:rwx "$TARGET"

The two commands are both required. Without the default ACL, files created inside $TARGET later will revert to the original ownership and the agent will lose write access to them.

Verification

getfacl /opt/your-app/target-dir

You should see entries like:

user::rwx
user:your-user:rwx
default:user:your-user:rwx

Now the agent can do whatever it wants inside that tree, with no sudo prefix:

cp src.md /opt/your-app/target-dir/
sed -i 's/old/new/' /opt/your-app/target-dir/*.md
echo "data" > /opt/your-app/target-dir/output.log
rm /opt/your-app/target-dir/stale.tmp
mkdir /opt/your-app/target-dir/subdir

Trade-offs

  • ✅ Native semantics — “user X owns write rights to directory Y” is exactly what ACL expresses
  • ✅ No sudoers changes, no security audit on /etc/sudoers.d/
  • ✅ Directory ownership stays root, respecting FHS conventions for /opt/
  • ✅ Redirection, pipes, and arbitrary tools all work
  • ⚠️ A package upgrade that replaces files inside the target may strip ACLs from the new files
  • ⚠️ Doesn’t help if the agent legitimately needs root for non-file operations (systemd, networking, etc.)

Side-by-Side

DimensionNOPASSWD sudoersPOSIX ACL
Conceptual axisAuthorizes commandsAuthorizes files/directories
Agent needs sudo prefixYesNo
Scope of trustBroad (or carefully enumerated)Tight (one directory tree)
Supports shell redirectionNo (shell handles it before sudo)Yes
Risk if account compromisedPotentially full rootWrite access to one directory
Best forSystem-wide tasks, package management, service controlWriting into a specific app/data directory
Setup complexityLow–mediumLow
MaintenanceGrows as commands growOne-time

A Quick Decision Tree

Does the agent need root for anything beyond writing one directory?
│
├─ Yes → NOPASSWD in /etc/sudoers.d/
│ (prefer scoped command list over `ALL` if you can)
│
└─ No → POSIX ACL with setfacl
(no sudo involved, no sudoers risk)

A Note on Local vs Remote Agents

You may have noticed that the same agent running locally can happily prompt you for a sudo password mid-task, while the same agent over SSH cannot. That is not a bug, it is a property of the channel:

  • Locally, the agent shares stdin with your terminal. When sudo writes Password:, the agent passes it to your screen, you type, the keystrokes go back into the child process. The TTY chain is intact.
  • Remotely, the agent’s SSH invocation typically runs in capture-stdout mode without an interactive TTY. The password prompt appears on the remote side, but there is no live keyboard wired to it.

That is the whole reason both approaches above are framed around “make the password go away” rather than “answer the password prompt.”


Conclusion

Two clean options, with different philosophies:

  • NOPASSWD is the right answer when the agent genuinely needs root and you want the standard SRE-style solution.
  • ACL is the right answer when the agent only needs to write somewhere, and you want the smallest, most surgical permission change.

For most “let my AI agent write into this one project directory” cases, ACL is the better starting point. Reach for NOPASSWD when the work genuinely crosses the root boundary.

Creating a Fully Restorable Windows System Backup (GPT + EFI + MSR + C)


Recommended Full System Backup Strategy

Boot into a Linux live USB environment.


① Backup the GPT Partition Table

sgdisk --backup=/media/xxx/DiskBackup/gpt.bin /dev/nvme0n1

✔ Includes both primary and backup GPT headers
✔ Very small file
✔ Mandatory

This preserves your exact partition structure.


② Backup the EFI Partition

Assuming EFI is p1:

dd if=/dev/nvme0n1p1 of=/media/xxx/DiskBackup/efi.img bs=4M status=progress

EFI contains your bootloader and UEFI boot files.


③ Backup the MSR Partition (16MB)

Assuming MSR is p2:

dd if=/dev/nvme0n1p2 of=/media/xxx/DiskBackup/msr.img bs=4M status=progress

⚠ Takes about 1 second
⚠ Technically optional
⚠ But since it’s tiny, backing it up completes the snapshot


④ Backup C: Using partclone

partclone.ntfs -c -s /dev/nvme0n1p3 -o /media/xxx/DiskBackup/c.img

✔ Only backs up used NTFS blocks
✔ Much faster than dd
✔ Image size is significantly smaller


Full Restore Procedure

If the system ever fails:


1️⃣ Restore GPT

sgdisk --load-backup=gpt.bin /dev/nvme0n1

2️⃣ Restore EFI

dd if=efi.img of=/dev/nvme0n1p1 bs=4M

3️⃣ Restore MSR (Optional)

dd if=msr.img of=/dev/nvme0n1p2 bs=4M

4️⃣ Restore C:

partclone.ntfs -r -s c.img -o /dev/nvme0n1p3

5️⃣ (Safest Step) Rebuild Boot Files

Boot into Windows recovery or installation media and run:

bcdboot C:\Windows /f UEFI

The Real Cause of Intermittent Ubuntu Boot Failures on Hyper-V

— and Why “Preparing in Advance” Solves It Once and for All

When running Ubuntu on Hyper-V, some users encounter a very confusing issue:

  • On a cold boot, the system occasionally drops into emergency mode
  • Errors indicate failure to load kernel modules or mount the root filesystem
  • Repeatedly clicking “Stop → Start” eventually allows Ubuntu to boot normally
  • The system disk and files are not corrupted

This problem is hard to reproduce reliably and difficult to search for online.
After a complete investigation, the conclusion is clear:

This is not accidental, nor mysterious behavior —
it is a classic engineering problem caused by insufficient boot-time preparation.


1. The Key Conclusion (Important)

The root cause is not a broken system.

The real issue is:

Linux boots faster than the virtual disk is ready.

And the solution can be summarized in one sentence:

Move work that is normally done during boot
to a point before the system starts booting.


2. Where Exactly Does the Failure Occur?

A simplified Linux boot sequence looks like this:

GRUB
 → Linux kernel
 → initramfs (minimal early boot environment)
 → Mount root filesystem (/)
 → systemd startup

The failure happens precisely at this transition:

initramfs → mounting the root filesystem

In a Hyper-V cold-boot scenario:

  • The kernel has already started mounting /
  • But the virtual disk controller / I/O path is still initializing
  • The device “will exist very soon”, but does not yet exist at that moment

Linux does not wait indefinitely by default, so the mount fails and the system
drops into emergency mode.


3. Why Rebooting Sometimes “Fixes” It

This is where many people are misled.

What actually happens:

First cold boot

  • Virtual device initialization is slow
  • Disk readiness lags behind kernel startup

Subsequent boots

  • Controllers, caches, and resources are already warm
  • The disk becomes ready much faster

This creates the illusion:

“If I restart a few times, it works.”

But this only changes the probability, not the underlying problem.


4. The Real Solution: Prepare in Advance

The effective fix consists of four steps:

sudo update-initramfs -u -k all
sudo nano /etc/default/grub

Change:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"

to:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash rootdelay=10"

Then run:

sudo update-grub
sudo reboot

What This Achieves

  • update-initramfs
    Ensures all required kernel modules are already available at boot time,
    instead of being loaded on demand.
  • rootdelay=10
    Explicitly tells the kernel to wait (up to 10 seconds) for the virtual disk
    before attempting to mount /.
  • update-grub
    Applies the new boot configuration.
  • reboot
    Activates the changes, which only take effect during startup.

Together, these steps eliminate the boot-time race condition entirely.


Appendix

Why rootdelay Fixes Disks but Breaks Your Assumptions

This section exists to clarify an important but easily misunderstood point:

rootdelay fixes a storage-layer race condition —
it does not fix system readiness as a whole.

Understanding this distinction is critical to applying the solution safely.


1. What rootdelay Actually Does (and What It Does Not)

The kernel parameter:

rootdelay=10

has a very narrow and specific purpose:

  • It delays mounting the root filesystem (/)
  • It gives block devices (e.g. virtual disks) extra time to appear
  • It only affects the transition: initramfs → mount /

This makes it effective for scenarios such as:

  • Hyper-V cold boot
  • Slow virtual disk initialization
  • Storage controllers that appear shortly after kernel start

However, rootdelay does not:

  • Delay systemd startup globally
  • Delay network stack initialization
  • Synchronize higher-level services
  • Fix Layer-3 (IP) configuration issues

It operates entirely at the storage boundary.


2. Why This Can Accidentally “Break” Networking

Many Linux systems implicitly assume:

“If the system boots, the network will be provided by DHCP.”

This assumption is usually correct on:

  • Home networks
  • Cloud images
  • Default Ubuntu installations

But it is not universally valid, especially in:

  • Enterprise networks
  • Corporate VLANs
  • Environments with statically assigned IP addresses

When rootdelay is introduced:

  • Boot timing changes slightly
  • Service initialization order may shift
  • Latent configuration assumptions become visible

If the network does not provide DHCP, the system will now clearly fail to acquire an address —
not because rootdelay broke networking, but because:

The system was never correctly configured for the network it was on.


3. The Key Misinterpretation to Avoid

It is tempting to conclude:

“After adding rootdelay, networking stopped working.”

This is not the correct causal model.

The correct interpretation is:

rootdelay removed a storage race
→ system booted deterministically
→ network configuration assumptions were exposed
→ DHCP failed (as expected in static IP environments)

In other words:

rootdelay did not break networking —
it removed a distraction that previously hid the real issue.


4. Static IP Environments Require Explicit Configuration

In networks where IP addresses are assigned manually, the correct fix is not boot-time tuning, but network-layer correctness.

That means explicitly configuring:

  • IP address
  • Subnet mask
  • Default gateway
  • DNS servers

For example (NetworkManager):

nmcli connection modify "Wired connection 1" \
ipv4.method manual \
ipv4.addresses <STATIC_IP>/<PREFIX> \
ipv4.gateway <GATEWAY> \
ipv4.dns "<DNS1> <DNS2>"

Then forcing a reconnection:

nmcli connection down "Wired connection 1"
nmcli connection up "Wired connection 1"

This is not a workaround, and it is not related to rootdelay.

It simply aligns the system with the reality of the network.


5. Engineering Takeaway

The deeper lesson is not about rootdelay itself, but about scope:

A fix that is correct at one layer
should never be assumed to generalize upward.

  • rootdelay fixes storage readiness
  • It does not define system readiness
  • It cannot compensate for incorrect Layer-3 assumptions

Fixing “wrong fs type / bad superblock” on an External Drive

(When Linux Sees /dev/sda but No /dev/sda1)

When mounting an external drive, I hit the following error:

sudo mount /dev/sda /media/external
mount: /media/external: wrong fs type, bad option, bad superblock on /dev/sda, ...

At first glance, this looks like a “broken filesystem.”
In reality, Linux could not see any partition at all (no /dev/sda1), so I was effectively trying to mount the entire disk device instead of a partition.

This post documents a safe, reproducible recovery workflow:

  • Identify the real problem
  • Create a full disk image with ddrescue
  • Use TestDisk to locate the lost partition
  • (Optional) Write the partition table back so the disk mounts normally again

Boot Sector vs. Partition Table — What Was Actually Broken?

Before doing anything, it’s critical to understand where the failure occurred:

  • Partition table (MBR/GPT)
    • Lives at the very beginning of the disk
    • Describes where partitions start/end
    • If this is missing or corrupt, you won’t even get /dev/sda1
  • Boot sector / filesystem metadata
    • Lives inside a partition
    • If only this is damaged, you usually still see /dev/sda1, but mounting fails

👉 In this case, the partition table was missing/corrupt, which is why lsblk showed sda but no sda1.


0) Safety Rules (Read This First)

  • Do NOT format the disk
  • Do NOT run destructive commands
    (e.g., mkfs, wipefs without -n, or random “repair” tools)
  • Always double-check the device name
    One typo in /dev/... can destroy your system disk
  • If you see many USB resets or I/O errors in dmesg,
    suspect cable/enclosure/power issues first

1) Confirm the Disk Is Detected

lsblk -o NAME,SIZE,MODEL,SERIAL,TYPE,MOUNTPOINTS

Identify your external drive by size and model.
Example:

/dev/sda   ~476GiB

2) Check for Partitions or Filesystems

lsblk -f
sudo fdisk -l /dev/sda

Key observation

  • If you see only sda and no sda1/sda2,
    the partition table is likely missing or corrupt.

Force a partition table reread (safe):

sudo partprobe /dev/sda
lsblk -o NAME,SIZE,TYPE,FSTYPE,LABEL,MODEL /dev/sda

Read-only signature checks:

sudo wipefs -n /dev/sda
sudo file -s /dev/sda

If wipefs -n shows nothing and file -s prints only data,
Linux does not recognize any partition table or filesystem header.

Quick read test (read-only):

sudo dd if=/dev/sda of=/dev/null bs=1M count=16 status=progress

If this runs at normal speed, the disk is at least readable.


3) Create a Full Disk Image First (Strongly Recommended)

Make sure another disk has enough free space (≥ disk size) and supports large files (avoid FAT32):

df -hT /mnt/recovery

Install tools:

sudo apt update
sudo apt install -y gddrescue testdisk

Create directories:

sudo mkdir -p /mnt/recovery/sda_backup
sudo mkdir -p /mnt/recovery/sda_recovered

First ddrescue pass (fast, minimal retries)

sudo ddrescue -f -n /dev/sda \
  /mnt/recovery/sda_backup/sda.img \
  /mnt/recovery/sda_backup/sda.log

Optional second pass if there were read errors:

sudo ddrescue -f -d -r3 /dev/sda \
  /mnt/recovery/sda_backup/sda.img \
  /mnt/recovery/sda_backup/sda.log

If you end up with 100% rescued and 0 read errors, the entire disk has been safely captured.


4) Use TestDisk on the Image to Find the Lost Partition

sudo testdisk /mnt/recovery/sda_backup/sda.img

In the interactive UI:

  1. Select the disk image
  2. Analyse → Quick Search
    (Use Deeper Search only if needed)
  3. Highlight a candidate partition and press P to list files

If P shows your real folders/files, that partition entry is correct.

Optional: Copy Files Out

  • Press a to select all → C (uppercase) to copy
  • Destination:/mnt/recovery/sda_recovered

If space is limited, copy only what you need.


5) Restore the Partition Table to the Original Disk

⚠️ Do this only after you have a full backup image.

Run TestDisk on the real device:

sudo testdisk /dev/sda

Steps:

  1. Analyse → Quick Search
  2. Highlight the correct partition and press P to confirm files
  3. Back in the list:
    • Set the correct entry to P (Primary)
    • Set wrong/overlapping entries to D (Deleted)
  4. Press Enter → Write → Y

This writes the recovered partition table back to /dev/sda.


6) Reload Partition Info and Mount (Read-Only First)

sudo partprobe /dev/sda
sudo partx -u /dev/sda
lsblk -f /dev/sda

You should now see:

/dev/sda1

Mount read-only to verify:

sudo mkdir -p /media/external
sudo mount -o ro /dev/sda1 /media/external

If everything looks correct:

sudo umount /media/external
sudo mount /dev/sda1 /media/external

Troubleshooting Notes

  • Seeing NTFS when you expected exFAT
    Trust what TestDisk reports; the drive may have been formatted differently than you remember.
  • NTFS “hibernated / unsafe state” warnings
    Best fix is on Windows:chkdsk /f Linux-side helper:sudo ntfsfix /dev/sda1
  • I/O errors or USB resets
    Change cable/port/enclosure, avoid hubs, ensure sufficient power, then image with ddrescue.
  • TestDisk can’t list files
    The filesystem metadata may be damaged. As a last resort, use PhotoRec (filenames/folders are usually lost).

Summary

  • The mount error was a symptom; the key clue was no /dev/sda1
  • The real issue was a missing or corrupt partition table
  • Best practice is always:

Image first with ddrescue, then analyze and recover with TestDisk.

Surface Laptop 2 修复 BLInitializeLibrary failed / 0xc0000001

适用于系统文件仍在,但EFI 引导区损坏导致无法启动、自动修复失败、bootrec 扫描不到 Windows 的情况。

以下步骤已被实际验证有效。


#️⃣1. 制作恢复 U 盘(Linux 环境)

① 下载微软恢复镜像

选择设备型号(如 Surface Laptop 2)
输入序列号
下载 ZIP(约 7.8GB)


② 在 Linux 中将 U 盘格式化为 FAT32(最重要步骤)

先确认你的 U 盘设备名称,例如:

lsblk

假设是 /dev/sda(⚠ 注意:千万不要选错)

格式化为 FAT32:

sudo umount /dev/sda*
sudo mkfs.fat -F 32 /dev/sda

③ 挂载 U 盘

sudo mkdir -p /mnt/usb
sudo mount /dev/sda /mnt/usb

④ 解压微软恢复镜像

unzip Surface_Recovery.zip -d surf

⑤ 将恢复文件复制到 U 盘(必须复制内容,而不是文件夹)

sudo cp -r surf/* /mnt/usb/

⑥ 卸载 U 盘

sudo umount /mnt/usb

#️⃣2. 从 U 盘启动进入恢复界面

  1. 插入 U 盘
  2. 长按 音量 –
  3. 按电源
  4. 松开电源但继续按住音量 –
  5. 进入 Windows 蓝色恢复界面

#️⃣3. 打开命令提示符

疑难解答 → 高级选项 → 命令提示符


#️⃣4. 可选:修复系统文件(推荐)

sfc /scannow /offbootdir=C:\ /offwindir=C:\Windows
dism /image:C:\ /cleanup-image /restorehealth

#️⃣5. 运行 bootrec(如果扫描到 0 个 Windows,继续下一步)

bootrec /fixmbr
bootrec /fixboot
bootsect /nt60 sys
bootrec /fixboot
bootrec /scanos

#️⃣6. 手动重建 EFI 引导分区(真正解决问题的步骤)

① 打开 diskpart

diskpart
list volume

记住EFI 分区编号:
通常是 100MB FAT32(如 Volume 1)


② 选择 EFI 分区并挂载为 Z:

sel volume 1
assign letter=Z
exit

③ 清空 EFI 目录并重建

cd /d Z:\
rmdir /S /Q Z:\EFI
mkdir Z:\EFI

④ 将 Windows 引导文件写入 EFI(最关键一步)

bcdboot C:\Windows /s Z: /f UEFI

看到:

启动文件创建成功

代表修复成功。


#️⃣7. 重启

exit

选择:

Continue → Continue to Windows

系统即可恢复正常启动。


🟦 总结(极简版流程)

# Linux 制作恢复盘
sudo umount /dev/sdX*
sudo mkfs.fat -F 32 /dev/sdX
sudo mount /dev/sdX /mnt/usb
unzip Recovery.zip -d surf
sudo cp -r surf/* /mnt/usb/
sudo umount /mnt/usb

# Windows 修复:
sfc /scannow /offbootdir=C:\ /offwindir=C:\Windows
dism /image:C:\ /cleanup-image /restorehealth
bootrec /fixmbr
bootrec /fixboot
bootsect /nt60 sys
bootrec /fixboot
bootrec /scanos

diskpart
list volume
sel volume 1
assign letter=Z
exit

cd /d Z:\
rmdir /S /Q Z:\EFI
mkdir Z:\EFI

bcdboot C:\Windows /s Z: /f UEFI

Microsoft 365 Business Premium: From License Activation to Teams Compliance and eDiscovery


A complete technical walkthrough of Microsoft 365 Business Premium,
covering Outlook mailboxes, Entra ID identity management, Teams message retention,
and Microsoft Purview eDiscovery for auditing and data governance.


1 Overview of Microsoft 365 Business Premium

License Components

  • Outlook Exchange Online (50 GB mailbox)
  • Teams for chat, calls, and meetings
  • OneDrive and SharePoint for cloud storage
  • Intune for device management
  • Entra ID (former Azure AD) for authentication and SSO
  • Purview for compliance and eDiscovery
  • Defender for Business for security protection

Each user license can activate Office apps on up to 5 PCs/Macs + 5 tablets + 5 phones.
All services update automatically after login with a valid subscription.


2 Outlook and Exchange Online Mailboxes

  • A Business Premium tenant automatically provisions an
    @yourtenant.onmicrosoft.com mailbox.
  • You can add a custom domain (e.g., @yourcompany.com) in
    Microsoft 365 Admin Center → Settings → Domains.
  • DNS records (MX, SPF, DKIM, DMARC) are handled automatically.

Mail data is stored in Exchange Online, enabling retention and eDiscovery.


3 Microsoft Entra ID (former Azure AD)

Purpose

  • Central identity provider for the tenant
  • User, group, and role management
  • SSO for internal and third-party apps
  • MFA and conditional access policies

Admin Portal


4 Teams Integration Architecture

Teams FeatureData LocationSearchable by eDiscovery
1:1 & group chatsExchange Online (hidden folder “TeamChat”)✅
Channel messagesSharePoint Team Site✅
File attachmentsOneDrive / SharePoint✅
Meeting recordingsStream or OneDrive✅
Calendar eventsExchange Calendar✅

Teams Admin Center provides usage reports:
message counts, meetings joined, call duration, and device types.


5 Microsoft Purview Compliance Portal

New unified entry point: https://compliance.microsoft.com

Included modules for Business Premium:

  • Audit – activity logs (90 days)
  • eDiscovery (Standard) – search and export content
  • Data Lifecycle Management – retention policies
  • Communication Compliance (basic rules)

6 Default Retention and Policy Extension

Data TypeDefault RetentionNotes
Teams chats≈ 30 days (if no policy)Deleted after expiration
Teams channel posts≈ 1 yearStored in SharePoint
Emails (Exchange)UnlimitedUntil user deletes
Files (OneDrive/SharePoint)UnlimitedUntil deleted
Audit logs90 daysExtend with E5 license

Create a Permanent Retention Policy

  1. Open Purview → Data Lifecycle Management → Microsoft 365 → Retention Policies
  2. Create policy → select Teams chats / channel messages
  3. Choose Keep Forever
  4. Apply to All Users → Save → Publish

After this, Teams messages remain permanently searchable and recoverable.


7 eDiscovery (Standard) Workflow

Step 1 Open Module

Purview → Solutions → eDiscovery → eDiscovery (Standard)

Step 2 Create a Case

Example name: Teams_Compliance_Audit

Step 3 Add Search

  • Locations: Teams Chats and Mailboxes
  • Keywords: e.g. ("resignation" OR "quit" OR "leave company")
  • Date range: optional
  • Run the search

Step 4 View and Export

Results show: sender, recipients, timestamp, and message snippet.
Select Preview to see context or Export to download a ZIP package.


8 Export Structure and HTML Preview

TeamsChatExport_20251112_XXXX/
├─ manifest.csv
├─ TeamsChat_1.html
└─ Metadata/
    ├─ MessageDetails.csv
    └─ Attachments/

Example HTML View

───────────────────────────────
User A  ( 2025-11-10 17:42 )
I haven’t mentioned the resignation yet.

User B  ( 2025-11-10 17:43 )
When will you bring it up?

User A  ( 2025-11-10 17:44 )
Probably end of the month, after handover.
───────────────────────────────

Each file includes message context, timestamps, and participants—
allowing a full reconstruction of conversation flow.


9 Permissions Required for eDiscovery

RoleCapabilities
Compliance AdministratorCreate and run Content Search, set policies
eDiscovery ManagerCreate cases, search Teams chats, export results
eDiscovery AdministratorManage all cases and exports
Global AdministratorHas all above permissions by default

Add roles via Purview → Permissions → Microsoft Purview solutions.

All features above are included in Business Premium—no extra license needed.
(Only eDiscovery Premium and Advanced Audit require E5 plans.)


10 Teams Privacy and Compliance Reality

ScenarioRetainedSearchableStorage Location
Private chat (1:1 / group)✅✅Exchange Online hidden folder
Channel posts✅✅SharePoint
Deleted messages (within policy)✅✅Retention snapshot
Attachments✅✅OneDrive / SharePoint

Even deleted messages remain discoverable until their retention period expires.

Conclusion for users:

Teams chat is not a private messenger.
All content belongs to the organization and may be retained or audited.


11 License Tier Comparison

FeatureBusiness PremiumE3 / E5
eDiscovery (Standard)✅✅
eDiscovery (Premium)❌✅
Audit log retention90 days1 year / 10 years
Communication ComplianceBasicAdvanced
DLP (Data Loss Prevention)BasicFull

12 Logical Architecture Summary

[User]
   ↓
[Teams Client]
   ↓
[Exchange Online / SharePoint / OneDrive]
   ↓
[Microsoft Purview Services]
   ├─ eDiscovery
   ├─ Audit
   ├─ Data Lifecycle Management
   ↓
[Compliance Admin Center]

13 Key Takeaways

  1. Business Premium integrates identity (Entra ID), collaboration (Teams), and compliance (Purview).
  2. Teams chat data is retained by default for 30 days unless a policy extends it.
  3. eDiscovery (Standard) can search and export full conversation context in HTML.
  4. Chat content is organizational data, not personal property.
  5. Administrators should set clear retention and privacy policies for all users.

Useful Portals

Install and Configure OpenAI Codex CLI on Ubuntu / WSL


🛠 Overview

This guide explains how to install the OpenAI Codex CLI on Ubuntu or Windows Subsystem for Linux (WSL), set up your API key, and switch authentication methods between apikey and chatgpt.


⚙️ Installation Steps

# Update packages
sudo apt update -y
sudo apt upgrade -y

# Install Node.js (using Node 22 as an example)
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt install -y nodejs

# (Optional) Ensure git is installed
sudo apt install -y git

# Install the Codex CLI globally via npm
sudo npm install -g @openai/codex

# Set your OpenAI API key
export OPENAI_API_KEY="your_OpenAI_API_Key"

# To make this persistent across sessions:
echo 'export OPENAI_API_KEY="your_OpenAI_API_Key"' >> ~/.bashrc
source ~/.bashrc

# Verify installation
codex --version

🔄 Switching Authentication Methods

You can choose how Codex authenticates your account:

# Use direct API key authentication
codex --config preferred_auth_method='apikey'

# Or use ChatGPT-based login
codex --config preferred_auth_method='chatgpt'

🔑 Set API Key Manually

If needed, you can manually edit your authentication file:

vi ~/.codex/auth.json

Add or update your API key inside that file.


🪄 One-Line Quick Install (for Termux / Android)

pkg update -y && pkg upgrade -y && \
pkg install -y curl git && \
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash && \
source ~/.bashrc && \
unset PREFIX && \
nvm install 20 && \
npm install -g @openai/codex && \
echo 'export OPENAI_API_KEY="your_OpenAI_API_Key"' >> ~/.bashrc && \
source ~/.bashrc

Use Local LLM:
Open your Codex configuration file: C:\Users\<username>\.codex\config.toml Replace or append the following: # Use Ollama as model provider model = "gpt-oss:20b" model_provider = "ollama"

like below:

# Use Ollama as model provider
model = "gpt-oss:20b"
model_provider = "ollama"

[model_providers.ollama]
name = "Ollama (local)"
base_url = "http://127.0.0.1:11434/v1"
# Ollama does not require API Key
wire_api = "chat"   # Codex uses Chat Completions API

Restart VS Code
After saving, restart VS Code (or reload the Codex extension) to apply the new settings.


📚 References

How to Add serena MCP Servers in Claude Code

Here are two common methods to configure them permanently — both survive restarts and will always auto-load when Claude Code launches.


Method 1: Command Line (Recommended)

Run the following command in your project directory:

claude mcp add serena -- uvx --from git+https://github.com/oraios/serena serena start-mcp-server --context ide-assistant --project $(pwd)
  • Automatically updates ~/.claude/settings.json
  • Adds the serena MCP server into the configuration
  • Will auto-connect each time Claude Code starts

Method 2: Manual Configuration File Edit

  1. Open ~/.claude/settings.json
  2. Add a new MCP server block, for example:
{
  "mcpServers": {
    "fujisoft-code-agent": {
      "command": "cmd.exe",
      "args": ["/c", "code-agent", "server"]
    },
    "serena": {
      "command": "uvx",
      "args": [
        "--from", "git+https://github.com/oraios/serena",
        "serena", "start-mcp-server",
        "--context", "ide-assistant",
        "--project", "/your/project/path"
      ]
    }
  }
}
  • You can add multiple MCP servers here
  • Save the file and restart Claude Code → the servers will auto-connect

Verify Your Configuration

To check your current MCP servers:

cat ~/.claude/settings.json

Or inside Claude Code:

/status

This will display the list of configured MCP servers and their status.


✅ Conclusion

  • Command Line Method → Quickest and easiest, auto-writes to config
  • Manual File Edit → More flexible, can add multiple servers at once
  • Result is the same → Both are persistent and survive restarts

⚡ Pro Tip:
On Windows, replace $(pwd) with %cd% when running the command.
Example:

claude mcp add serena -- uvx --from git+https://github.com/oraios/serena serena start-mcp-server --context ide-assistant --project %cd%

👉 With this setup, you can extend Claude Code with custom MCP servers like Serena and streamline your coding workflow!


🔹 Additional Knowledge: Execution Status & Management

After Adding Serena with --project

  • When you run: claude mcp add serena --project $(pwd)
    • Serena will only auto-start when you run Claude Code inside that project directory.
    • Other directories will not see Serena.

Manage and Modify MCP Servers

  1. List configured MCP servers: claude mcp list
  2. Remove Serena from config: claude mcp remove serena
  3. Re-add as a global configuration (visible everywhere): claude mcp add serena -- uvx --from git+https://github.com/oraios/serena serena start-mcp-server --context ide-assistant
  4. Add Serena to another project (project-level): cd /path/to/other/project claude mcp add serena -- uvx --from git+https://github.com/oraios/serena serena start-mcp-server --context ide-assistant --project $(pwd)

Config File Locations

  • Project-level config → created inside the project directory
  • Global config → stored in ~/.claude/settings.json

If you want to switch Serena from project-level to global:

  1. Remove the existing entry claude mcp remove serena
  2. Add it again without --project.

在 WordPress.com 上免费创建您自己的网站。创建您自己的网站。
免费开始