The latest development version of this page may be more current than this released 2.7.5 version.

File system shell example


This example provides shell access to a LittleFS file system partition in flash.


A board with LittleFS file system support and UART console


Native Posix

Before starting a build, make sure that the i386 pkgconfig directory is in your search path and that a 32-bit version of libfuse is installed. For more background information on this requirement see Native POSIX execution (native_posix).

export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig
west build -b native_posix samples/subsys/shell/fs

See Native POSIX execution (native_posix) on how to connect to the UART.

Reel Board

west build -b reel_board samples/subsys/shell/fs

Particle Xenon

This target is customized to support the same SPI NOR partition table as the littlefs File System Sample Application.

west build -b particle_xenon samples/subsys/shell/fs


Once the board has booted, you will be presented with a shell prompt. All file system related commands are available as sub-commands of fs.

Begin by mounting the LittleFS file system.

fs mount littlefs /lfs

Files System Shell Commands


Mount a file system partition to a given mount point

fs mount (littlefs|fat) <path>


List all files and directories in a given path

fs ls [path]


Change current working directory to given path

fs cd [path]


List current working directory

fs pwd


Write hexadecimal numbers to a given file. Optionally a offset in the file can be given.

fs write <path> [-o <offset>] <hex number> ...


Read file and dump in hex and ASCII format

fs read <path>


Truncate a given file

fs trunc <path>


Create a directory

fs mkdir <path>


Remove a file or directory

fs rm <path>

Flash Host Access

For the Native POSIX board the flash partitions can be accessed from the host Linux system.

By default the flash partitions are accessible through the directory flash relative to the directory where the build is started.