Skip to content

Commit 8344fd7

Browse files
authored
Merge pull request #19 from maxgmr/dev
0.1.0-beta.3
2 parents c1c5f3a + 48ebd8c commit 8344fd7

30 files changed

+2828
-531
lines changed

CHANGELOG.md

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,37 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Fun BSOD-style screen on panic.
1313
- Nicer interface for ANSI colour escape codes (and coloured printing in general).
1414
- Get `mash` to "bundle together" stuff with quotes and generally handle quotes properly.
15+
- Build script updates GRUB entry version number automatically
16+
- Handle non-`/dev/sda{1,2}` configurations in `usb-setup` and `initramfs_init`
17+
- Abstract away Tlenix program boilerplate (proc macro?)
18+
- Add `--help` display to all Tlenix programs
19+
- `man` pages!
20+
21+
## [0.1.0-beta.3] - 2025-06-12
22+
23+
### Added
24+
25+
- `cat`: Concatenate files and print on the standard output.
26+
- `clear`: Clears the terminal screen.
27+
- `mv`: Moves/renames files.
28+
- `File::read_to_bytes`: Reads the whole file into a byte vector.
29+
- `format!`: Just like the `std` macro!
30+
- `rename`: Changes the name/path of a file/directory.
31+
32+
### Changed
33+
34+
- Modernized file stats format (`fstat` -> `statx`).
35+
- Statically access the standard input, standard output, and standard error streams.
36+
- Prettier test output alignment.
37+
- Fixed `./usb-install` file schema.
38+
- `README` instructions now use `./usb-install` script.
1539

1640
## [0.1.0-beta.2] - 2025-05-27
1741

1842
### Added
1943

2044
- `hello`: Minimal demo Tlenix program. Useful as a template/example.
21-
- `printenv`: Print the environment variables.
45+
- `printenv`: Prints the environment variables.
2246

2347
### Removed
2448

Cargo.toml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tlenix"
3-
version = "0.1.0-beta.2"
3+
version = "0.1.0-beta.3"
44
authors = ["Max Gilmour <mgilmour@maxgmr.ca>"]
55
edition = "2024"
66
description = "Custom OS built upon the Linux kernel"
@@ -27,5 +27,9 @@ bitflags = "2.1"
2727
getargs = { version = "0.5", default-features = false }
2828
lazy_static = { version = "1.5", features = ["spin_no_std"] }
2929
num_enum = { version = ">=0.4, <=0.7", default-features = false }
30-
spin = "0.10.0"
30+
spin = { version = "0.10.0", default-features = false, features = [
31+
"mutex",
32+
"spin_mutex",
33+
"lock_api",
34+
] }
3135
talc = "4.4.2"

README.md

Lines changed: 45 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,53 @@
11
# Tlenix
22

3-
Custom x86_64 OS built upon the Linux kernel. Boots from a USB.
3+
Custom x86_64 OS built upon the Linux kernel. The OS consists of Tlenix user programs and a custom Linux kernel. Boots from a USB.
44

55
Written in pure Rust without the standard library or any dependencies on a C standard library.
66

77
# Programs
88

9-
`initramfs_init`: Init program for `initramfs`. Sets up important things like devices and the filesystem. Starts `init` when finished.
9+
`initramfs_init`: Init program for the `initramfs`. Sets up important things like devices and the filesystem. Starts `init` when finished.
1010

11-
`init`: Responsible for booting up the system. Starts up `mash`.
11+
`init`: Responsible for booting up the system.
1212

1313
`mash`: **Ma**x's **Sh**ell. An extremely primitive command-line-interface shell.
1414

15-
`ls`: List the entries within a directory.
15+
`cat`: Concatenates files and prints them to the standard output.
16+
17+
`clear`: Clear the terminal screen.
18+
19+
`hello`: Example Tlenix program. Generates a greeting.
20+
21+
`ls`: Lists the entries within a directory.
22+
23+
`printenv`: Prints the current environment variables along with their values.
1624

1725
# Setup Guide
1826

1927
Here's how to get Tlenix running on a USB of your own.
2028

