How to find the number of unsed sectors?

Hello to all,

Can any one please tell me how to find the no of used sectors from the hdd. Is there any linux command to find out that??

Reply to
Nutty
Loading thread data ...

Sectors on a HD are not marked "used" in any way.

On a HD there can be lots of partitions. The partition table indicates what sectors are assigned to what partitions. There might be sectors that are not assigned to any partition. Same can be called "unused".

In each partition there can be a file system. Linux provides drivers for a lot of different file systems as a standard and everybody can create a new one if he likes.

Each kind of file system has it's own method to define which sectors are assigned to what kind of information (e.g. to the file allocation table, to the main directory, to a subdirectory, to a file, or to the chain of unused blocks. That was said with an FAT file system in mind, other file systems can be much more complicated.

So the short answer is: you can't.

-Michael

Reply to
Michael Schnell

How about getting the book on kernel internals instead of milking unconnected information fragments here in the newsgroup?

What you want to do is very prone to crash the whole system unless the programmer understands what's going on inside the kernel.

--

Tauno Voipio
tauno voipio (at) iki fi
Reply to
Tauno Voipio

This depends on the partition structure and the filesystems on each partition.

For a mounted filesystem you could use df to get a snapshot of the usage. It does not necessarily map to actual sectors on the disk.

~$ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/hda3 79013284 47764916 31248368 61% /

In this example, there are 47764916 used blocks in this specific partition. One block is two sectors on this disk.

Kind regards,

Iwo

Reply to
Iwo Mergler

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.