Documentation Index
Fetch the complete documentation index at: https://mintlify.com/pastaboy12345/SilverOS/llms.txt
Use this file to discover all available pages before exploring further.
mkfs_svd is a host-side C utility that creates a fresh SilverFS-formatted virtual disk image (.svd file). It runs on the development machine — not inside the kernel — and must be executed before booting SilverOS whenever a new or clean disk is needed. The tool allocates a 16 MB flat binary image, writes a valid superblock, initialises the inode and block bitmaps, lays out an empty inode table, and sets up inode 0 as the root directory. The resulting file is passed directly to QEMU as a virtual ATA hard disk.
The kernel’s
silverfs_format() function is a stub that always returns -1 with a warning message. All disk formatting must be performed with the host-side mkfs_svd tool. Never rely on the kernel to format the disk.Building mkfs_svd
mkfs_svd is built automatically as part of the standard build process. The compiled binary is placed at build/mkfs_svd.
tools/mkfs_svd.c and has no dependencies beyond the C standard library, so it compiles cleanly on any Linux host.
Usage
mkfs_svd takes exactly one argument: the path of the output .svd file to create. If the file already exists it is overwritten. On success, the tool prints a confirmation line and exits with status 0; on failure (e.g., unable to open the output path or out of memory) it prints an error to stderr and exits with a non-zero status.
What mkfs_svd creates
The toolcallocs a 16 MB buffer (SVD_FILE_SIZE = 16 * 1024 * 1024), populates it in memory, then writes the entire buffer to disk in a single fwrite call. The resulting image has the following structure:
Block 0 — Superblock
The silverfs_superblock_t at byte offset 0 is initialised with:
| Field | Value |
|---|---|
magic | 0x53494C56 (“SILV”) |
block_size | 4096 |
total_blocks | 4096 |
total_inodes | 1024 |
free_blocks | 4073 (4096 − 22 structural blocks − 1 root data block) |
free_inodes | 1023 (inode 0 allocated to root) |
inode_table_block | 3 |
data_block_start | 22 |
root_inode | 0 |
volume_name | "SilverOS" |
1024 inodes × 76 bytes ≈ 19 blocks). All entries are zeroed except inode 0, which describes the root directory:
| Field | Value |
|---|---|
type | SILVERFS_TYPE_DIR (2) |
permissions | 0755 |
link_count | 2 |
size | 0 |
blocks[0] | 22 (first data block) |
block_count | 1 |
desktop_init() populates it on first boot.
SVD file format
A.svd file (SilverOS Virtual Disk) is a flat raw binary image with no header, partition table, or boot record beyond the SilverFS superblock. Every byte offset in the file corresponds directly to a byte on the virtual disk:
- Byte offset
N × 4096is the start of blockN. - Block
Nmaps to LBAN × 8(since each 4096-byte block spans 8 × 512-byte ATA sectors).
ata_read_sectors / ata_write_sectors in include/ata.h) using the macro BLOCK_TO_LBA(block) = block * (SILVERFS_BLOCK_SIZE / ATA_SECTOR_SIZE).
The file is passed to QEMU as the first virtual ATA hard disk:
Default filesystem structure at first boot
When SilverOS boots for the first time against a freshly formatted disk,desktop_init() (in desktop/desktop.c) creates a set of standard directories and seed files using the SilverFS kernel API:
| Path | Type | Contents |
|---|---|---|
/home/ | Directory | — |
/home/user/ | Directory | — |
/etc/ | Directory | — |
/tmp/ | Directory | — |
/etc/hostname | File | silveros |
/home/user/readme.txt | File | Welcome message |
/home/user/readme.txt is:
Regenerating the disk
Runningmake disk or make rebuilds build/disk.svd from scratch using mkfs_svd. This produces a clean, empty filesystem with only the structural metadata written — none of the files created by desktop_init() or any user session are preserved.