Thursday 4 January 2018

memory - Doesn't metadata occupy any size?


I put 4096 characters in a text file and save it.Since every character is 1 byte, Size of the text file must be 4K byte.As you see below that's OK:


enter image description here


I connect my flash memory to my computer. the free space on the flash memory is 1,717,518,336 bytes :


enter image description here


I created a copy of the file in my flash memory. And again take a look at the free space. it has 1,717,514,240 bytes free space :


enter image description here


Let see what is the difference :


1,717,518,336 - 1,717,514,240 = 4096 bytes




My question :


Q1:


As you see in the last picture above, the only space that the file occupy on the flash, is the space for its contents [characters].So where is metadata file ?


I mean, when I move the file to another computer, how it understand name of file, Owner of file, Date created and modified and ... ?


Doesn't it occupy any size?!!


Q2:


Can I see the metadata file in the flash memory?


enter image description here


Appreciate your time and consideration.



Answer



Yes, metadata occupies space. On NTFS it occupies 1024 bytes, to be specific. However, the information is not stored in the file, but in the master file table MFT. Specifically in MFT record #4 $AttrDef.


See this Technet article for details: table 3.5 holds all MFT records defined.



When a volume is formatted with NTFS, a Master File Table (MFT) file and other pieces of metadata are created. Metadata are the files NTFS uses to implement the file system structure. NTFS reserves the first 16 records of the MFT for metadata files.


NTFS creates a file record for each file and a directory record for each directory created on an NTFS volume. The MFT includes a separate file record for the MFT itself. These file and directory records are stored on the MFT. The attributes of the file are written to the allocated space in the MFT. Besides file attributes, each file record contains information about the position of the file record in the MFT.



Note that other file systems can and do deal differently with metadata.


EDIT: It has been pointed out in the comments section that this answer is missing the point because the OP asked for metadata on FAT32 filesystems, not NTFS. If I knew how, I would remove the "correct answer" attribute. Therefore I provide additional information that answers the question with regard to FAT32.


FAT32 saves simple metadata such as visibility or modification time for each file and folder in an entry in the parent folder of the the file or folder, creating a tree down from the root folder of the FS. As pointed out with regards to NTFS this is not a file but saved within the folder data structure. The entry originally was 32 byte large and contained the following attributes:


Name (8.3) xxxxxxxx.yyy. (88 bits)

Attribute byte (8 bits of information, described later in this section).

One reserved byte.

Create time (24 bits).

Create date (16 bits).

Last access date (16 bits).

Two reserved bytes.

Last modified time (16 bits).

Last modified date (16 bits).

Starting cluster number in the file allocation table (16 bits).

File size (32 bits).

The list was taken from this Microsoft Technet article and pertains to FAT16. Since the cluster size of FAT32 can be 32 bits and the name of files can be longer than 8.3 the table is not wholly accurate. To accomodate long file names and larger disks FAT32 modifies some behaviour which can be read up in the Wikipedia here but the basic idea holds.


No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...