21-
## Watch Out!
29+
## 0. Watch Out!
2230

2331
Stuff like drive partitioning can screw up your system if you don't know what you're doing! If you aren't confident, I recommend using a virtual machine as the host when setting up the USB.
2432

2533
Additionally, make sure nothing important is stored on your USB you're using to boot this, because it _will_ be irrevocably wiped.
2634

2735
This project is in its early stages and is _not thoroughly tested_... Follow these instructions at your own risk.
2836

29-
## Build a Fresh Kernel
37+
## 1. Get the Tlenix Source
38+
39+
Go to a convenient place on your computer and clone the Tlenix source:
40+
41+
```bash
42+
git clone https://github.com/maxgmr/tlenix.git
43+
```
44+
45+
## 2. Build a Fresh Kernel
3046

3147
### Get the Linux Kernel Source
3248

49+
Go to a different convenient place on your computer and clone the Linux kernel source:
50+
3351
```bash
3452
git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
3553
cd linux
@@ -73,53 +91,13 @@ make -j$(nproc) CC="gcc-13" KCFLAGS="-std=gnu11" 2>&1 | tee log
7391

7492
Your finished kernel is located at `arch/x86_64/boot/bzImage` within the Linux source code directory.
7593

76-
## Build the Tlenix Binaries
77-
78-
Switch to the Tlenix source code directory.
94+
### Copy Finished Kernel to Tlenix Source Directory
7995

8096
```bash
81-
cargo build --all --release
97+
cp arch/x86_64/boot/bzImage <tlenix dir>/bzImage
8298
```
8399

84-
Your completed binaries will be under the `target/x86_64-unknown-linux-none/release` directory.
85-
86-
## Create the `initramfs`
87-
88-
We need to create a root filesystem which is used during the boot process. It loads necessary drivers and modules, then passes on control, switching to the actual persistent root filesystem on the USB.
89-
90-
### Create the `initramfs` Directory
91-
92-
```bash
93-
mkdir initramfs
94-
```
95-
96-
### Create the Basic `initramfs` Structure
97-
98-
```bash
99-
mkdir -v initramfs/{bin,dev,etc,lib,proc,sys,usr}
100-
```
101-
102-
### Create Essential Device Nodes
103-
104-
```bash
105-
sudo mknod initramfs/dev/console c 5 1
106-
sudo mknod initramfs/dev/null c 1 3
107-
```
108-
109-
### Copy Over the Tlenix `initramfs_init` Program
110-
111-
```bash
112-
cp <tlenix directory>/target/x86_64-unknown-linux-none/release/initramfs_init initramfs/init
113-
```
114-
115-
### Create the `initramfs` Archive
116-
117-
```bash
118-
cd initramfs
119-
find . | cpio -oH newc | gzip >../root.cpio.gz
120-
```
121-
122-
## Partition USB
100+
## 3. Partition USB
123101

124102
### Warning
125103

@@ -174,48 +152,13 @@ sudo mkfs.vfat -F32 /dev/sdX1
174152
sudo mkfs.ext4 /dev/sdX2
175153
```
176154

177-
## Organize USB Structure
178-
179-
### Mount Partitions
180-
181-
```bash
182-
sudo mkdir -pv /mnt/tlenix-usb/{boot,rootfs}
183-
sudo mount /dev/sdX1 /mnt/tlenix-usb/boot
184-
sudo mount /dev/sdX2 /mnt/tlenix-usb/rootfs
185-
```
186-
187-
### Populate Boot Partition
188-
189-
```bash
190-
sudo cp <path to bzImage> /mnt/tlenix-usb/boot/
191-
sudo cp <path to root.cpio.gz> /mnt/tlenix-usb/boot/
192-
```
193-
194-
### Install GRUB
195-
196-
```bash
197-
sudo grub-install \
198-
--target=x86_64-efi \
199-
--boot-directory=/mnt/tlenix-usb/boot \
200-
--efi-directory=/mnt/tlenix-usb/boot \
201-
/dev/sdX
202-
```
203-
204-
### Configure GRUB
205-
206-
Copy over the GRUB config:
207-
208-
```bash
209-
sudo cp <tlenix dir>/config/grub.cfg /mnt/tlenix-usb/boot/grub/grub.cfg
210-
```
155+
## 4. Configure Tlenix
211156

