• Tutorials
  • Using Yocto SDKs to Deploy Applications Directly into NFS RootFS

    When your embedded target boots its root filesystem over NFS, you can use a Yocto SDK to cross-compile and deploy applications directly into the live filesystem. This workflow allows instant updates without reflashing or image rebuilds.


    #Why This Workflow Rocks

    AdvantageDescription
    Instant deployment`scp` or `make install` directly updates `/nfs/rootfs/...` — no flashing required
    🔁 Zero downtime iterationReboot or re-mount target instantly picks up new binaries
    🧰 Full cross-toolchain & sysrootYocto SDK provides matching compiler + libs identical to your image
    🪄 Automatable in CI/CDBuild jobs can push compiled artifacts to the NFS export automatically

    #1. Prerequisites

    • Yocto build environment ready (build/ directory)

    • Exported NFS root filesystem, e.g.:

       1/nfs/rootfs/ → 192.168.0.0/24(rw,no_root_squash,sync)
      
    • Target board boots with:

       1root=/dev/nfs rw nfsroot=192.168.0.1:/nfs/rootfs,tcp ip=dhcp
      
    • Developer workstation or build server with the generated Yocto SDK installed.


    #2. Generate and Install SDK

    From the Yocto build directory:

     1bitbake core-image-minimal -c populate_sdk
    

    This produces something like:

     1tmp/deploy/sdk/poky-glibc-x86_64-core-image-minimal-cortexa9t2hf-neon-toolchain-4.0.sh
    

    Install on your workstation:

     1chmod +x poky-*.sh
     2./poky-*.sh -d ~/yocto-sdk
     3source ~/yocto-sdk/environment-setup-cortexa9t2hf-neon-poky-linux-gnueabi
    

    You now have a matching cross-toolchain and sysroot.


    #3. Mount or Sync the NFS RootFS

    #Option A — Direct Mount (recommended for lab setups)

     1sudo mkdir -p /mnt/nfs-rootfs
     2sudo mount -o rw 192.168.0.1:/nfs/rootfs /mnt/nfs-rootfs
    

    Deploy directly into it:

     1make install DESTDIR=/mnt/nfs-rootfs
    

    #Option B — Rsync after Build

     1rsync -a ./install/ root@192.168.0.1:/nfs/rootfs/
    

    #4. Deploying a Custom Application

    Project layout:

     1apps/
     2 ├── src/main.c
     3 └── Makefile
    

    Example Makefile using Yocto SDK environment variables:

     1CC ?= $(CROSS_COMPILE)gcc
     2CFLAGS += --sysroot=$(SDKTARGETSYSROOT)
     3
     4all::
     5    $(CC) $(CFLAGS) src/main.c -o myapp
     6
     7install::
     8    mkdir -p $(DESTDIR)/usr/bin
     9    cp myapp $(DESTDIR)/usr/bin/
    

    Deploy to NFS rootfs:

     1make install DESTDIR=/mnt/nfs-rootfs
    

    Your target now instantly sees /usr/bin/myapp after reboot or remount.


    #5. Running on Target

    Once booted from NFS:

     1root@target:~# myapp
    

    Verify library dependencies:

     1ldd /usr/bin/myapp
    

    #6. Using devtool (Extensible SDK)

    Generate eSDK:

     1bitbake core-image-minimal -c populate_sdk_ext
    

    Then on your dev host:

     1source poky-glibc-x86_64-core-image-minimal-cortexa9t2hf-neon-toolchain-4.0.sh
     2devtool create-workspace ~/workspace
     3devtool modify myapp
     4devtool build myapp
     5devtool deploy-target myapp root@192.168.0.100:/usr/bin/
    

    No full rebuilds — just rebuild and deploy changed components.


    #7. CI/CD Integration Example

    Automate app build and deployment:

     1#!/bin/bash
     2source ~/yocto-sdk/environment-setup-cortexa9t2hf-neon-poky-linux-gnueabi
     3make all
     4make install DESTDIR=/mnt/nfs-rootfs
     5sudo umount /mnt/nfs-rootfs || true
    

    #8. Pro Tips

    • Use overlayfs: keep /usr on NFS, /var locally writable.
    • Sync SDK and image versions to avoid ABI mismatches.
    • Later, integrate your app as a Yocto recipe for production images.

    #Summary Workflow

     1┌────────────────────────────┐
     2│ Developer Workstation      │
     3│  • Yocto SDK               │
     4│  • source environment      │
     5│  • Build app → make install│
     6└────────────┬───────────────┘
     7             │ NFS
     8 9┌────────────────────────────┐
    10│ NFS RootFS Server          │
    11│  /nfs/rootfs/usr/bin/myapp │
    12└────────────┬───────────────┘
    13             │ Ethernet (PXE+NFS)
    1415┌────────────────────────────┐
    16│ Target Board               │
    17│  Boots kernel + NFS rootfs │
    18│  Runs updated app instantly│
    19└────────────────────────────┘
    
    profile image of Martin Mitkov

    Martin Mitkov

    Martin is a founder and CEO of Mitkov Systems GmbH.

    More posts from Martin Mitkov