How to get free space of internal file system?

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
User avatar
platforma
Posts: 258
Joined: Thu May 28, 2015 5:08 pm
Location: Japan

Re: How to get free space of internal file system?

Post by platforma » Thu Sep 29, 2016 10:39 am

Just to give an update. The uos.statvfs() implementation has been merged in https://github.com/micropython/micropyt ... 5c2c95dd50

mad474
Posts: 60
Joined: Sun Dec 29, 2013 7:48 pm

Re: How to get free space of internal file system?

Post by mad474 » Thu Sep 29, 2016 8:40 pm

Great! Thanks!

DWiskow
Posts: 11
Joined: Sun Apr 24, 2016 1:23 pm

Re: How to get free space of internal file system?

Post by DWiskow » Wed Apr 18, 2018 3:30 pm

This would do it . . .

Code: Select all

import uos
fs_stat = uos.statvfs('/')
fs_size = fs_stat[0] * fs_stat[2]
fs_free = fs_stat[0] * fs_stat[3]
print("File System Size {:,} - Free Space {:,}".format(fs_size, fs_free))

ObiTwoKenobi
Posts: 1
Joined: Sat Aug 07, 2021 5:14 pm

Re: How to get free space of internal file system?

Post by ObiTwoKenobi » Sat Aug 07, 2021 5:15 pm

import uos, esp
blksize = uos.statvfs('/')[0]
fbs = uos.statvfs('/')[3]
print ("Avilable storage is:",(blksize*fbs)/1024, "KB", "out of:", esp.flash_size()/1024,"KB",sep=" ")

Post Reply