212-
Optionally, you can edit the configuration:
157+
Inside the Tlenix source directory, the `config/` directory contains some options for customizing your Tlenix installation.
213158

214-
```bash
215-
sudoedit /mnt/tlenix-usb/boot/grub/grub.cfg
216-
```
159+
### Changing the Terminal Font
217160

218-
You can choose your own font. In the place of `TER16x32` in the config above, you can choose from any of the following:
161+
You can choose your own terminal font. To do so, open up `config/grub.cfg` in your preferred text editor. Instead of the default `TER16x32` font, you can set `fbcon=font:` to any of the following:
219162

220163
- `MINI_4x6`
221164
- `6x8`
@@ -227,44 +170,27 @@ You can choose your own font. In the place of `TER16x32` in the config above, yo
227170
- `SUN8x16`
228171
- `10x18`
229172
- `SUN12x22`
230-
- `TER16x32`
231173

232-
## Set Up the Root Filesystem
233-
234-
This is the filesystem which you actually use when running Tlenix.
235-
236-
### Create Minimal Directory Structure
237-
238-
```bash
239-
sudo mkdir -pv /mnt/tlenix-usb/rootfs/{bin,dev,etc,home,lib,proc,sbin,sys,usr,var}
240-
```
174+
## 5. Install Tlenix
241175

242-
### Create Essential Device Nodes
176+
Make sure you're in the Tlenix source directory. Here's a pre-install checklist:
243177

244-
```bash
245-
sudo mknod /mnt/tlenix-usb/rootfs/dev/console c 5 1
246-
sudo mknod /mnt/tlenix-usb/rootfs/dev/null c 1 3
247-
```
178+
- Your partitioned and formatted USB is plugged in.
179+
- `config/grub.cfg` exists.
180+
- `bzImage` exists and is in the top level of the Tlenix source directory.
248181

249-
### Add `init` Program
182+
Make sure your partitioned and formatted USB is plugged in. Once you're ready, run the installation script:
250183

251184
```bash
252-
sudo cp <tlenix dir>/target/x86_64-unknown-linux-none/release/init /mnt/tlenix-usb/rootfs/sbin/init
185+
./usb-install
253186
```
254187

255-
### Add `mash` Program
256-
257-
```bash
258-
sudo cp <tlenix dir>/target/x86_64-unknown-linux-none/release/mash /mnt/tlenix-usb/rootfs/bin/mash
259-
```
188+
## 6. Boot Into Tlenix
260189

261-
## QEMU Test
190+
With your USB plugged in to your computer, restart your machine. If you boot _back_ into your computer's normal operating system, you'll have to go into your computer's BIOS menu and try the following things one at a time, restarting and retrying after each step:
262191

263-
```bash
264-
sudo qemu-system-x86_64 \
265-
-kernel /mnt/tlenix-usb/boot/bzImage \
266-
-initrd /mnt/tlenix-usb/boot/root.cpio.gz \
267-
-drive file=/dev/sdX,format=raw \
268-
-append "root=/dev/sdX2 console=ttyS0" \
269-
-nographic
270-
```
192+
1. Make sure your USB drive is at the top of the boot priority. This is the most common reason why you aren't automatically booting into Tlenix!
193+
2. Make sure Secure Boot is disabled.
194+
3. Disable CSM.
195+
4. Set boot mode to UEFI only, not legacy/BIOS.
196+
5. Disable Fast Boot.

config/grub.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
menuentry "tlenix" {
2-
linux /bzImage root=/dev/sda2 rw loglevel=4 fbcon=font:TER16x32
3-
initrd /root.cpio.gz
2+
linux /EFI/BOOT/bzImage root=/dev/sda2 rw loglevel=3 fbcon=font:TER16x32
3+
initrd /EFI/BOOT/root.cpio.gz
44
}

0 commit comments

Comments
 (0)