简体   繁体   中英

how to check the SD card size before mounted and do not require root

I want to check the SD card size in bash or python. Right now I know df can check it when the SD card is mounted or fdisk -l if root is available.

But I want to know how to check the SD card size without requiring mounting the card to the file system or requiring the root permission? For example, if the SD card is not mounted and I issue df -h /dev/sdc , this will return a wrong size. In python, os.statvfs this function returns the same content as well. I search on stack overflow but did not find a solution yet.

Well, I found the lsblk -l can do the job. It tells the total size of the partitions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM