<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Karthik Balasubramanian on Medium]]></title>
        <description><![CDATA[Stories by Karthik Balasubramanian on Medium]]></description>
        <link>https://medium.com/@karthikbalasubramanian08?source=rss-110e0af94afa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*g_UJ5ekEM69_738KwWB-iQ.png</url>
            <title>Stories by Karthik Balasubramanian on Medium</title>
            <link>https://medium.com/@karthikbalasubramanian08?source=rss-110e0af94afa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 12:55:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@karthikbalasubramanian08/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Why a goroutine switch is so cheap? The mechanism behind it]]></title>
            <link>https://medium.com/@karthikbalasubramanian08/why-a-goroutine-switch-is-so-cheap-the-mechanism-behind-it-11adfb8b92ff?source=rss-110e0af94afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/11adfb8b92ff</guid>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[os-internals]]></category>
            <category><![CDATA[goroutines]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[memory-management]]></category>
            <dc:creator><![CDATA[Karthik Balasubramanian]]></dc:creator>
            <pubDate>Mon, 12 Oct 2026 18:39:04 GMT</pubDate>
            <atom:updated>2026-10-12T18:39:04.074Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5ZTRtF5EUiPDHHPP.jpg" /></figure><p>The main idea is that switching between goroutines is cheap because Go usually doesn’t need to save and restore every CPU register when switching from one goroutine to another.</p><h3>Before any deeper explanation some tl;dr about CPU registers(for those of us who forgot our OS classes)</h3><p>i just found a better analogy to understand the relationship better. computer’s main memory (RAM) is like a massive warehouse shelves down the street. SSD is a cargo ship parked at the port, registers are the workbench directly in front of the CPU worker’s hands.</p><p>a CPU register is the smallest, fastest storage location inside a computer’s processor. They temporarily hold values, memory addresses, and execution information.</p><h3>Important types of registers</h3><p>General purpose registers(GPR) Hold numbers, temporary values, and sometimes addresses used during calculations.</p><p>Program Counter(PC) Holds the address of the instruction the CPU should execute next (conceptually)</p><p>Stack Pointer(SP) Holds the address marking the current top of the stack, which stores things such as function-call information and local variables.</p><h3>Calling convention</h3><p>Imagine you have two goroutines running on the same OS thread.</p><pre>func worker() {<br>    fmt.Println(&quot;Before blocking&quot;)<br> <br>    ch := make(chan int)<br>    &lt;-ch // Blocks because nobody sends a value<br> <br>    fmt.Println(&quot;After blocking&quot;)<br>}</pre><p>when worker is blocked on the channel, GO&#39;s runtime can pause it and run another goroutine on the same OS thread.</p><p>conceptually GO’s runtime must save worker goroutine&#39;s execution state before switching to another goroutine right? so what exactly GO saves to resume `worker` later?</p><p>First let us understand what a function call does to CPU registers. a function might use them to hold pointers, integers, or intermediate results. When a function calls another function in a program, the CPU needs a standardized contract known as a calling convention so both functions agree on how registers and memory are used without overwriting each other’s data.</p><p>Because a CPU has a very limited set of general-purpose registers, the calling function (caller) and the called function (callee) are likely going to use the exact same registers. To prevent the callee from accidentally destroying data that the caller still needs, calling conventions divide registers into two rulesets:</p><p><strong>caller-saved registers(volatile/scratch registers)</strong></p><ol><li>If the caller has important data sitting in these registers right before making a function call, it is the caller’s responsibility to back them up (usually by pushing them onto the stack) <em>before</em> calling the function.</li><li>The called function is completely free to trash, modify, and overwrite these registers however it wants without restoring them. When the function returns, the caller assumes those register contents are destroyed</li></ol><p><strong>callee-saved registers(non-volatile/preserved registers)</strong></p><ol><li>If the callee (the function being called) wants to use one of these registers for its own work, it must save the original value (e.g push it to the stack) at the very beginning of its execution, and then restore that exact value right before returning to the caller.</li><li>The caller can safely rely on these registers remaining completely unchanged across a function call.</li></ol><blockquote><em>Caller-saved registers are ideal for short-lived data, especially in leaf functions that don’t call other functions. They act as scratch space for temporary calculations without needing to save and restore their values.</em></blockquote><blockquote><em>Callee-saved registers are useful when a function needs to keep values alive across multiple function calls, such as a loop counter or a pointer. The function saves and restores these registers only if it uses them, avoiding the need for the caller to save them around every call.</em></blockquote><p>What does GO choose? Under Go’s official internal ABI specification, Go does not use callee-saved registers.</p><p>refer — <a href="https://go.dev/src/cmd/compile/abi-internal">https://go.dev/src/cmd/compile/abi-internal</a><br><em>There are no callee-save registers, so a call may overwrite any register that doesn’t have a fixed meaning, including argument registers.</em></p><p>Instead, Go treats virtually all general-purpose registers as caller-saved (also known as call-clobbered or volatile) This intentional design drastically simplifies stack tracing for the Garbage Collector (GC), eases dynamic stack growth, and streamlines stack unwinding during panic recovery. If Go utilized callee-saved registers, the GC would be forced to continuously scan spilled register areas in the stack frames to locate active memory pointers.</p><h3>Now we move to the title</h3><p>I think we have enough context to understand the rest of the content now</p><p>In C or C++, when a thread yields or switches, the OS kernel steps in, pauses the thread, and explicitly saves <em>all</em> CPU registers (both caller-saved and callee-saved) into a kernel data structure called a Thread Control Block (TCB). Because Go’s ABI treats most registers as caller-saved (scratch registers), the GO runtime doesn’t need to automatically save all register values during a goroutine context switch. The runtime assumes that if a goroutine was in the middle of a computation using caller-saved registers, those values are already safely stored away or dead.</p><h3>The Catch: Garbage Collection and Stack Growth</h3><p>Even though caller-saved registers don’t need to be preserved across normal function calls, the Go runtime cannot completely ignore them during certain critical events, specifically:</p><ul><li>garbage collection: when a GC safepoint is triggered, the runtime needs to scan all memory pointers to see what objects are still active. If a pointer to a heap-allocated object is sitting temporarily inside a register right at that exact millisecond, the GC <em>must</em> know about it. If it ignores the register, it might think the object has no references and accidentally free it out from under the running goroutine!</li><li>if a goroutine needs to grow its stack,the runtime needs a complete map of the goroutine’s active state.</li></ul><p>Go doesn’t just yank execution away from a CPU core arbitrarily whenever it feels like it. goroutine switch happens at a controlled point in the runtime, where Go can use the architecture’s calling convention and compiler-generated code to manage the required state. that controlled point is what brings us the concept of safepoints in GO</p><h3>Safepoints</h3><p>Go is a garbage-collected language with moving/growable stacks. For the GC to safely sweep memory without accidentally deleting a live object, it must answer one absolute question at any pause: “Where are all the active pointers right now?”</p><p>If a pointer to a heap object is sitting inside a CPU register or on the stack, and the GC misses it, the GC will treat that object as dead garbage and free it. This leads to immediate memory corruption or crashes.</p><p>However, inspecting arbitrary machine code instructions at a random microsecond is nearly impossible because machine code is dynamic and unstructured. Safepoints solve this by establishing a contract between the compiler and the runtime.</p><p>When the Go compiler translates your source code into machine code, it doesn’t just emit instructions; it also generates metadata tables embedded directly into the binary (known as stack maps and live register maps). For every single function, the compiler creates a map that says:</p><blockquote>“If execution stops at PC (Program Counter) offset 0x48a2, then variable x is located at stack offset -16, variable y is dead, and register RAX holds a pointer to a heap object.&quot;</blockquote><p>A safepoint is any instruction offset where this metadata is guaranteed to be valid and available.</p><p>umm.. if it felt a bit confusing the gist is the compiler has predicted the state of the program beforehand. it isn’t predicting <em>what values</em> your variables will hold (it doesn’t know if x is going to be 5 or 10,000 at runtime) It predicts where those variables and pointers live at every single instruction offset.</p><ul><li>The GC reads this, marks those memory objects as alive, and safely ignores them.</li><li>the runtime waits for the goroutine to reach a safepoint. At a safepoint, the goroutine’s state is clean, predictable, and fully mapped out. The runtime can instantly copy the stack pointer (SP) and program counter (PC) into the goroutine&#39;s gobuf structure, park it aside, and load a completely different goroutine onto the CPU core.</li></ul><p>In short: Go avoids the overhead of saving registers on every single function call, but it relies on compiler metadata and strict safepoints so the runtime always knows where live data is hiding when it needs to pause a goroutine.</p><h3>gobuf</h3><p>Go’s runtime uses a structure called gobuf to store the minimal execution context needed for a goroutine switch.</p><p>Conceptually, it contains fields like these:</p><pre>type gobuf struct {<br>    sp  uintptr // Stack pointer<br>    pc  uintptr // Program counter<br>    bp  uintptr // Base pointer, where applicable<br>    // Other fields may also be present<br>}</pre><p>the structure has additional fields and exact details depend on the GO version and architecture(amd64, arm64,…) Go saves the necessary context for one goroutine and restore another goroutine’s context here without performing a full OS-thread context switch.</p><blockquote><em>gobuf is not the entire goroutine state. The goroutine&#39;s stack, scheduler metadata, and other runtime state remain in their respective structures.</em></blockquote><h3>so why is this cheaper than switching OS threads?</h3><p>atp, you might have guessed, the entire switching happens at the user-space, there is no kernel trapping.</p><h3>Goroutine switch</h3><ul><li>Runtime saves and restores the necessary execution context.</li><li>No kernel entry is required just to switch goroutines.</li></ul><h3>OS-thread context switch</h3><ul><li>The OS scheduler participates in switching threads.</li><li>Kernel scheduling and thread-state management add overhead.</li></ul><p>which is why a goroutine switch lands at around 100–200ns versus microseconds for an OS thread.</p><h3>(Optional) asynchronous preemption</h3><p>lol i read about this as well, so putting em here</p><p>If the runtime could only interrupt goroutines at cooperative safe points, a goroutine that never reached a safepoint? It could monopolize its OS thread for too long.</p><pre>func main() {<br>    go func() {<br>        for {<br>            // Infinite CPU-bound loop<br>        }<br>    }()<br> <br>    time.Sleep(time.Second)<br>    fmt.Println(&quot;Hello!&quot;)<br>}</pre><p>The first goroutine runs an infinite loop. Without asynchronous preemption, a goroutine like this could keep running for a long time without reaching a point where the runtime can easily take control.</p><p>That could delay other goroutines that need CPU time.</p><p>Read about this if you have time after this, you’ll love it.</p><p>For more such interesting concepts about GO and rabbitholes follow <a href="https://x.com/kartikktwt">https://x.com/kartikktwt</a></p><p>peace 🕊️</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11adfb8b92ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inside Go’s Garbage Collector: why does it take pauses?]]></title>
            <link>https://medium.com/@karthikbalasubramanian08/inside-gos-garbage-collector-why-does-it-take-pauses-1314129c5468?source=rss-110e0af94afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/1314129c5468</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[garbage-collection]]></category>
            <dc:creator><![CDATA[Karthik Balasubramanian]]></dc:creator>
            <pubDate>Sun, 23 Aug 2026 13:52:52 GMT</pubDate>
            <atom:updated>2026-08-23T13:52:52.220Z</atom:updated>
            <content:encoded><![CDATA[<h3>Inside Go’s Garbage Collector: why does it take pauses? How can you write better GO to reduce GC Overhead</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ih_PmdxrgFH2vLnV.png" /></figure><p>for better reading experience please visit :- <a href="https://kaizakin.site/blogs/inside-go-garbage-collector">https://kaizakin.site/blogs/inside-go-garbage-collector</a></p><p>In the initial days of learning GO you might have heard this sentence from time to time, “GO has unpredictable pause times”, this shows up everywhere reddit, X people arguing about why they chose Rust or c++ over go for their low-latency product. but actually GO’s team has fixed this in the 1.5 release which happened in <a href="https://go.dev/blog/go1.5">August 19, 2015</a> Go now uses the tri-color mark-and-sweep collector, and pause times have been driven down to sub-millisecond levels. now if you think “If go team has fixed this 10 years ago and the stop times are &lt;1ms” then why do still people argue? well that’s what we’re about to cover in this write-up There’s more to garbage collection than STW(Stop the World) pauses.</p><h3>Quick Intro on Garbage Collection</h3><p>Garbage collection is a form of automatic memory management, instead of the programmer manually allocating and deallocating memory (malloc/calloc) in C. The language runtime keeps track of the objects that are still reachable (referenced somewhere in the program) and reclaims the memory of the objects that are no longer reachable.</p><p>Manual memory-management is powerful but error-prone two classic bugs it causes are:</p><ul><li>Memory leaks — forgetting to free memory that’s no longer needed.</li><li>use-after-free/dangling pointers: freeing memory that’s still being used elsewhere and accessing it later.</li></ul><p>Most GCs use some variant of reachability analysis. Starting from a set of “roots” (global variables, stack variables, CPU registers), the collector walks the graph of object references. Anything reachable from a root is considered “live.” Anything not reachable is garbage and can be reclaimed.</p><p>Common strategies include:</p><ul><li>Mark and sweep: mark all reachable objects, then clear the rest (unreachable).</li><li>Reference counting: every object tracks how many references point to it. If the counter reaches zero, then the object is removed.</li><li>Generational GC: objects are split into old and new generations. New generation objects are scanned frequently and old generation objects are scanned rarely. New objects get into new generation and if the object survives multiple times it gets moved to the old generation.</li><li>Tri-color / concurrent marking: marks the objects concurrently with the program, minimizing the STW pauses (we’ll discuss this in detail).</li></ul><h3>The Spectrum of Memory Management</h3><h3>Manual Memory Management (C/C++)</h3><p>The programmer manually creates (malloc/new) and frees (free/delete) every place of heap memory. nothing happens automatically The best part about this is there&#39;s no background process scanning memory, so performance is entirely predictable. this is why c/c++ dominates embedded systems and os kernels.</p><h4>RAII</h4><p>in c++ there’s a thing called RAII(Resource acquisition is initialization) When an object leaves its scope, its destructor runs immediately. You don’t have to wait for a garbage collector.</p><p>for example, this is the code snippet from my container runtime project <a href="https://github.com/kaizakin/Aegis">Aegis</a> destructor gets called the moment an object goes out of scope, teardown() is a custom function which as the name suggests, tears down all the resources it has ever created.</p><p>Since the allocated resources are cleared within the object lifecycle itself, there is no need for a seperate GC.</p><pre>// constructor<br>Network::Network(pid_t pid) : pid(pid) {<br>  veth_host = &quot;veth0_&quot; + std::to_string(pid);<br> <br>  veth_container = &quot;veth1&quot;;<br>  bridge = &quot;bridge_&quot; + std::to_string(pid); <br>}<br> <br>// RAII (Resource Acquisition Is Initialization)<br>// lifecycle of resources is tied to the lifecycle of the object<br> <br>// Destructor<br>Network::~Network(){<br>  teardown(); <br>}</pre><p>This makes resource management safe and predictable, even if an exception is thrown.</p><p>Full control over memory-management has its own downsides too. Developers are clumsy and we make mistakes</p><ul><li>Use-after-free bugs: accessing memory after it’s been freed, leading to undefined behavior or exploitable security vulnerabilities.</li><li>Double-free errors: freeing the same pointer twice, corrupting the allocator’s internal bookkeeping.</li><li>Memory leaks: forgetting to free memory at all, especially in complex code paths with early returns or exceptions.</li><li>Dangling pointers: pointers that still “look valid” but point to freed or reallocated memory.</li></ul><h3>Traditional VM-Based Garbage Collection (Java/JVM)</h3><p>The runtime automatically tracks object reachability and reclaims memory nobody references anymore. The programmer never calls free.</p><p>This eliminates the whole bunch of bugs we talked about in c++. no use-after-free, no double-free, no manual leak-hunting</p><h4>High Throughput</h4><p>Say your app runs for 100 seconds.</p><ul><li>95 seconds doing actual work</li><li>5 seconds doing GC</li></ul><pre>95 / 100 = 95</pre><p>So yeah, 95% useful work.</p><p>If GC takes 20 seconds instead:</p><pre>80%</pre><p>Not great.</p><p>If your app uses something like 300 GB RAM, cleaning that all at once is slow.</p><p>Old GCs would pause everything.</p><p>New ones like G1, Shenandoah, ZGC clean in small chunks while your app keeps running. Less pause, better throughput.</p><h4>Generational GCs</h4><p>over the years upon observing how programs behave engineers noticed most objects die very soon after they’re created* This is called generational Hypothesis.</p><p>so what did engineers do? Instead of putting every object in one giant bucket they split the heap into generations.</p><pre>Young Generation <br><br>Old Generation</pre><p>every object starts with the young generation bucket. Once it survives multiple cleanup cycles it gets moved to the old generation bucket.</p><p>Now because of this clever idea garbage collector doesn’t have to check on all objects everytime. objects in young generation receive frequent cleanup cycles and objects in old generation gets rarely.</p><p>The complexity/cost side:</p><ul><li>Stop-the-world pauses: Even modern GCs pause the application at times, causing unpredictable latency spikes.</li><li>Complex tuning: Production JVMs often require careful GC and memory tuning using numerous JVM flags.</li><li>Higher memory usage: The JVM typically needs extra memory beyond live data to keep GC efficient.</li><li>Object overhead: Every Java object includes metadata, making it larger than equivalent low-level structures like C structs.</li></ul><h3>Go: The Middle Path</h3><p>Go sits between these two extremes</p><p>cool thing about GO’s is individual requests are much more predictable. let’s say a java program processes 100,000 requests/min ocassionally pauses 50–100ms due to GC these pauses some individual requests but the server gets done more work overall.</p><p>now the same program in GO processes 950,000 requests/min GC pauses are tiny (&lt;1ms) individual requests are much more predictable. this is crucial for</p><ul><li>HTTP servers</li><li>Microservices</li><li>RPC services</li></ul><p>a request suddenly taking 100 ms instead of 5 ms is often worse than serving 5% fewer requests overall. So Go intentionally sacrifices a bit of maximum throughput to keep tail latency (p99/p999) low.</p><p>Go’s authors (Pike, Griesemer, Taylor) explicitly optimized for:</p><ul><li>Low-latency over throughput: Go’s GC is optimized for short, predictable pause times instead of maximizing raw throughput, making it well-suited for backend services.</li><li>Simple to tune: Only a few knobs like GOGC and GOMEMLIMIT are usually enough, unlike the JVM&#39;s extensive GC configuration.</li><li>Concurrent collection: The GC runs alongside your program using a concurrent mark-and-sweep algorithm, minimizing stop-the-world pauses.</li><li>Non-moving GC: Objects aren’t relocated during collection, avoiding pointer updates and keeping the runtime simpler, though with some memory trade-offs.</li><li>Stack allocation via escape analysis: Go’s escape analysis pushes as many objects as possible onto the stack instead of the heap, which steps away GC involvement entirely for a large fraction of allocations. This is a big reason Go can get away with a simpler GC. it reduces the GC’s job before it even starts.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*eJy36EAvtLu5uhZjITuF2Q.png" /></figure><h3>GO’s GC Architecture (Deep Dive)</h3><h3>Memory in GO</h3><p>GO’s memory management involves inovolves both the Stack and Heap data structures. Depending on the nature and lifecycle of data, one of these structures is chosen. The compiler does Escape analysis to determine whether this variable goes to the stack or heap.</p><p>Each time a function is invoked, a new stack frame is allocated with all the function’s local variables. When the function finishes executing, its stack frame is deallocated, freeing up the memory for subsequent use. The stack is fast and provides automatic memory management. (We need garbage collector only for the heap)</p><p>Heap is a region for dynamic memory management. unlike stack heap has no order, memory in heap can be allocated and deallocated anytime. This flexibility comes with a cost of manual memory management and slower access times. Data that needs to outlive the function scope goes to the heap.</p><p>In GO the size of the heap is managed by the Garbage collector. Go’s runtime will increase the size of the heap if there’s not enough space.</p><p>Unlike some languages where the stack size must be defined at thread creation, Go starts each goroutine with a small stack, usually around 2KB, which can dynamically grow and shrink as needed. When a goroutine requires more stack space, the runtime allocates a larger contiguous stack and copies over the existing data.</p><h3>Some jargons related to GC</h3><p>GO’s garbage collection involves a concurrent tri-color mark and sweep approach. This makes GC causing no trouble to the application performance.</p><p>let’s break down each term for better understanding</p><p>Concurrent — the term concurrent signifies that the garbage collection doesn’t stop the execution of the application. traditional garbage collectors often implement a “stop-the-world” pause, during which the garbage collector examines and reclaims memory. Which cannot be ideal for some application workloads. Go’s GC, on the other hand, is designed to work concurrently with the program. Most of the garbage collector’s work is done in the background, alongside the application’s execution. This results in shorter stop-the-world pauses, improving the overall latency of Go applications.</p><p>Tri-color — the tri-color refers to the marking algorithm used by the GO’s garbage collector which considers objects (or blocks of memory) as three different colors — white, grey, black.</p><ul><li>white: objects those the garbage collector has not processed (or the GC hasn’t seen yet).</li><li>grey: objects those the gc has discovered but the descendants(objects they reference) hasn’t been processed yet</li><li>black: objects those and their descendants has been processed.</li></ul><p>Initially all objects starts white, gc starts from the roots and colors them grey as it moves, After processing all the objects referenced by a grey object it colors it black.</p><p>This clear segregation of objects based on their reachability status assists in GC identifying and reclaiming memory efficiently.</p><p>Mark-sweep: Mark phase — During this phase the GC traverses the graph from the roots as described in the tri-color marking algorithm to discover all reachable objects. This Marking phase runs concurrently with the application with the help of goroutines spawned by the garbage collector. These goroutines concurrently executes the marking work without much disturbing the application code execution.</p><p>Sweep phase — Once all reachable objects are marked (black), the sweep phase begins. During this phase, the garbage collector reclaims the memory occupied by white (unreachable) objects. This phase also happens concurrently with the execution of Goroutines, cleaning up a bit of memory at a time.</p><p>Pacer:</p><p>pacer is the manager of the Garbage collector Its job is not to mark objects, it takes care of these</p><ul><li>When should GC start?</li><li>How much marking work should happen right now?</li><li>Should the mutator (your program) help with marking?</li><li>Are we falling behind?</li><li>Are we marking too aggressively?</li></ul><h3>The Tri-color Mark-and-Sweep Algorithm</h3><p>In the context of Garbage collection the “Marking” phase involves traversing the object graph from the roots and marking every object that can be reached. Then the “Sweep” phase goes on to reclaim all the objects which are no longer referenced(unreachable).</p><p>The tri-color model visualizes objects in three colors white, grey and black. Initially all objects are marked as white denoting they are candidates for garbage collection. then the root objects are marked as grey which tells us the descendants of these objects are not processed yet. The GC successfully progresses through objects and marks the objects grey as it sees them. Once all the object referenced by a grey object has been turned grey, it gets painted to black. This process continues until there are no more grey objects.</p><p>All the white objects that are left now can be considered garbage and swept away.</p><h3>Write barriers</h3><p>Say object A is black (already scanned) and object B is white (not yet visited). The application does:</p><pre>A.field = B   // black now points to white</pre><p>If this happens _and_ nothing else points to B, the collector will never visit B again it&#39;s black, so it&#39;s done and B gets swept as garbage even though it&#39;s live and reachable via A.</p><p>The classic “hiding” scenario makes this concrete with three objects:</p><ol><li>A is black, A.field = C (grey), and B is white.</li><li>Mutator does A.field = B (steals reference, now A points to B, not C).</li><li>Mutator does C.field = nil (severs the only other path to B).</li></ol><p>Now B is reachable only through the black object A, which the GC will never rescan. B gets collected out from under a live pointer. This is a use-after-free, and in a memory-safe language like Go that&#39;s an unacceptable failure mode it would corrupt memory.</p><p>To prevent this, Go’s compiler inserts a write barrier a small piece of code that runs on every pointer write to heap memory, _but only during GC cycles_. Instead of compiling A.field = B as a raw store, the compiler emits something conceptually like:</p><pre>writePointer(&amp;A.field, B)</pre><p>where writePointer is:</p><pre>func writePointer(slot *unsafe.Pointer, ptr unsafe.Pointer) {<br>    if writeBarrierEnabled {<br>        shade(ptr)   // ensure the new pointee isn&#39;t left white so the GC rescans it<br>    }<br>    *slot = ptr<br>}</pre><p>This is what Write barrier is every pointer write goes through the write barrier when the GC cycle is running.</p><h3>The Pacing Algorithm &amp; GC Triggers</h3><p>Go’s GC doesn’t run on a timer. It runs when a heap growth target is about to be exceeded, and that target is recomputed every cycle based on live heap size and GOGC.</p><h4>The target rule (GOGC)</h4><p>At the end of each GC cycle, the runtime measures the current live heap size call it heapMarked. It then computes a target for the _next_ cycle:</p><pre>target = heapMarked + heapMarked * (GOGC / 100)</pre><p>GOGC defaults to 100, meaning: let the heap double before the next GC starts. If heapMarked is 4MB, the runtime lets the heap grow to ~8MB before triggering the next cycle.</p><p>Set GOGC=50 and you get a 1.5x target more frequent GCs, less memory, more CPU burned on collection.</p><p>Set GOGC=200 and you get 3x fewer GCs, more memory headroom, less CPU overhead.</p><p>GOGC=off disables the heap-based trigger entirely (only GOMEMLIMIT, if set, will still trigger a collection).</p><h4>GOMEMLIMIT</h4><p>The GOGC ratio-based target works fine when live heap size is roughly stable, but it has a blind spot: it says nothing about absolute memory in bytes. A container with a 512MB limit running a service whose live heap grows from 50MB to 300MB will happily let the heap target climb to 600MB under GOGC=100 and get OOM-killed by the kernel or orchestrator before Go&#39;s GC ever felt pressured to intervene.</p><p>GOMEMLIMIT introduced in (go1.19+) helps set a soft cap on total memory. Once set (via runtime/debug.SetMemoryLimit() or the GOMEMLIMIT env var), the runtime treats it as an additional, tighter target: it will run GC more frequently and aggressively as usage approaches the limit, even if the GOGC-based doubling target hasn&#39;t been reached yet.</p><h3>Downsides to Garbage collection in GO</h3><p>GO’s GC buys you memory safety and low STW pauses but that concurrency isn’t completely free. The GC steals some CPU cycles from your actual workload.</p><h4>Breakdown</h4><p>Stolen CPU (the 25% tax)</p><p>Go’s design goal is to keep the GC using no more than ~25% of available CPU during a collection cycle(this is a soft target, not a guarantee). On a machine with GOMAXPROCS=4, that can mean up to one full core&#39;s worth of throughput getting redirected into marking work during every GC cycle.</p><p>This is the fundamental trade Go made: instead of one big STW pause, you get many small background pauses spread across the entire cycle. Imagine you have 8 CPU Cores, 6 cores are doing useful application work. The other 2 are tracing the object graph. So your throughput drops by roughly 25% during that period.</p><p>Mark Assist</p><p>If your application allocates memory faster than the background mark workers can keep up the runtime doesn’t just let the heap overshoot, it forces the _allocating goroutine itself_ to pause and do mark work before its allocation is allowed to proceed. This is called mark assist.</p><p>Write Barrier</p><p>Remember the write barrier we spoke about earlier? This isn’t free even in the “good” case every pointer store during an active cycle does extra bookkeeping. Programs with pointer-heavy data structures (trees, linked lists, deeply nested structs with pointer fields) pay this cost more than programs using flat, low-pointer data layouts like arrays of value types. This is part of why idiomatic “fast” Go tends to favor []struct{} over []*struct{} fewer pointers means less write-barrier overhead and less marking work per cycle, not just less allocation.</p><p>Memory Overhead Beyond the Live Set</p><p>Go intentionally allows the heap to grow beyond the amount of memory your program is actively using. By default (GOGC=100), after a GC cycle finishes, the heap can grow to roughly twice the size of the current live data before another collection begins. This extra headroom lets the garbage collector run less frequently, reducing CPU overhead and improving throughput. Lowering GOGC reduces the heap size but causes GC to run more often, increasing CPU cost, while raising it does the opposite. Since throughput is what matters the most GO trades it for some extra memory (so it&#39;s manageable)</p><p>Scan Cost Scales With Heap Shape, Not Just Heap Size</p><p>A GC cycle’s marking cost is roughly proportional to the number of pointers it has to trace, not the number of bytes in the heap. A 1GB heap made of a few large []byte buffers scans almost instantly (few pointers to chase). A 1GB heap made of millions of small pointer-heavy structs can take dramatically longer to mark, because the collector has to walk every one of those pointer fields. This means two Go programs with identical heap sizes can have wildly different GC overhead depending purely on data structure choice</p><p>No Control Over Collection Timing</p><p>Unlike manual free() or Rust&#39;s deterministic drop-at-scope-exit, you don&#39;t get to say &quot;collect exactly now, while I have idle CPU&quot; or &quot;never collect during this latency-critical section.&quot; debug.SetGCPercent and runtime.GC() exist, but they&#39;re blunt instruments there&#39;s no per-request or per-goroutine way to defer collection. For latency-sensitive systems (trading systems, real-time bidding, anything where latency matters), this lack of fine-grained control is often the actual reason teams reach for Rust or manual pooling (sync.Pool, object reuse) instead of trusting the collector to stay out of the way during the exact millisecond it matters most.</p><h3>Profiling &amp; Detecting GC Overhead</h3><h3>gctrace</h3><p>There’s a way to watch a program’s GC behavior in real time. Setting GODEBUG=gctrace=1 before running any Go binary and the runtime prints one line per GC cycle straight to stderr no code changes, no build flags.</p><p>Here’s a sample image for better understanding</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*SikQsS7D5lQ_5tZa.png" /></figure><p>It looks dense, but every field maps directly to concepts from the pacing/tricolor sections. Let’s break it apart piece by piece.</p><ul><li>gc 3 — Third garbage collection cycle.</li><li>@0.215s — GC started 215 ms after the program began.</li><li>2% — Total runtime spent in GC so far.</li><li>0.021 + 1.2 + 0.010 ms (clock) — Wall-clock time:</li><li>0.021 ms — STW sweep termination.</li><li>1.2 ms — Concurrent marking (program keeps running).</li><li>0.010 ms — STW mark termination.</li><li>0.084 + 0.35/1.1/2.3 + 0.040 ms (cpu) — CPU time used by each phase. The middle values are CPU spent on marking by assists, background workers, and idle workers.</li><li>4 → 5 → 2 MB — Heap usage:</li><li>4 MB — Heap at GC start.</li><li>5 MB — Heap at end of marking.</li><li>2 MB — Live heap after sweeping.</li><li>5 MB goal — Heap target that triggered this GC cycle.</li><li>0 MB stacks — Memory used by goroutine stacks.</li><li>0 MB globals — Memory used by global variables scanned as GC roots.</li><li>8 P — GOMAXPROCS: 8 logical processors available for Go to run goroutines and GC work.</li></ul><h3>memprofile</h3><p>This is a built-in flag for Go’s testing tool. When you run a benchmark or a test, this flag tells Go to sample the memory allocations and write the data to a file. It tracks heap allocations. It counts both the _number of objects_ allocated and the _total bytes_ allocated. This is specifically used when writing benchmarks, when you write a new database driver or parser, you run a benchmark with this flag to see exactly how much garbage it generates per operation.</p><h3>runtime/pprof</h3><p>This is a standard library package (import &quot;runtime/pprof&quot;) that lets you instrument your actual application code to capture profiles on demand while the binary is running. Go&#39;s runtime tracks heap memory allocations continuously from the millisecond the application boots up. once the control reaches this line it writes the profile out to a file (or expose it via an HTTP endpoint using net/http/pprof).</p><p>code sample:</p><pre>package main<br> <br>import (<br>    &quot;os&quot;<br>    &quot;runtime/pprof&quot;<br>)<br> <br>func main() {<br>    f, _ := os.Create(&quot;mem_prod.out&quot;)<br>    defer f.Close()<br> <br>    // Capture the current heap state<br>    pprof.WriteHeapProfile(f)<br>}</pre><h3>alloc objects vs inuse objects</h3><p>alloc_objects - the cumulative total number of objects ever allocated at that call site since the program (or benchmark) started, whether or not they&#39;re still alive. This never decreases.</p><p>`inuse_objects` — the number of objects that are still reachable at the moment the profile was taken (i.e., they’d survive a GC). This tells you about your actual _live heap footprint_ what’s really sitting in memory right now and why.</p><h3>gcflags=”-m”</h3><p>the -gcflags=-m flag commands the compiler to print optimization decisions, specifically regarding memory allocation and function inlining</p><p>let’s build a sample code with this flag and observe what happens</p><p>sample code:</p><pre>package main<br> <br>import &quot;fmt&quot;<br> <br>type point struct{ x, y int }<br> <br>func makeOnStack() point {<br> p := point{1, 2}<br> return p // returned by value — safe to stack-allocate<br>}<br> <br>func makeOnHeap() *point {<br> p := point{1, 2}<br> return &amp;p // pointer escapes — must go to heap<br>}<br> <br>func main() {<br> a := makeOnStack()<br> b := makeOnHeap()<br> fmt.Println(a, b)<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*7DNGu0vp3X9F_kwz.png" /></figure><p>`can inline makeOnStack` / `can inline makeOnHeap` the compiler decided both functions are small/simple enough to inline directly into their call sites, rather than emitting real function calls. This happens _before_ escape analysis runs, and it changes the analysis entirely there’s no longer a function boundary to reason about, just one flattened body.</p><p>inlining call to makeOnStack/makeOnHeap confirms the substitution actually happened(I mean the compiler literally replaces the function call with a copy of the function&#39;s body)</p><p>rest of the lines in the output explains itself on its own.</p><h3>Code Patterns to Minimize GC Overhead</h3><h3>Pre-allocating Slices and Maps</h3><p>Bad: unbounded growth</p><pre>func buildIDs(n int) []int {<br>    var ids []int<br>    for i := 0; i &lt; n; i++ {<br>        ids = append(ids, i)<br>    }<br>    return ids<br>}</pre><p>Every time the backing array runs out of room, append allocates a new, larger array and copies everything over.</p><p>Good: pre-allocate with known capacity</p><pre>func buildIDs(n int) []int {<br>    ids := make([]int, 0, n)<br>    for i := 0; i &lt; n; i++ {<br>        ids = append(ids, i)<br>    }<br>    return ids<br>}</pre><p>One allocation. append just writes into existing capacity until it&#39;s full.</p><h3>Reusing Memory with sync.Pool</h3><p>Imagine you have a hot path in your code and your server handles 100,000 requests per second. Every request allocates a buffer and GC frees it. so for 100k requests that’s 100k objects become garbage GC has to clean 100k buffers.</p><p>instead of throwing buffers away you can use sync.Pool to reuse them.</p><p>sample code:</p><pre>var bufPool = sync.Pool{<br>    New: func() any {<br>        return new(bytes.Buffer)<br>    },<br>}<br> <br>func handleRequest(w io.Writer, data []byte) error {<br>    buf := bufPool.Get().(*bytes.Buffer)<br>    buf.Reset()<br>    defer bufPool.Put(buf)<br> <br>    buf.Write(data)<br>    // ... transform, encode, whatever ...<br>    _, err := w.Write(buf.Bytes())<br>    return err<br>}</pre><p>`New` is only called when the pool is empty</p><h3>Avoiding Pointers in Map Keys and Values</h3><p>The GC’s mark phase has to scan every pointer-containing object to trace what it points to. For a map, that means walking every bucket if the key or value type contains a pointer.</p><pre>// GC must scan every bucket, every entry, to find and trace the *User pointers<br>m := make(map[string]*User)</pre><p>If m has 5 million entries, that&#39;s 5 million pointers the GC has to trace on every mark cycle, even if nothing in the map changed. This is a classic source of GC-pause blowup</p><p>The fix: use pointer-free key and value types. Go’s runtime marks a type as pointer-free via its type descriptor (kind &amp; kindNoPointers), and for a map where both key and value are pointer-free, the entire bucket array can be skipped during scanning not just skipped-per-entry, skipped entirely.</p><pre>// GC-invisible: no pointers in key or value, so buckets are never scanned<br>m := make(map[uint64]User) // User is a flat struct: no pointer/slice/map/string/interface fields</pre><p>If User itself has to contain pointer-like fields (strings, slices, interfaces), you can still flatten:</p><pre>type User struct {<br>    ID    uint64<br>    Name  [32]byte // instead of string, if fixed-width is acceptable<br>    Score float64<br>}</pre><h3>Strings vs. Byte Slices</h3><p>Strings in Go are immutable every concatenation allocates a new backing array and copies both operands in.</p><pre>// Bad: O(n²) allocations across the loop<br>func buildCSV(rows [][]string) string {<br>    var out string<br>    for _, row := range rows {<br>        for _, field := range row {<br>            out += field + &quot;,&quot;<br>        }<br>        out += &quot;\n&quot;<br>    }<br>    return out<br>}</pre><p>Each += allocates a new string sized for the combined length. For n concatenations, you get roughly n allocations with steadily growing copy sizes quadratic total work.</p><h4>Fix 1: strings.Builder</h4><pre>func buildCSV(rows [][]string) string {<br>    var b strings.Builder<br>    b.Grow(estimateSize(rows)) // optional, but avoids Builder&#39;s own regrowth<br>    for _, row := range rows {<br>        for _, field := range row {<br>            b.WriteString(field)<br>            b.WriteByte(&#39;,&#39;)<br>        }<br>        b.WriteByte(&#39;\n&#39;)<br>    }<br>    return b.String()<br>}</pre><p>strings.Builder accumulates into an internal []byte once, at the end, via a zero-copy cast(Go simply creates a string header pointing at the same bytes) no final copy.</p><h4>Fix 2: zero-copy conversions in hot paths (unsafe)</h4><p>Normally, string(byteSlice) and []byte(str) both copy, because the compiler has to preserve the immutability guarantee of string and the mutability of []byte. If you _know_ the byte slice won&#39;t be mutated after conversion (or the string won&#39;t outlive the buffer), you can skip the copy:</p><pre>import &quot;unsafe&quot;<br> <br>// []byte -&gt; string, zero-copy (Go 1.20+)<br>func bytesToString(b []byte) string {<br>    return unsafe.String(unsafe.SliceData(b), len(b))<br>}<br> <br>// string -&gt; []byte, zero-copy — CAUTION: resulting slice must not be written to<br>func stringToBytes(s string) []byte {<br>    return unsafe.Slice(unsafe.StringData(s), len(s))<br>}</pre><p>There’s a catch: This breaks the GO’s memory model. If you convert a string to []byte this way and then mutate the slice, you&#39;ve mutated a value the runtime and other code assume is immutable. you might run into potential data races, corrupted strings, or worse if the string was a compile-time constant living in read-only memory. Use this only in narrow, well-audited hot paths (e.g., serialization code where you fully control the lifetime), never as a general substitute for strings.Builder.</p><h3>Summary &amp; Best Practices</h3><h3>Don’t prematurely optimize</h3><p>Every technique in this post pre-allocation, sync.Pool, pointer-free maps, unsafe string conversions trades readability or safety margin for throughput. That trade is only worth making where it matters, and &quot;where it matters&quot; is not a guess.</p><p>The discipline is: write clean code first, profile second, optimize third.</p><ul><li>Write clean code first. Use idiomatic Go plain slices, plain maps, and simple string concatenation unless you’re in a hot loop. Most of your code won’t be performance-critical, so keeping it clear and maintainable is usually the right choice.</li><li>Profile second. Use pprof (via go tool pprof, runtime/pprof) to find where CPU time and allocations actually go. Instead of guessing what&#39;s expensive, measure it. Check GODEBUG=gctrace=1 as well to see if GC is even a bottleneck before trying to optimize around it.</li><li>Optimize third, and only the hot path. Apply techniques like pre-allocation, pooling, or reducing pointer usage only where profiling shows they matter not across the entire codebase. A map[string]*User used once during startup doesn&#39;t need to become a map[uint64]User. The same structure in a request path with millions of entries is a different story.</li></ul><p>The main reason for following this approach is that optimizations like sync.Pool or unsafe conversions often trade readability or safety for performance. If you haven&#39;t measured a real bottleneck, that trade-off usually isn&#39;t worth making.</p><h3>Cheatsheet</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*wpyF3LkqAeOYvXlhSieS3w.png" /></figure><p>cheers ^-^</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1314129c5468" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless Is Great, Until You Let Strangers Run Code on Your Machines]]></title>
            <link>https://medium.com/@karthikbalasubramanian08/serverless-is-great-until-you-let-strangers-run-code-on-your-machines-7f6a948a8ed1?source=rss-110e0af94afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f6a948a8ed1</guid>
            <category><![CDATA[knative]]></category>
            <category><![CDATA[gvisor]]></category>
            <category><![CDATA[unikernel]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Karthik Balasubramanian]]></dc:creator>
            <pubDate>Sun, 03 May 2026 16:43:38 GMT</pubDate>
            <atom:updated>2026-05-03T16:43:38.926Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pFTWEnuNGePXdT8cHYjYqA.png" /></figure><p>Here is something I find genuinely underappreciated in conversations about cloud infrastructure. Everyone talks about how fast serverless is, how it scales to zero, how you only pay for what you use. All of that is true. But there is a much harder question sitting underneath all of it that almost nobody asks out loud.</p><p>What happens when the code running on your infrastructure is not yours?</p><p>I am not talking about a bug in your own functions. I am talking about a cloud provider scenario, where a stranger submits arbitrary code, you package it up, and you run it on the same physical machine as twenty other strangers’ code. That is the actual promise of public serverless. And the moment you start pulling on that thread, you realize that the foundation most people assume is solid is actually pretty shaky.</p><p>A team at Nubis PC published a paper on exactly this problem, and their solution involves a technology called unikernels that I think deserves way more attention than it gets. Let me walk you through the whole thing.</p><p>research paper link: <a href="https://dl.acm.org/doi/10.1145/3642977.3652096">https://dl.acm.org/doi/10.1145/3642977.3652096</a></p><h3>First, What Even Is Serverless and Why Containers?</h3><p>Let me set the stage properly because the security problem only makes sense once you understand the plumbing underneath.</p><p>Serverless, at its core, is about breaking your application into small independent functions. Each function waits for a trigger, like an incoming HTTP request, wakes up, does its one job, and then goes back to sleep. The platform scales it up when there is demand and scales it all the way to zero when there is not. No idle servers burning money, no capacity planning headaches.</p><p>The way these functions get packaged and shipped is through containers. A container bundles your code with everything it needs, libraries, runtime, config, into one neat image. You can start a container in milliseconds. You can run hundreds of them on a single machine. Docker, containerd, runc these are the standard tools in this world, all governed by the OCI (Open Container Initiative) spec.</p><p>Containers are fast and efficient. Great. But here is the catch.</p><p>Containers share the host OS kernel. Every container on the same machine is talking to the same underlying kernel. The kernel manages memory, hardware access, process scheduling, everything at the lowest level. Containers get isolation through namespaces (which separate things like the process tree, filesystem view, and network) and cgroups (which limit CPU and memory consumption), but they are not running on separate kernels. They are just different “views” of the same kernel.</p><blockquote><em>I’ve written a blog about building a container runtime from scratch </em><a href="https://kaizakin.site/blogs/container-runtime-from-scratch"><em>https://kaizakin.site/blogs/container-runtime-from-scratch</em></a><em> refer this for more information.</em></blockquote><p>Think of it like living in an apartment building. Each tenant has their own unit, their own locked door. But the plumbing, the electrical grid, the building’s foundation that is all shared. If someone floods their unit badly enough, it can become your problem too.</p><p>So what? CVEs related to container escapes and privilege escalation show up in security advisories regularly. A malicious or poorly written container can, under the right exploit, break out of its isolation and touch the host or other containers. For internal enterprise deployments where you trust your own developers, that risk is manageable. For a public cloud where literally anyone can submit code that risk is not manageable at all.</p><h3>Knative’s Honest Admission</h3><p>Knative is one of the most widely used serverless frameworks in the cloud-native ecosystem. It sits on top of Kubernetes (K8s) and handles all the serverless-specific concerns: auto-scaling, scale-to-zero, request routing, lifecycle management. If you are running serverless workloads on Kubernetes, there is a good chance Knative is involved.</p><p>Here is what I respect about the Knative project: they are honest about their limitations. Their threat model documentation flat out states that they assume a single tenant per cluster. They do not consider themselves secure for multi-tenant scenarios where untrusted users are submitting arbitrary workloads.</p><p>That is a huge constraint. It means any provider that wants to use Knative for a real public serverless product needs to give every tenant their own dedicated cluster, which is expensive and operationally painful.</p><p>The mitigation Knative points to is enhanced isolation through sandboxed container runtimes. Which brings us to the two big options everyone reaches for.</p><p>FYI, this is what AWS lambda does<br>read<br><a href="https://firecracker-microvm.github.io/">https://firecracker-microvm.github.io/</a><br><a href="https://aws.amazon.com/blogs/compute/building-multi-tenant-saas-applications-with-aws-lambdas-new-tenant-isolation-mode/">https://aws.amazon.com/blogs/compute/building-multi-tenant-saas-applications-with-aws-lambdas-new-tenant-isolation-mode/</a></p><h3>gVisor and Kata Containers: Good Ideas With Real Costs</h3><p>So the obvious move is to wrap your containers in something with stronger isolation. Two technologies dominate this space.</p><p>Kata Containers wraps each container inside a lightweight microVM. The container gets its own guest kernel running inside a virtual machine. Anything that container does, including system calls, is contained inside that VM. A container escape inside a Kata sandbox does not reach the host. The isolation is real.</p><p>The cost? Spinning up a microVM takes time and memory. You are booting a full guest OS for every container. For long-running services, that startup cost outweighs the lifetime of the container. For serverless cold starts, where the whole point is to respond to a trigger in under a second, booting a VM is painful.</p><p>gVisor takes a different angle. Instead of a full microVM, it inserts a user-space kernel between the container and the host OS. All syscalls made by the container, the read(), write(), socket(), mmap() calls that every program makes constantly, get intercepted by gVisor&#39;s user-space kernel (called Sentry) rather than going directly to the host kernel. If a container tries to exploit a kernel vulnerability through a syscall, gVisor catches it first.</p><p>The isolation is lighter-weight than Kata, but still meaningful. The cost is syscall interception overhead, which adds latency to every operation the container performs.</p><p>Both of these are legitimate solutions. Production-grade, widely deployed, battle-tested. But the researchers identified two problems that neither of them actually fixes.</p><p>Problem one: performance. The benchmarks are not kind. Both gVisor and Kata Containers roughly double the cold-start latency compared to plain containers. At the 99th percentile (which is what real users actually experience when things are slightly busy), gVisor hits 2.23 seconds and Kata Containers hits 3.91 seconds. Plain runc sits at 1.25 seconds. In serverless terms, that difference matters enormously.</p><p>Problem two: the internal boundary. This one is more subtle and I think it is the more interesting insight in the paper.</p><p>In Knative’s architecture, every function pod has two containers running inside it. One is the user container, which holds the function code. The other is the queue-proxy, which is Knative’s own infrastructure component. It handles request routing to the function, talks to the autoscaler, manages pod lifecycle signals. The queue-proxy is platform code, not user code.</p><p>When you sandbox a Knative pod with Kata Containers or gVisor, what you get is one sandbox with both containers inside it. The queue-proxy and the untrusted user function are sitting in the same isolated environment, separated from the host, but not separated from each other. If the user’s code compromises something inside that sandbox, the queue-proxy is reachable. You’ve improved the external boundary but left the internal one completely unaddressed.</p><p>That is the gap this paper actually sets out to close.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XFto26fFW0asIm1R7DWfGQ.png" /></figure><h3>Okay, So What Even Are Unikernels?</h3><p>Before I get into what the researchers built, let me explain unikernels properly, because I think most people have a vague sense that they are “lightweight VMs” and leave it at that. The actual concept is more interesting.</p><p>Think about what a general-purpose operating system has to do. It needs to support thousands of different applications. It needs drivers for hardware it might never actually have. It ships with a scheduler that handles dozens of concurrent processes, a filesystem stack that supports a dozen different formats, a networking stack that covers every protocol you can think of. It has a user management system, a permissions model, init systems, service managers. A minimal Ubuntu install is still over a gigabyte of code.</p><p>Your serverless function needs maybe 0.1% of that. It needs to open a socket, read a request, compute something, write a response. That is it.</p><p>A unikernel is what you get when you take that function and compile it together with only the specific OS components it actually needs into a single self-contained image. No unused drivers. No multi-user support (it is a single-application VM, why would there be multiple users). No layers. Just your application and the exact kernel primitives it requires, compiled together into one binary that boots directly into your app.</p><p>The result runs as a VM, so you get hardware-enforced isolation from everything else on the host. But the image is tiny, the attack surface is minimal (because there is almost nothing there to attack), and the boot time is in the milliseconds range because there is barely anything to initialize.</p><p>The tradeoff historically has been that unikernels are a pain to integrate with standard tooling. The container ecosystem has well-defined standards, OCI images, container runtimes, Kubernetes CRI. Unikernels have not traditionally spoken that language. That is exactly what the researchers decided to fix.</p><h3>urunc: Teaching Kubernetes to Speak Unikernel</h3><p>The tool they built is called urunc (unikernel container runtime). The goal is simple: let unikernels participate in a standard Kubernetes cluster without requiring any changes to the orchestration layer above.</p><p>urunc is an OCI-compliant low-level container runtime. It receives the same kind of requests that runc would receive, a container spec, a filesystem bundle, a set of annotations. Based on annotations on the container image, urunc decides what to do. If the annotation says this is a unikernel, urunc handles it by spawning the unikernel as a VM. If the annotation says this is a regular container, urunc passes it off to runc like normal.</p><p>This is the key architectural decision that makes everything else work.</p><blockquote><em>As an engineer, you should appreciate what this gives you: a single container runtime that can manage both plain containers and VM-isolated unikernels transparently, within the same pod, without the orchestration layer knowing or caring.</em></blockquote><p>Because urunc can handle both types within the same pod, you can now configure a Knative function pod so that the queue-proxy runs as a plain runc container while the user function runs as a unikernel VM. They co-exist in the same pod, they can still communicate over the pod’s local network, but the user’s code is now inside a hardware-isolated VM with a minimal attack surface. The queue-proxy is genuinely separated from the untrusted function, not just logically but at the hypervisor boundary.</p><p>This is what neither gVisor nor Kata Containers achieved. Both of those sandbox the entire pod. urunc sandboxes only the part that needs sandboxing, and it uses a much leaner runtime environment to do it.</p><p>Because of this, unikernels provided insansely low startup times</p><p>In a standard setup:</p><ul><li>Proxy gets Request -&gt; Wait for standard Linux Container to boot (Slow) -&gt; Send via Localhost -&gt; Process.</li></ul><p>In the urunc setup:</p><ul><li>Proxy gets Request -&gt; Unikernel is already “Ready/Listening” (Fast) -&gt; Send via Memory Pipe -&gt; Process.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F9B5sAj6sNqtfbTR_PXebg.png" /></figure><h3>The Numbers</h3><p>Let me just walk through what the benchmarks actually showed, because this is where the rubber meets the road.</p><p>Hardware: AMD EPYC 7502P (32 cores), 128GB RAM, bare metal. Software: Kubernetes 1.28, Knative 1.12, Ubuntu 20.04. Runtimes compared: runc, gVisor, Kata Containers, urunc. The benchmark tool is kperf, Knative’s own benchmarking utility, which they customized to measure cold-start service response latency accurately.</p><p>Single instance, cold start:</p><p>runc averages around 1.2 seconds. urunc matches it almost exactly. gVisor and Kata Containers both sit in the 2 to 2.5 second range. At the 99th percentile: runc and urunc are identical at 1.25 seconds. gVisor is at 2.23 seconds. Kata Containers is at 3.91 seconds.</p><p>Scaling to multiple instances:</p><p>Up to 300 concurrent services, runc and urunc are indistinguishable. gVisor adds roughly 1.5 seconds of average overhead. Kata Containers starts degrading past 125 instances and above 200 instances shows more than 10x the latency of urunc. At 200+ concurrent services, Kata Containers is essentially unusable for serverless workloads.</p><p>Pushing to 500 instances:</p><p>Only runc and urunc were tested at this scale. Both spawned a comparable number of actual instances (some drop-off occurs due to cluster limits, not the runtime itself). urunc maintained low response latency even with 450 instances running simultaneously. Same memory and CPU footprint as plain runc, with VM-level isolation on the user container.</p><p>The “so what” here is not subtle. You get genuine hardware isolation, you close the internal queue-proxy vulnerability, and you pay zero performance cost compared to running completely unsandboxed containers. That is the trade-off that neither gVisor nor Kata Containers could offer.</p><h3>What This Actually Means</h3><p>unikernels have been “promising” for a while now. The research community has known they have good properties for serverless workloads. The gap has always been practical integration, nobody wants to throw away their entire container toolchain to use a different paradigm.</p><p>What this work demonstrates is that you do not have to. urunc slots into the existing Kubernetes CRI layer, speaks OCI, works with standard Knative, and requires no changes to how you orchestrate or deploy. The unikernel-specific stuff is entirely at the container runtime level, which is the right place for it.</p><p>There are still open questions. The benchmark uses a simple HTTP reply function, not a compute-intensive workload. Real serverless functions do database calls, machine learning inference, image processing. How unikernels behave under those workloads at scale is not covered here, and the researchers acknowledge they want to look at hardware acceleration next.</p><p>But the core claim is that unikernels can enable genuine multi-tenancy on Knative without sacrificing performance is backed by solid numbers. And the design insight about separating the queue-proxy from the user function is something that every Knative deployment dealing with untrusted workloads should be thinking about.</p><p>That is all from my side on this one.</p><p>Worth keeping an eye on urunc as it develops.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f6a948a8ed1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dependency resolving in Package Managers: pacman vs apt vs dnf]]></title>
            <link>https://medium.com/@karthikbalasubramanian08/dependency-resolving-in-package-managers-pacman-vs-apt-vs-dnf-deb1e43d6505?source=rss-110e0af94afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/deb1e43d6505</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[dnf]]></category>
            <category><![CDATA[arch-linux]]></category>
            <category><![CDATA[pacman]]></category>
            <category><![CDATA[package-manager]]></category>
            <dc:creator><![CDATA[Karthik Balasubramanian]]></dc:creator>
            <pubDate>Tue, 17 Feb 2026 17:17:03 GMT</pubDate>
            <atom:updated>2026-02-17T17:17:03.715Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/637/1*F6rGrEUVPIbHTeB5vAVhVA.png" /></figure><p>Installing one package isn’t isolated</p><pre>install nginx</pre><p>it actually needs:</p><pre>nginx → openssl → libc<br>      → pcre<br>      → zlib</pre><p>so software deps form a graph, not a list.</p><p>humans can’t resolve graphs reliably.</p><p>that’s why package managers exist.</p><p>what package managers do:</p><p>given:</p><ul><li>requested package</li><li>repo metadata (deps, versions, conflicts)</li></ul><p>find:</p><p>valid install set satisfying all constraints</p><p>this is dependency graph + constraint solving.</p><p>To understand this more we need to understand what is a SAT solver</p><p>SAT = Boolean satisfiability problem</p><p>given:</p><ul><li>variables(A, B, C…)</li><li>logical contraints (AND, OR, NOT)</li></ul><p>find:</p><p>assignment of true/false so that the whole formula becomes TRUE</p><p>Example:</p><pre>(A OR B) AND (NOT A OR C)</pre><p>assignment for this problem would be A=0, B=1, C=0</p><p>since formula is TRUE it’s a SAT</p><p>UNSAT example -&gt; A AND (NOT A)</p><p>this formula is impossible</p><p>SAT is used in many areas:</p><ul><li>package deps</li><li>scheduling</li><li>routing</li><li>resource allocation</li></ul><p>how this SAT works in package managers:</p><pre>nginx → openssl1.1<br>curl  → NOT openssl1.1<br>system → openssl1.1 OR openssl1.0</pre><p>for this problem the variables and constraints are,</p><p>Variables = N, O1, O0, C</p><blockquote><em>O1 = openssl1.1</em></blockquote><blockquote><em>O0 = openssl1.0</em></blockquote><p>constraints = N → O1, C → NOT O1, O1 OR O0</p><p>solver input form:</p><p>CNF(Conjunctive Normal Form) (AND of OR classes) — this you might have studied in your CS degree (i slept in class lol 🥲)</p><pre>The following packages will be upgraded:<br>openssl<br>The following will be removed:<br>curl</pre><pre>(A OR B)<br>(NOT A OR C)<br>(D OR NOT C)</pre><p>which assignment satisfies all the classes?</p><p>N=1, O1=1, C=0, O0=0 -&gt; this satsfies the so solution exists</p><blockquote><em>1 = installed / true</em></blockquote><blockquote><em>0 = not installed / false</em></blockquote><h3>How solver searches (intuition)?</h3><pre>A = true?<br>      check constraints<br>B = true?<br>      conflict<br>backtrack<br>B = false<br>continue</pre><p>many systems use SAT:</p><ul><li>compilers</li><li>schedulers</li><li>verification</li><li>circuit design</li><li>AI planning</li></ul><p>so now you know dependency conflict isn’t just a random error it’s a UNSAT state.</p><p>now let’s come back to understand the solver differences in pacman, dnf and apt.</p><h3>1. Pacman</h3><p>pacman’s philosophy is very simple,</p><ul><li>simple</li><li>rolling</li><li>minimal solver</li></ul><p>Behavior:</p><ul><li>assumes repo is internally consistent</li></ul><p>which means maintainers ensure all packages in the repo already work together,</p><p>so at any moment repo snapshot = one consistent universe</p><p>if they update any package they have to rebuild all other packages that depends on this and make sure a <strong>exactly one valid dependency graph</strong>.</p><ul><li>installs latest compatible versions</li><li>fewer complex version branches</li></ul><p>which means Arch repo usually has:</p><p>openssl 3.0 ONLY</p><p>Older removed.</p><p>So dependency graph has single version per node</p><p>That massively simplifies solving.</p><p>Pacman does <strong>less SAT solving</strong> than apt/dnf.</p><p>That’s why Arch repos must stay consistent.</p><pre>pacman -S nginx</pre><p>when you do this, Pacman does:</p><ol><li>read nginx deps</li><li>look up repo versions</li><li>install those exact versions</li></ol><p>No branching. No alternatives. No SAT solving.</p><p>So effectively:</p><p>install latest deps from repo</p><h3>2. apt(Debian/ubuntu)</h3><p>Philosophy:</p><ul><li>stability</li><li>multiple versions</li><li>complex upgrades</li></ul><p>APT uses a real dependency resolver:</p><ul><li>handles version ranges</li><li>suggests removals</li><li>suggests downgrades</li><li>proposes solutions</li></ul><pre>apt install nginx</pre><p>when you try to install nginx in apt, tis is what apt does.</p><pre>The following packages will be upgraded:<br>openssl<br>The following will be removed:<br>curl</pre><p>APT is solving a constraint satisfaction problem.</p><h3>3. dnf (Fedora/RHEL)</h3><p>Philosophy:</p><ul><li>correctness + modular repos</li><li>enterprise lifecycle</li></ul><p>DNF uses <strong>libsolv</strong></p><p>This is a full SAT solver.</p><p>It can handle:</p><ul><li>modular streams</li><li>optional deps</li><li>rich conflicts</li><li>multiple repos</li></ul><p>So DNF resolution is mathematically strongest.</p><p>given package nodes, dependency edges, version constraints, conflicts</p><p>package managers has to find a valid install set.</p><p>other package mangers like npm, yarn, cargo, pip solves similar problems</p><p>after resolving package manager creates a topoloically sorted plan,</p><p>like this,</p><pre>install openssl<br>install pcre<br>install zlib<br>install nginx</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=deb1e43d6505" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understand Arch manual with me]]></title>
            <link>https://medium.com/@karthikbalasubramanian08/understand-arch-manual-with-me-ef23ee97f850?source=rss-110e0af94afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef23ee97f850</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[arch-linux]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[kernel]]></category>
            <category><![CDATA[shell]]></category>
            <dc:creator><![CDATA[Karthik Balasubramanian]]></dc:creator>
            <pubDate>Wed, 10 Dec 2025 16:55:07 GMT</pubDate>
            <atom:updated>2025-12-10T17:07:53.105Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7mZvOP5Ax1600Tz2JO2oPw.png" /></figure><blockquote><em>Disclaimer: I used my natural language throughout this blog most of it are written at my free time and maybe i have missed some points or i might have blabbered something</em></blockquote><p>So sorry for that in advance :)</p><h3>Let’s start with the basics why do we need a bootable USB for installing a operating system to a machine?</h3><p>Computer always boots from some form of storage they look for a bootloader (like GRUB, Windows Boot Manager, etc) to start the OS.</p><p>since the system doesn’t have that, we need a external medium a bootable USB in this case that contains a bootable OS installer and a bootloader to kickstart the process.</p><ul><li>when your PC powers on it starts executing a set of predefined instructions from (UEFI/BIOS)</li><li>it looks for a thing to ‘boot from’</li><li>if it doesn’t find anything it asks ‘are you playin w me??’</li></ul><blockquote><em>UEFI is a modern replacement for BIOS, offering a more secure and feature-rich boot process</em></blockquote><h4>SO what does a BIOS/UEFI needs</h4><ul><li>a boot sector</li><li>a bootloader</li><li>a filesystem it can parse</li><li>and an executable image to load.</li></ul><p>So we give it an external media that contains all of these,</p><ul><li>A boot sector(MBR or EFI)</li><li>a minimal bootloader (like GRUB)</li><li>the ISO contents</li></ul><blockquote><em>A boot sector is the first sector of a storage device containing instructions to start the computer’s operating system. MBR (Master Boot Record) is a traditional boot sector that holds the bootloader code and a partition table to manage disk partitions, used with older BIOS systems. EFI (Extensible Firmware Interface), now more commonly UEFI (Unified Extensible Firmware Interface), is a modern replacement for BIOS that uses a different boot process, often with a GUID Partition Table (GPT) and an EFI System Partition to manage the boot process.</em></blockquote><p>NOTE: We’re going to learn about the installation process that makes arch users brag (I use Arch BTW).<br>there is another popular way of installation using archinstall script that takes care of some heavy lifting for you.</p><h4>Few things about Arch</h4><ol><li>Archlinux is one of those few distros that is developed from the ground up unlike some famous distros ubuntu, fedora for example which are forks of debian and red hat respecively.</li><li>Archlinux should run on any x86_64 architecture machine and it will take 2gigs of disk space after a successfull installation.</li></ol><p>Now you may ask how come archlinux takes only 2 gigs of space?</p><ul><li>Ubuntu default install is like 10–12GB.</li><li>Windows? Bro it eats 20–30GB like snacks.<br>These OSes thinks our users probably need this so let’s ship it.<br>This makes the base install bloated asf.</li></ul><p>Here’s what makes Arch different</p><ul><li>It only gives you a Kernel, Shell, pacman(package manager in Arch), a few essentials and asks you to install whatever you want to your liking.<br>Basically bro do whatever you wanna do with your system we don’t make any opinions.</li></ul><p>This is one of the reasons people like Arch.</p><h3>Now let’s move to the steps after plugging in your bootable USB to the target device.</h3><p>You will be logged in on the first <a href="https://en.wikipedia.org/wiki/Virtual_console">virtual console</a> as the root user, and presented with a <a href="https://wiki.archlinux.org/title/Zsh">Zsh</a> shell prompt.</p><blockquote><em>A virtual console (VC) — also known as a virtual terminal (VT) — is a conceptual combination of the keyboard and display for a computer </em><a href="https://en.wikipedia.org/wiki/User_interface"><em>user interface</em></a><em>. It is a feature of some </em><a href="https://en.wikipedia.org/wiki/Unix-like"><em>Unix-like</em></a><em> </em><a href="https://en.wikipedia.org/wiki/Operating_system"><em>operating systems</em></a><em> such as </em><a href="https://en.wikipedia.org/wiki/Linux"><em>Linux</em></a><em>, </em><a href="https://en.wikipedia.org/wiki/BSD"><em>BSD</em></a><em>, </em><a href="https://en.wikipedia.org/wiki/Illumos"><em>illumos</em></a><em>, </em><a href="https://en.wikipedia.org/wiki/UnixWare"><em>UnixWare</em></a><em>, and </em><a href="https://en.wikipedia.org/wiki/MacOS"><em>macOS</em></a><em> in which the </em><a href="https://en.wikipedia.org/wiki/System_console"><em>system console</em></a><em> of the computer can be used to switch between multiple virtual consoles to access unrelated user interfaces. Virtual consoles date back at least to </em><a href="https://en.wikipedia.org/wiki/Xenix"><em>Xenix</em></a><em> and </em><a href="https://en.wikipedia.org/wiki/Concurrent_CP/M"><em>Concurrent CP/M</em></a><em> in the 1980s.</em></blockquote><p>Default keyboard layout will be in US<br>other Available layouts can be listed with:</p><pre>localectl list-keymaps</pre><p>to select a keyboard layout, pass its name to LoadKeys</p><pre>loadkeys de-latin1</pre><pre>setfont ter-132b</pre><p>This command is to set a big sized font in the terminal in-case if you feel the terminal font is too small to see.</p><pre>cat /sys/firmware/efi/fw_platform_size</pre><p>This command is to verify the boot mode.</p><ul><li>If the command returns 64, the system is booted in UEFI mode and has a 64-bit x64 UEFI.</li><li>If the command returns 32, the system is booted in UEFI mode and has a 32-bit IA32 UEFI. While this is supported, it will limit the boot loader choice to those that support mixed mode booting.</li><li>If it returns No such file or directory, the system may be booted in <a href="https://en.wikipedia.org/wiki/BIOS">BIOS</a> (or <a href="https://en.wikipedia.org/wiki/Compatibility_Support_Module">CSM</a>) mode.</li></ul><h4>Next set of commands are related to connecting to the internet.</h4><pre>ip link</pre><p>Linux exposes all network interfaces (physical + virtual) through the netlink subsystem.</p><blockquote><em>Netlink is a communication system that lets the kernel and user-space exchange networking information.</em></blockquote><blockquote><em>It’s like a messaging API built into Linux</em></blockquote><blockquote><em>kernel can’t read commands like set eth up, netlink is a communication channel between user-space tools (like ip, ifconfig, NetworkManager) and the kernel networking code.</em></blockquote><blockquote><em>It’s dangerous to let user space programs to change kernel memory</em></blockquote><blockquote><em>netlink standardizes them it’s literally a socket-based protocol.</em></blockquote><p>It’s the command that asks the kernel for status of all of the network interfaces.<br>ip link is the command that shows and controls network interface on your system.</p><p>It’s basically the “interface management” part of the ip command.</p><p>if you run this command you’ll see a output sth like</p><ul><li>loopback</li><li>ethernet</li><li>wifi</li><li>virtual bridges</li><li>docker interfaces</li><li>tunnels</li><li>wireguard interfaces</li></ul><p>you can also perform certain actions like bringing an interface up and down.</p><pre>ip link set wlan0 up</pre><pre>ip link set eth0 down</pre><pre>rfkill</pre><p>There are bunch of radio transmitters in our system:</p><ul><li>Wi-Fi</li><li>Bluetooth</li><li>NFC (rare)</li><li>WWAN / mobile broadband</li><li>Airplane mode toggles</li><li>Hardware switches</li></ul><p>Each of these can be soft-blocked(by software) or hard-blocked(by a physical switch or firmware).</p><p>rfkill is a debugging + control tool to manage wireless radio devices on Linux.</p><p>rfkill list lists all radio devices<br>rfkill unblock all unblocks all radios<br>rfkill unblock wifi unblock only Wi-Fi</p><p>connect to wifi using iwctl</p><ul><li>iwctl is the command line utility to talk to the Wi-Fi daemon.</li><li>nmcli can be used if your device uses NetworkManger to manage Wi-Fi</li></ul><pre>ping</pre><p>you know what ping does.</p><h3>Next up: Changing time and date</h3><pre>timedatectl</pre><p>This command is used to view and change the system date, time, and time-related settings.</p><p>it can be achieved by</p><pre>sudo timedatectl set-time &quot;2025-12-01 21:30:00&quot;</pre><pre>sudo timedatectl set-time &quot;2025-12-01&quot;</pre><pre>sudo timedatectl set-timezone Asia/Kolkata</pre><h3>Partition the disk</h3><p>In linux everything is treated as a folder.<br>disks are assigned to a <a href="https://wiki.archlinux.org/title/Block_device">block device</a> such as /dev/sda, /dev/nvme0n1 or /dev/mmcblk0</p><pre>fdisk -l</pre><p>this command is used to view the disks and partitions<br>alternative popular command for the similar use case would be lsblk</p><p>RAID mode shouldn’t be enabled in your system (coz RAID support in linux is poor).<br>If you’re unsure what raid is. take a read at this</p><pre>https://x.com/kaizakinn/status/1995538976409874904?s=20</pre><p>Common Example:</p><pre>sudo fdisk /dev/sda</pre><p>inside fdisk you’ll get options like</p><ul><li>p = print partitions</li><li>n = new partition</li><li>d = delete partition</li><li>w = write changes</li><li>q = quit without saving</li></ul><p>as per Arch manual You’ll be told to create a swap partition in this step<br>If you’re unsure what swap is. have a read</p><pre>https://x.com/kaizakinn/status/1991753444403695900?s=20</pre><h3>Format partitions:</h3><p>Newly created partitions has to be formatted with an appropriate file system<br>we format ext4 file system on the main partition coz its the default file system for linux.</p><pre>mkfs.ext4 /dev/_root_partition_</pre><p>mkfs stands for make file system.</p><p>swap partition has to be formatted as well,</p><pre>mkswap /dev/_swap_partition</pre><p>mkswap stands for make swap.</p><p>EFI partition is formatted with FAT32 using</p><pre>mkfs.fat -F 32 /dev/_efi_system_partition_</pre><ul><li>-F flag means “File Allocation Table size” it tells mkfs to create a FAT32 file system.</li><li>fat is the simple old school file system</li><li>works on almost all devices.</li></ul><h3>Mounting the file systems:</h3><p>Mount the root volume to /mnt</p><ol><li>what is mount and why are we mounting root volume to mnt in the first place.</li></ol><ul><li>mount is a Linux command that attaches a storage device (like a partition, USB drive, SSD, NVMe, etc.) to a folder in your filesystem so you can access its files.</li><li>/dev/sda1 -&gt; mounted to -&gt;/mnt</li><li>we mount these storage to a directory so that the installer can copy the OS files to that directory.</li></ul><pre>/mnt/<br>├── boot/<br>├── home/<br>└── (other Linux system files)</pre><pre>mount --mkdir /dev/_efi_system_partition_ /mnt/boot</pre><p>mount with --mkdir creates the directory if it doesn&#39;t exist.</p><pre>swapon /dev/_swap_partition_</pre><p>This command enables the created and formatted swap volume.</p><h3>Installation</h3><p>Since arch base install has only essentials additional packages has to be downloaded from the mirror servers.</p><p>They are defined in the /etc/pacman.d/mirrorlist<br>The topmost worldwide mirror should be fast enough for most people, if not you can edit the file for the same.</p><p>This file will later be copied to the new system by <em>pacstrap</em>, so it is worth getting right.</p><blockquote><em>some essential packages are mentioned in the arch install manual to get you started and its pretty self-explanatory if you read em why you wanna install those packages so im skipping those here.<br></em><a href="https://wiki.archlinux.org/title/Installation_guide#Install_essential_packages"><em>https://wiki.archlinux.org/title/Installation_guide#Install_essential_packages</em></a></blockquote><p>For example, a basic installation with the Linux <a href="https://wiki.archlinux.org/title/Kernel">kernel</a> and firmware for common hardware:</p><pre>pacstrap -K /mnt base linux linux-firmware</pre><p>now you may have a question pacman is the package manager in arch right why are we even using pacstrap</p><ul><li>pacman is used to install packages in a running arch system.</li><li>pacstrap installs the base Arch system onto a new disk<br>When you install Arch from the ISO, you are not inside your actual system yet.<br>You are in a live environment (temporary, RAM-based).</li></ul><p>you’re future Arch system lives inside /mnt</p><p>You must install the “base system” there.<br>That is exactly what pacstrap does.</p><p>pacstrap meaning<br>pac = pacman<br>strap = bootstrap.</p><p>pacstrap installs the initial OS files to /mnt</p><h4>So why is the -K flag at the end?</h4><p>lemme give you some context before explaining that flag.</p><ul><li>arch linux signs all packages</li><li>your system needs valid keys to verify them<br>Without keys the installed system has no keys so it must initialize them using pacman-key --init</li><li>This can fail if:</li><li>Your clock is wrong</li><li>Networks fail</li><li>Key servers are down</li></ul><p>-K avoids these problems.</p><h4>This is what -K does</h4><ul><li>Copy the keyring from the live environment into the new system’s /mnt/etc/pacman.d/gnupg</li><li>So the new system already trusts the same package-signing keys</li></ul><h3>Next up: configuring the system</h3><h4>fstab</h4><p>What is fstab and why do we need it?<br>it is just a config file that tells your system:</p><ul><li>which storage devices exist</li><li>where they should be mounted</li><li>with what permissions and options</li><li>whether they should mount automatically during boot.</li></ul><p>Linux has no built-in memory of where your partitions belong.<br>it has no clue where your devices like /dev/sda1 /dev/nvme0n1p3 /dev/sdb should attach in your folder tree.</p><ul><li>Every time you reboot, your disks would NOT mount automatically.</li><li>You’d have to run mount /dev/sda2 /mnt/storage <em>every single time</em>.</li></ul><p>Breakdown of fstab entry:</p><ul><li>Device (disk UUID or path)</li><li>Mount point (/home, /mnt, /boot)</li><li>Filesystem (ext4, ntfs, btrfs, vfat, etc.)</li><li>Options (read-write, noatime, auto, etc.)</li><li>Dump backup flag</li><li>fsck order (boot-time disk checking)</li></ul><pre>genfstab -U /mnt &gt;&gt; /mnt/etc/fstab</pre><p>genfstab = &quot;Generate fstab entries&quot;</p><ul><li>it scans all currently mounted partitions under /mnt</li><li>it figures out device UUIDs, mount points, filesystem types, mount options</li><li>and prints out valid /etc/fstab lines</li></ul><p>-U means UUIDs &quot;stable, unique identifiers&quot; instead of /dev/sda1 style paths.<br>This is safer because device names can change between boots.</p><p>&gt;&gt; this takes the output of genfstab and appends it to /mnt/etc/fstab<br>/mnt is where the arch system currently mounted.</p><p>It creates the new Arch system’s /etc/fstab, which tells it:</p><blockquote><em>“Mount these partitions exactly the same way the installer just did, every time the system boots.”</em></blockquote><h3>Interactive with the new system’s environment</h3><pre>arch-chroot /mnt</pre><p>What is chroot?<br>as we now know when we install a os to our system we’re booted into a live ISO and that is not our real system. It’s just a temporary environment.</p><p>But we need to run commands inside our newly installed system how do we do that even tho the system isn’t booted yet?</p><p>that is what chroot = change root is.</p><p>now the root folder is changed to the mountpoint /mnt so this creates a fake environment, programs behave like they&#39;re running on a live system.</p><p>now comes another question. what tf does arch-chroot does?<br>normal chroot only changes the filesystem root.<br>it does not automatically mount:</p><ul><li>/proc</li><li>/sys</li><li>/dev</li><li>/run</li></ul><p>These dirs provide hardware info, devices, process info, and runtime data.<br>Without these, half the tools will break.<br>Try using pacman inside a plain chroot -&gt; stuff fails.<br>Try installing grub -&gt; fails because no /sys or /dev.</p><p>so basically arch-chroot is a wrapper around chroot that handles all these with permissions and environment variables as well.</p><h3>Time</h3><pre>ln -sf /usr/share/zoneinfo/Area/Location /etc/localtime</pre><p>When your system shows the wrong time, tons of stuff breaks:</p><ul><li>logs are out of order</li><li>cron jobs run at wrong times</li><li>SSL certificates appear invalid</li><li>developer tools throw warnings</li><li>package managers complain</li></ul><p>Hardcoding your timezone is stupid</p><p>Linux uses a file called:</p><pre>/etc/localtime</pre><p>This file tells Linux “use this TimeZone data”</p><p>All timezone definitions are stored in:</p><pre>/usr/share/zoneinfo/</pre><p>Inside this folder, you have subfolders like:</p><pre>Asia/Kolkata<br>Europe/London<br>America/New_York</pre><p>so what does the command do?<br>ln - create a link<br>-s - Symbolic link<br>-f - force overwrite.</p><p>It links your timezone info to the /etc/localtime so that your systems behave correctly</p><pre>hwclock --systohc</pre><blockquote><em>To prevent clock drift and ensure accurate time, set up </em><a href="https://wiki.archlinux.org/title/Time_synchronization"><em>time synchronization</em></a><em> using a </em><a href="https://en.wikipedia.org/wiki/Network_Time_Protocol"><em>Network Time Protocol</em></a><em> (NTP)</em></blockquote><p>This is done using timedatectl set-ntp true</p><p>your system has two clocks</p><h3>System Clock (software clock)</h3><ul><li>Lives in RAM</li><li>Starts running when the kernel boots</li></ul><h3>Hardware Clock (a.k.a RTC — Real Time Clock)</h3><ul><li>A little clock chip on your motherboard</li><li>Runs even when your laptop is turned off</li><li>Powered by a tiny CMOS battery</li></ul><p>When your PC boots, it reads time from the hardware clock, then the kernel runs its own clock.</p><p>If these two clocks mismatch — you get all kinds of weird issues.</p><p>hwclock --systohc stands for Hardware clock &lt;- System Clock<br>&quot;Take the current System Time and write it into the Hardware Clock&quot;</p><p>When installing Linux (especially Arch), you:</p><ol><li>Set your timezone</li><li>Sync your system clock using NTP (timedatectl set-ntp true)</li><li>Then you run hwclock --systohc to save that correct time into hardware.</li></ol><h3>Localization</h3><p>From manual</p><blockquote><em>To use the correct region and language specific formatting (like dates, currency, decimal separators), </em><a href="https://wiki.archlinux.org/title/Textedit"><em>edit</em></a><em> </em><em>/etc/locale.gen and uncomment the UTF-8 </em><a href="https://wiki.archlinux.org/title/Locale"><em>locales</em></a><em> you will be using. Generate the locales by running:</em></blockquote><blockquote><em>locale-gen</em></blockquote><p>All the formatting settings like</p><ul><li>language to display</li><li>date formatting</li><li>decimals be displayed 1.23 or 1,23</li><li>how to sort string with special chars</li><li>which character encoding to support (UTF-8 etc…)<br>comes from a setting called locale.<br>A locale = rules for language + region + formatting. Ex: en_US.UTF-8 English (United States)</li></ul><p>Linux needs these compiled and stored so apps can actually use them</p><p>So locale-gen generates/compiles the locales you enabled in /etc/locale.gen</p><p>you uncomment what are all the options you want in /etc/locale.gen then run locale.gen to actually generate the compiled locale files for your system.</p><p>then create a /etc/locale.conf file and set which locale you want your system to use by default</p><p>TLDR;<br>/etc/locale.gen - Enable/generate available locales<br>/etc/locale.conf - Choose the default system locale</p><pre># /etc/locale.conf</pre><pre>LANG=en_US.UTF-8</pre><h3>Network Configuration</h3><p>This file /etc/hostname exactly contains one line that denotes the hostname for your system<br>without this name other devices in the network cannot refer to it, this device cannot identify itself when sending packets.</p><pre># etc/hostname</pre><pre>karthik-dev-machine</pre><p>This is the file the init system (like systemd) reads<br>It sets the system’s hostname with that value.<br>All services started after this point inherit that hostname.</p><p>The temporary way to do this is</p><pre>hostname karthik</pre><p>This resets after reboot.</p><h3>Initramfs</h3><p>What is initramfs?? why do we need it?</p><p>At the very start, the bootloader like GRUB loads the linux kernel into memory.</p><p>The kernel alone cannot access your real filesystem yet.</p><ul><li>your root filesystem might be on ext4, btrfs, LVM, LUKS encrypted volume, RAID, NVMe etc…</li><li>the kernel doesn’t have the drivers for those built-in</li><li>The kernel has no idea how to decrypt your drive or activate LVM or assemble RAID.</li></ul><p>initramfs - The kernel&#39;s temporay mini-operating system<br>initramfs - initial RAM filesystem.</p><p>its basically,</p><ul><li>a tiny temporary linux filesystem</li><li>loaded into RAM at boot.</li><li>Contains scripts + drivers to “prepare the real system”</li></ul><p>you can call it a mini rescue OS that runs before your actual Linus system does.<br>it has kernel modules(drivers), binaries like ls, mount, lvm, cryptsetup and boot scripts</p><p>For example ext4 drive:<br>initramfs loads disk + filesystem modules, mounts root switches to the real system<br>simple.<br>This is different for each drive lvm, LUKS, RAID etc..</p><p>now this pretty much explains why do we need</p><pre>mkinitcpio -P</pre><p>initramfs depends on your system configuration.<br>If you change any one of this</p><ul><li>filesystem</li><li>add encryption</li><li>add LVM</li><li>install new kernel modules</li><li>modify hooks in /etc/mkinitcpio.conf<br>then old initramfs might not contain the right tools<br>so we regenerate it with this command.</li></ul><p>What is LVM?<br>LVM = Logical Volume manager<br>Problems before LVM:</p><ul><li>You cannot easily resize or move partitions.</li><li>You can’t combine multiple disks into one logical storage pool.</li><li>You can’t resize filesystems while they’re online (in most cases).<br>I once myself faced this problem then i had to reinstall arch in a big partition.<br>sadly i didn’t know about LVM back then.</li></ul><p>LVM treats storage like RAM, just pool it and use what you need.<br>its like a lego blocks for storage.<br>Instead of physical partitions, you create <em>virtual</em> ones that you can resize, move, extend, shrink — while the system is running.</p><p>Some jargon:</p><ol><li>PV = Physical Volume:<br>your actual storage devices:</li></ol><ul><li>/dev/sda</li><li>/dev/nvme0n1p2 any disk like this<br>you convert them into PV&#39;s</li></ul><p>pvcreate /dev/sda2</p><ol><li>VG = Volume Group<br>You combine multiple volume groups into one big pool.</li></ol><p>vgcreate myvg /dev/sda2 /dev/sdb1</p><ol><li>LV= logical volume</li></ol><p>lvcreate -n root -L 40G myvg<br>lvcreate -n home -L 100G myvg</p><p>These are completely virtual and you can resize them anytime.</p><p>TLDR;</p><p>Layer 1 PV (Physical Volumes)</p><p>Actual disks or partitions.</p><p>Layer 2 VG (Volume Group)</p><p>A pool/bucket made by combining physical volumes.</p><p>Layer 3 LV (Logical Volumes)</p><p>Virtual partitions created inside the volume group.</p><p>how resizing partitions LIVE is done in LVM</p><pre>lvextend -L +10G /dev/myvg/root<br>resize2fs /dev/myvg/root</pre><p>Boom, done. No reboot. No stress.</p><p>LVM can do more things:</p><ul><li>Combine multiple disks</li><li>Easier encryption (LUKS + LVM combo)</li><li>Perfect for VMs, servers, production machines</li></ul><p>take snapshots (like ZFS-lite)<br>clone volumes<br>resize storage on the fly<br>This is how actual sysadmins run storage.</p><h3>Root Password</h3><pre>passwd</pre><p>you know what this command does.</p><h3>Boot Loader</h3><p>A <a href="https://en.wikipedia.org/wiki/Bootloader">boot loader</a> is a piece of software started by the <a href="https://en.wikipedia.org/wiki/Firmware">firmware</a>-UEFI or BIOS. It is responsible for loading the kernel with the wanted <a href="https://wiki.archlinux.org/title/Kernel_parameters">kernel parameters</a> and any external initramfs images.</p><p>A boot manager presents a menu of boot options, or provides some other way to control the boot process i.e. it just runs other EFI executables.<br>Ex: grub is a boot manager.</p><p>In the case of UEFI, the kernel itself can be directly launched by the UEFI using the <a href="https://wiki.archlinux.org/title/EFI_boot_stub">EFI boot stub</a>. A separate boot loader or a boot manager can still be used for the purpose of editing kernel parameters before booting.</p><h3>Reboot</h3><blockquote><em>Optionally manually unmount all the partitions with </em><em>umount -R /mnt: this allows noticing any &quot;busy&quot; partitions, and finding the cause with </em><a href="https://man.archlinux.org/man/fuser.1"><em>fuser(1)</em></a><em>.</em></blockquote><p>now comes the question why do we need to unmount the /mnt partition before exiting?</p><p>It’s the same as we eject the pendrive from file explorer before physically removing the pendrive from the system.</p><p>It’s more of a safety procedure.</p><p>what might happen if you didn’t unmout the partition before reboot.</p><ul><li>The kernel might still be writing files to /mnt</li><li>pacstrap or mkinitcpio might not have flushed all data</li><li>Journals (ext4/others) might not be clean</li><li>You may end up with a bootloader that didn’t install correctly</li><li>Or a system that doesn’t boot because /etc/fstab or kernel images weren’t actually written</li></ul><p>So now what is fuser?<br>fuser = File user finder.<br>It lets you check <em>which processes are currently using a file or directory</em>.</p><pre>fuser -v /mnt</pre><p>This will show:</p><ul><li>Which programs still have files open</li><li>Which terminals are accessing /mnt</li><li>If there’s a stray shell sitting in /mnt</li><li>If a background process is messing with the mount</li></ul><p>you can even kill all the processes using the /mnt folder</p><pre>fuser -k /mnt</pre><p>fuser is also usefull in certain other<br>scenarios as well for example you’re starting your app in port 3000 and the shell says port 3000 is already in use<br>so you can use fuser in that scenario.</p><pre>fuser -v 3000/tcp</pre><p>you can even kill it using this command:</p><pre>fuser -k 3000/tcp</pre><p>where -k stands for kill.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*W5Kj9YZ-6E36vQ6m1pY1dg.png" /></figure><p>now you might have got what fuser does and how it is useful:<br>here for demonstration purposes i used fuser to check what processes are using the file system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/597/1*x0f7U_boiQKFMQUg6ew1mA.png" /></figure><p>What issue does a “busy partition” cause???</p><p>you do umount and it says umount: /mnt: target is busy</p><p>That means something is still using that partition.</p><p>could be:</p><ul><li>Your terminal is “cd”-ed into /mnt</li><li>A background process is reading the filesystem</li><li>A package install is still running</li><li>A log viewer is open</li><li>A file manager (less, nano, vim) hasn’t closed the file</li></ul><p>If you ignore this and shut down or reboot:</p><ul><li>data fully not written and may result in corrupted sytem</li><li>bootloader not fully installed</li><li>incomplete configs</li></ul><p>So its always a good idea to check busy mounts</p><h3>Now that we’ve learnt what these series of commands in archlinux install manual do, it’s time to goon more on arch</h3><p>and now don’t forget you’re not just a normal arch user you can brag with no hesitation “I use ARCH BTW”</p><p>if you want to read more about post-installation steps which are basically installing some gui’s and stuff that i assume you already know so i’m skipping those.</p><p><a href="https://wiki.archlinux.org/title/Installation_guide">https://wiki.archlinux.org/title/Installation_guide</a></p><p>Anyway Happy Learning Peace 🕊️</p><p>👉 → <a href="https://x.com/kaizakinn">https://x.com/kaizakinn</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef23ee97f850" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Complete Guide: How to Dual Boot Arch Linux(Omarchy) and Windows 11 Using Arch Install Script]]></title>
            <link>https://medium.com/@karthikbalasubramanian08/complete-guide-how-to-dual-boot-arch-linux-omarchy-and-windows-11-using-arch-install-script-6af63e7de202?source=rss-110e0af94afa------2</link>
            <guid isPermaLink="false">https://medium.com/p/6af63e7de202</guid>
            <category><![CDATA[arch-linux]]></category>
            <category><![CDATA[dual-boot]]></category>
            <category><![CDATA[windows-11]]></category>
            <category><![CDATA[omarchy]]></category>
            <category><![CDATA[arch-install]]></category>
            <dc:creator><![CDATA[Karthik Balasubramanian]]></dc:creator>
            <pubDate>Wed, 22 Oct 2025 12:23:16 GMT</pubDate>
            <atom:updated>2025-10-22T12:23:16.006Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AdGBPThsbWkhosHLdjPRgw.png" /></figure><h3>Introduction</h3><p>This tutorial will guide you through the easiest and safest way to dual-boot Arch Linux with Windows 11 using the all-new Arch Install Script. This method allows you to install Arch Linux alongside Windows 11 on the same drive without risking data loss. However, it’s strongly recommended to back up your files to the Cloud or an external drive before proceeding.</p><p>At the end of this guide, you’ll also learn how to safely remove Arch Linux from the dual boot setup if needed.</p><h3>Pre-requisites</h3><p>Before starting, ensure you have:</p><ul><li>Windows 11 or Windows 10 installed on your PC or laptop</li><li>An 8GB or higher USB drive to create a bootable disk with Arch Linux</li><li>At least 50GB of free space available on your existing drive</li></ul><h3>Step 1: Create System Restore Point</h3><p>Before installing Arch Linux, it’s recommended to create a System Restore point on your Windows computer as a safety backup.</p><ol><li>Search for “restore point” in the Start menu</li><li>Open “Create a restore point”</li><li>Click “Create” to take a snapshot of your current system state</li></ol><p>This backup allows you to restore your system to normal if something goes wrong with the Arch installation.</p><h3>Step 2: Disable BitLocker Encryption (Windows 11 Pro Only)</h3><p>If you’re using Windows 11 Pro, disable BitLocker encryption before proceeding, as it can interfere with Linux installations.</p><p>Note: For Windows 11 Home users, this feature is disabled by default.</p><ol><li>Search for “BitLocker” in Start menu</li><li>Turn off BitLocker for your system drive</li><li>Wait for decryption to complete</li></ol><h3>Step 3: Creating Free Space For Arch Linux</h3><p>Now let’s create free space on your drive for Arch Linux installation.</p><ol><li>Right-click on the desktop and open Terminal (or press Win + X and select Terminal/PowerShell)</li><li>Type the following command and press Enter:</li></ol><pre>diskmgmt.msc</pre><p>This opens the Disk Management utility, which displays all drives and their partitions.</p><h3>Understanding Your Disk Layout</h3><p>You’ll see your Drive 0 with several partitions:</p><ul><li>EFI partition: Contains the Windows boot loader</li><li>Main Windows partition (C:): Your Windows installation</li><li>Recovery partition: Windows recovery tools</li></ul><h3>Shrinking Your Windows Partition</h3><ol><li>Right-click on your C: Drive (or any other partition you want to shrink)</li><li>Select “Shrink Volume”</li><li>Enter the amount of space to allocate for Arch Linux</li></ol><ul><li>Minimum: 40,000 MB (40 GB)</li><li>Recommended: 50,000 MB (50 GB) or more</li><li>Example: 200,000 MB (200 GB) for ample space</li></ul><p>4. Click “Shrink”</p><p>This creates an unallocated free space for Arch Linux.</p><h3>Step 4: Download Arch Linux</h3><ol><li>Open your web browser and visit the <a href="https://archlinux.org/">official Arch Linux website</a></li><li>Click the “Download” button</li><li>Scroll down and choose the closest mirror to your location</li><li>Download the Arch Linux ISO file</li></ol><h3>Step 5: Download Rufus</h3><ol><li>Visit the <a href="https://rufus.ie/">official Rufus website</a></li><li>Download the latest version of Rufus</li><li>Save both the Arch Linux ISO and Rufus to an easily accessible location</li></ol><h3>Step 6: Creating Bootable USB with Arch Linux</h3><ol><li>Connect your USB stick (8GB or larger) to your computer</li><li>Double-click to open Rufus</li><li>Configure Rufus settings:</li></ol><ul><li>Device: Select your USB drive</li><li>Boot selection: Click “SELECT” and choose the Arch Linux ISO file</li><li>Partition scheme: Select GPT</li><li>Target system: Select UEFI (non CSM)</li></ul><p>Important Note: If your system uses legacy BIOS, select MBR instead of GPT.</p><ol><li>Click “START” to begin creating the bootable USB</li><li>Accept any prompts that appear</li><li>Wait for the process to complete (time varies based on USB write speed)</li></ol><h3>Step 7: Modifying BIOS Settings</h3><p>Once the bootable USB is ready, you need to boot into your system’s BIOS/UEFI settings.</p><h3>Entering BIOS</h3><ol><li>Restart your computer</li><li>Press the appropriate key during startup (commonly F2, F9, F10, F12, DEL, or ESC)</li></ol><ul><li>The key varies by manufacturer; watch for the prompt during boot</li></ul><h3>BIOS Configuration</h3><p>In the UEFI BIOS settings:</p><ol><li>Enable USB Boot</li><li>Change Boot Order: Set the USB drive as the primary boot device</li><li>Disable Secure Boot</li><li>Save changes and exit</li></ol><p>Your system will now boot from the USB drive. If it fails to boot automatically, use the boot menu (usually F12 or F9) to manually select the USB drive.</p><h3>Step 8: Booting Into Arch Linux Installation Media</h3><p>When your system boots from the USB, you’ll see a terminal screen. Note that mouse functionality is disabled, and you must rely on keyboard commands.</p><h3>Increase Console Font Size</h3><p>Type the following command to increase the console font size for better readability:</p><pre>setfont ter-132b</pre><p>Press Enter to execute.</p><h3>Step 9: Connect to the Internet</h3><h3>For Ethernet Connection</h3><p>If your computer is connected via Ethernet cable, test the connection:</p><pre>ping -c 3 archlinux.org</pre><p>If you receive packets, you’re connected.</p><h3>For WiFi Connection (Using iwctl)</h3><p>If you’re using built-in WiFi, use the iwctl utility:</p><ol><li>Enter the iwctl shell:</li></ol><pre>iwctl</pre><ol><li>List available network interfaces:</li></ol><pre>device list</pre><p>Look for wlan0 and ensure it’s turned on.</p><ol><li>If it’s off, enable it:</li></ol><pre>device wlan0 set-property Powered on</pre><ol><li>Scan for available networks:</li></ol><pre>station wlan0 scan</pre><ol><li>List available WiFi networks:</li></ol><pre>station wlan0 get-networks</pre><ol><li>Connect to your WiFi network:</li></ol><pre>station wlan0 connect &quot;YOUR_WIFI_NAME&quot;</pre><p>Replace YOUR_WIFI_NAME with your actual WiFi SSID.</p><ol><li>Enter your WiFi password when prompted</li><li>Wait 5 seconds, then press Enter</li><li>Exit iwctl:</li></ol><pre>exit</pre><ol><li>Verify internet connection:</li></ol><pre>ping -c 3 archlinux.org</pre><h3>Step 10: Update Package Database and Install Required Packages</h3><ol><li>Synchronize package databases:</li></ol><pre>pacman -Sy</pre><ol><li>Install Arch Linux keyring:</li></ol><pre>pacman -S archlinux-keyring</pre><ol><li>Install archinstall package:</li></ol><pre>pacman -S archinstall</pre><p>Execute these commands one after the other.</p><h3>Step 11: Creating Partitions For Arch Linux</h3><h3>List All Drives</h3><pre>lsblk</pre><p>You’ll see all connected drives. Focus on the main drives (ignore loop devices):</p><ul><li>nvme0n1 or sda: Your main drive with Windows 11</li><li>sdb or similar: Your bootable USB</li></ul><h3>Launch cfdisk</h3><p>Replace nvme0n1 with your actual drive name (could be sda for SATA drives):</p><pre>cfdisk /dev/nvme0n1</pre><h3>Creating Partitions</h3><p>Use arrow keys for navigation and Enter for confirmation.</p><p>You’ll see your existing partitions:</p><ul><li>EFI partition</li><li>Windows partition</li><li>Free space (the unallocated space you created earlier)</li></ul><h3>Create EFI Partition (1GB)</h3><ol><li>Navigate to the Free space using arrow keys</li><li>Press Enter to create a new partition</li><li>Enter size: 1G (1 GB)</li><li>Press Enter to confirm</li><li>Select Type</li><li>Choose EFI System</li></ol><h3>Create Root Partition (Remaining Space)</h3><ol><li>Navigate back to the Free space</li><li>Press Enter to create a new partition</li><li>Use the remaining free space (or specify size, minimum 20GB)</li><li>Press Enter to confirm</li><li>Type is automatically set to Linux filesystem</li></ol><h3>Write Changes</h3><ol><li>Navigate to Write at the bottom</li><li>Press Enter</li><li>Type yes to confirm</li><li>Navigate to Quit and press Enter</li></ol><p>Remember your partition identifiers (e.g., nvme0n1p5 for EFI, nvme0n1p6 for Root)</p><h3>Step 12: Formatting Partitions</h3><h3>Verify New Partitions</h3><pre>lsblk</pre><p>You should see your newly created partitions (e.g., nvme0n1p5 and nvme0n1p6).</p><h3>Format EFI Partition</h3><p>Replace nvme0n1p5 with your actual EFI partition:</p><pre>mkfs.fat -F32 /dev/nvme0n1p5</pre><h3>Format Root Partition</h3><p>Replace nvme0n1p6 with your actual root partition:</p><pre>mkfs.ext4 /dev/nvme0n1p6</pre><h3>Step 13: Mounting Partitions</h3><h3>Mount Root Partition</h3><p>Replace nvme0n1p6 with your actual root partition:</p><pre>mount /dev/nvme0n1p6 /mnt</pre><h3>Create Boot Directory</h3><pre>mkdir -p /mnt/boot</pre><h3>Mount EFI Partition</h3><p>Replace nvme0n1p5 with your actual EFI partition:</p><pre>mount /dev/nvme0n1p5 /mnt/boot</pre><h3>Verify Mounts</h3><pre>lsblk</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*taN1fv8nKu4vBd4AEpyTfA.jpeg" /></figure><p>Ensure both partitions are properly mounted to /mnt and /mnt/boot.</p><h3>Step 14: Installing Arch Linux With ArchInstall Script</h3><p>Now it’s time to use the automated ArchInstall script to install Arch Linux.</p><h3>Launch ArchInstall</h3><pre>archinstall</pre><p>You’ll see a menu-driven interface. Use arrow keys to navigate and Enter to select.</p><h3>Configuration Steps</h3><h3>1. System Language</h3><ul><li>Select your preferred language (e.g., en_US)</li></ul><h3>2. Locale</h3><ul><li>Choose your locale (e.g., en_US.UTF-8)</li></ul><h3>3. Disk Configuration</h3><ul><li>Select “Disk configuration”</li><li>Choose “Pre-mounted configuration”</li><li>Enter root directory: /mnt</li><li>Press Enter to confirm</li><li>Go back to main interface</li><li>Verify that the script recognized your root partition</li></ul><h3>4. Swap</h3><ul><li>Ensure swap is enabled</li></ul><h3>5. Bootloader</h3><ul><li>Select “Bootloader”</li><li>Choose GRUB (recommended for dual boot)</li></ul><h3>6. Hostname</h3><ul><li>Enter hostname: archlinux (or your preferred name)</li></ul><h3>7. Root Password</h3><ul><li>Set a strong password for the root user</li></ul><h3>8. User Account</h3><ul><li>Create a new user account</li><li>Add this user to the sudoers group for elevated privileges</li></ul><h3>9. Profile</h3><ul><li>Select “Profile”</li><li>Choose “Desktop”</li><li>Select Minimal Desktop (This is crucial we will run Omarchy install script on top of a minimal Desktop)</li></ul><h3>10. Graphics Drivers</h3><p>Select based on your hardware:</p><ul><li>Intel iGPU: Intel (open source)</li><li>AMD GPU: AMD / ATI (open source)</li><li>NVIDIA RTX (newer cards): Nvidia (proprietary)</li><li>NVIDIA (older cards): Nouveau (open source)</li><li>Unsure: All open-source drivers</li></ul><h3>11. Audio</h3><ul><li>Select “Audio”</li><li>Choose PipeWire (recommended for best compatibility)</li></ul><h3>12. Kernels</h3><ul><li>Stick with the latest kernel (default)</li><li>Optionally install additional kernels if needed</li></ul><h3>13. Network Configuration</h3><ul><li>Select “Network configuration”</li><li>Choose NetworkManager</li></ul><h3>14. Additional Packages (Optional)</h3><ul><li>Press / followed by package name</li><li>Press Tab to select</li><li>Examples: firefox, vlc, git, etc.</li></ul><h3>15. Timezone</h3><ul><li>Select your timezone for correct system time</li></ul><h3>Begin Installation</h3><ol><li>Review all options to ensure nothing is left blank</li><li>Select “Install”</li><li>Wait for the ArchInstall script to complete (this may take several minutes)</li></ol><h3>Step 15: Post-Installation — GRUB Installation</h3><p>After installation completes, you’ll see a prompt for post-installation steps.</p><h3>Enter Chroot Environment</h3><p>Select the option to perform post-installation steps to enter the chroot environment.</p><h3>Verify Partitions</h3><pre>lsblk</pre><h3>Manually Install GRUB</h3><p>The script may not install GRUB properly, so we’ll do it manually.</p><ol><li>Install required packages:</li></ol><pre>pacman -S grub efibootmgr dosfstools mtools</pre><ol><li>Install GRUB to the boot partition:</li></ol><pre>grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB</pre><ol><li>Generate GRUB configuration file:</li></ol><pre>grub-mkconfig -o /boot/grub/grub.cfg</pre><p>GRUB bootloader is now installed successfully!</p><h3>Step 17: Finalize and Reboot</h3><h3>Exit Chroot Environment</h3><pre>exit</pre><h3>Unmount Partitions</h3><pre>umount -R /mnt</pre><h3>Shutdown System</h3><pre>shutdown now</pre><p>Eject the USB drive before the system powers off completely.</p><h3>Step 18: First Boot and GRUB Setup</h3><h3>Make GRUB as Default Boot Manager</h3><p>When you turn on your computer:</p><ol><li>If you see the GRUB menu, proceed to Step 19</li><li>If your system boots directly into Windows 11:</li></ol><ul><li>Restart your computer</li><li>Press the BIOS key during startup</li><li>Navigate to Boot Options</li><li>Select GRUB under UEFI boot entries</li><li>Make GRUB the default boot manager</li><li>Save and exit</li><li>Reboot</li></ul><p>You should now see the GRUB boot menu.</p><h3>Boot Into Arch Linux</h3><ol><li>Select Arch Linux from GRUB menu</li><li>Login with your user credentials</li></ol><h3>Step 19: Adding Windows Entry to GRUB</h3><p>Currently, Windows 11 won’t appear in the GRUB menu. Let’s fix that.</p><h3>Edit GRUB Configuration</h3><p>Open terminal in Arch Linux and edit the GRUB configuration:</p><pre>sudo nano /etc/default/grub</pre><h3>Modify Settings</h3><ol><li>Find the line: GRUB_TIMEOUT=5</li><li>Change it to: GRUB_TIMEOUT=30 (or your preferred timeout in seconds)</li><li>Scroll to the bottom and find:</li></ol><pre>#GRUB_DISABLE_OS_PROBER=false</pre><ol><li>Uncomment it (remove the #):</li></ol><pre>GRUB_DISABLE_OS_PROBER=false</pre><p>This allows GRUB to detect the Windows boot loader.</p><h3>Save and Exit</h3><ul><li>Press Ctrl + O to save</li><li>Press Enter to confirm</li><li>Press Ctrl + X to exit</li></ul><h3>Step 20: Running Omarchy Script in our fresh archinstall</h3><ol><li>Connect to internet using USB-Tethering or using nmcli command</li></ol><pre>sudo nmcli dev wifi connect &lt;WIFINAME&gt; password &lt;YOURPASSWD&gt;</pre><p>2. Now check the connection using ping:</p><pre>ping -c 5 google.com</pre><p>3. Update your system and install some recommended packages/dependencies</p><pre>sudo pacman -Syyu</pre><pre>sudo pacman -S git wget curl nano vim</pre><p>4. Run Omarchy install Script</p><pre>wget -q0- https://omarchy.org/install | bash</pre><p>That’s it now sit back and be patient and let the script do it’s job.</p><h3>That’s it now you’ve Suceesfully dual booted Omarchy with Windows11 💐</h3><p>You can learn more about Omarchy <a href="https://omarchy.org/">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6af63e7de202" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>