简体   繁体   English

如何在运行时查找已安装和已卸载分区的总大小和可用大小

[英]How to find total and free size of mounted and unmounted partition at runtime

I am using tune2fs -l /dev/mmcblk0p1 but when i use this command and change the free space of partition by copying some files into it , tune2fs does not gives updated values. 我正在使用tune2fs -l / dev / mmcblk0p1,但是当我使用此命令并通过将一些文件复制到其中来更改分区的可用空间时,tune2fs不会提供更新的值。

Tune2fs gives correct value if i restart the system but does not updates values at runtime. 如果我重新启动系统,Tune2fs会给出正确的值,但不会在运行时更新值。

Please suggest some other command that provides coreect data at runtime for unmounted/mounted partitions both. 请建议其他一些在运行时为未安装/已安装分区提供coreect数据的命令。

TIA. TIA。

You can not get the exact value of free space available on a random unmounted block device/partition, because the actual free space will depend on actions kernel will perform when mounting the device. 您无法获得随机卸载的块设备/分区上可用的可用空间的确切值,因为实际的可用空间将取决于内核在安装设备时执行的操作。 So the only proper way to get the amount of free space is to mount the partition first, then use the usual df utility, which will show the up to date space utilization. 因此,获取可用空间量的唯一正确方法是先安装分区,然后使用通常的df实用程序,该实用程序将显示最新的空间利用率。

However, if system crashes abruptly, the free space reported after remounting may actually be different from the value last reported by df prior to the crash. 但是,如果系统突然崩溃,则重新安装后报告的可用空间实际上可能与崩溃前df最后报告的值不同。

For non-mounted devices/partitions, you can always obtain the total (but not free) space available using lsblk or similar utilities. 对于未挂载的设备/分区,您始终可以使用lsblk或类似实用程序获得可用的总空间(但不是可用空间)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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