storage — storage management

The storage provides storage management functionality such as mounting and unmounting which is typically handled by the operating system hosting Python. CircuitPython does not have an OS, so this module provides this functionality directly.

storage.mount(filesystem, mount_path, *, readonly=False)

Mounts the given filesystem object at the given path.

This is the CircuitPython analog to the UNIX mount command.

Parameters:readonly (bool) – True when the filesystem should be readonly to CircuitPython.
storage.umount(mount)

Unmounts the given filesystem object or if mount is a path, then unmount the filesystem mounted at that location.

This is the CircuitPython analog to the UNIX umount command.

storage.remount(mount_path, readonly=False, *, disable_concurrent_write_protection=False)

Remounts the given path with new parameters.

Parameters:
  • readonly (bool) – True when the filesystem should be readonly to CircuitPython.
  • disable_concurrent_write_protection (bool) – When True, the check that makes sure the underlying filesystem data is written by one computer is disabled. Disabling the protection allows CircuitPython and a host to write to the same filesystem with the risk that the filesystem will be corrupted.
storage.getmount(mount_path)

Retrieves the mount object associated with the mount path

storage.erase_filesystem()

Erase and re-create the CIRCUITPY filesystem.

On boards that present USB-visible CIRCUITPY drive (e.g., SAMD21 and SAMD51), then call microcontroller.reset() to restart CircuitPython and have the host computer remount CIRCUITPY.

This function can be called from the REPL when CIRCUITPY has become corrupted.

Warning

All the data on CIRCUITPY will be lost, and CircuitPython will restart on certain boards.

class storage.VfsFat(block_device)

Create a new VfsFat filesystem around the given block device.

Parameters:block_device – Block device the the filesystem lives on
label

The filesystem label, up to 11 case-insensitive bytes. Note that this property can only be set when the device is writable by the microcontroller.

mkfs()

Format the block device, deleting any data that may have been there

open(path, mode)

Like builtin open()

ilistdir([path])

Return an iterator whose values describe files and folders within path

mkdir(path)

Like os.mkdir

rmdir(path)

Like os.rmdir

stat(path)

Like os.stat

statvfs(path)

Like os.statvfs

mount(readonly, mkfs)

Don’t call this directly, call storage.mount.

umount()

Don’t call this directly, call storage.umount.