Is it possible to find out the USED disk space for an UNMOUNTED file system/disk?
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is it possible to find out the USED disk space for an UNMOUNTED file system/disk?
Hi,
I couldn't find an answer for that on Google, but does anybody knows if it's even possible to find the actual USED disk space for a certain file system/Disk WITHOUT having it mounted?
It's easy to find out the TOTAL disk capacity using fdisk, but the USED the disk space?
Try gparted but in reality it may mount the disk for exclusive use to gparted to provide graphical image of area used. In fact, there has to be some access to the drive in order to find any information about it. There is none saved by default in other places.
As I read the OP, it seemed to want to know how much free space was available on the file-system, as seen by that file-system, but without mounting it.
And, I don't know that you can do that. When mounting, the appropriate filesystem driver is matched-up to the partition and is responsible for knowing how to do things with it – including reporting the amount of free space.
what's the big deal it's easy to mount and unmount a file system
unless your not root in that case anything that could answer your question will not run ether
then the simple answer would be NO it needs to be mounted
the more complex answer is
the kernel needs to have the block tables loaded in to memory and the kernel modules
that work with that file system loaded and they have to be told things where on the disk the file system starts block size all of this is handled by the mount command
copy,rm,mkdir,du,diff all commands that work with a file system and files depend on kernel calls that in turn depend on info set up by mount
there is almost nothing that can be done with a file system that is unmounted
AFAIK
the only utility that can do any thing with an unmounted file system is dd
like it or not he is going to have to mount that file system to run df on it
then the simple answer would be NO it needs to be mounted
The internals of every Linux filesystem are published and available. The internals for various proprietary filesystems, if not published, have been reverse-engineered, or else the kernel would not be able to parse those filesystems. The header files with all the structure definitions can be used to build programs that simply open() the device containing the filesystem and read data from the headers. For ext2/3/4 filesystems, those headers are in the e2fsprogs-devel package. That's how programs like e2fsck, badblocks, debugfs, resize2fs, tune2fs, etc. (programs that take a device name, not a mount point, as an argument) operate for ext2/3/4 filesystems. There are similar programs for other filesystems. None of the mount the filesystem.
The internals of every Linux filesystem are published and available. The internals for various proprietary filesystems, if not published, have been reverse-engineered, or else the kernel would not be able to parse those filesystems. The header files with all the structure definitions can be used to build programs that simply open() the device containing the filesystem and read data from the headers. For ext2/3/4 filesystems, those headers are in the e2fsprogs-devel package. That's how programs like e2fsck, badblocks, debugfs, resize2fs, tune2fs, etc. (programs that take a device name, not a mount point, as an argument) operate for ext2/3/4 filesystems. There are similar programs for other filesystems. None of the mount the filesystem.
yes a program can be written to read free space from an unmounted partition
BUT
the OP did not ask how to write such a program
and why write one when it's so easy to mount a file system run df on it and unmount it
then
is there a program that can read the free space from an unmounted partition
the only program that I know of that even comes close to READING from an unmounted file system is dd but you would still have to mount it to do anything with the copy of it
yes a program can be written to read free space from an unmounted partition
BUT
the OP did not ask how to write such a program
and why write one when it's so easy to mount a file system run df on it and unmount it
then
is there a program that can read the free space from an unmounted partition
the only program that I know of that even comes close to READING from an unmounted file system is dd but you would still have to mount it to do anything with the copy of it
"tune2fs -l" will show you the total number of blocks in the filesystem and the number of free blocks, as well as the inode count and the number of free inodes. The output from e2fsck will do the same, though that would be a silly reason to run e2fsck. If the filesystem is directly on a device or partition (i.e., no LVM, encryption, etc.), gparted will also show how much of its space is in use, and it does not mount the filesystem to do so. The OP asked, "Is it possible?" The answer is, "Yes."
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.