Trouver la taille du cluster

4

Je suis sous Ubuntu 11.04 et je me demande comment trouver la taille de la taille de l’unité d’allocation? Existe-t-il une commande dans Ubuntu pour trouver cela? En outre, en fonction de la taille de l’unité d’allocation, la quantité totale d’espace disque utilisé a-t-elle changé? J'ai vérifié les tailles de fichier en utilisant ls et du -b et dans les deux cas, j'obtiens les mêmes valeurs.

Y compris les données:

 sudo tune2fs -l <file system> 
  Block count:              8052736
  Reserved block count:     402636
  Free blocks:              2797402
  First block:              0
  Block size:               4096
  Reserved GDT blocks:      1022
  Blocks per group:         32768
   Inode blocks per group:   512
  Flex block group size:    16
  Reserved blocks uid:      0 (user root)
  Reserved blocks gid:      0 (group root)
  Journal backup:           inode blocks

Donc, si la taille du bloc est de 4 096 octets, les fichiers inférieurs à 4 096 occupent 4 096 octets de stockage sur le disque dur, qu'en est-il des fichiers de plus de 4 096 octets? Y a-t-il une commande pour trouver la même chose?

    
posée bhavs 15.03.2012 - 15:29
la source

1 réponse

5

Top post edit:
Trouver de manière préventive la taille:

temp = int(size/block)  
if mod(size/block) != 0:  
    temp += 1
temp = temp*block
print temp

connaître le nombre de blocs d’un fichier sur le disque:

ls -s

où la taille de bloc correspond à la taille du bloc de partition
et la taille sur le disque est la taille de bloc * nombre de blocs

Explication sur les différences de terminologie de taille de bloc
sudo fdisk -l /dev/sda
où / dev / sda est le disque dur en question

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c1f6b

Device Boot Start End Blocks Id System /dev/sda1 * 63 498014 248976 83 Linux /dev/sda2 498015 976768064 488135025 5 Extended /dev/sda5 498078 976768064 488134993+ 83 Linux

Cela vous dit plusieurs choses. Quelqu'un d'autre l'a déjà dit mieux, alors:
The problem with this is that there are four distinct units that you must be keeping in 
mind. To make things even worse, two of these units bear the same name. These are the 
different units:

1. Hardware block size, "sector size"
2. Filesystem block size, "block size"
3. Kernel buffer cache block size, "block size"
4. Partition table block size, "cylinder size"

To differentiate between the filesystem block size and the buffer cache block size, I 
will follow FAT terminology and use "cluster size" for the filesystem block size.


The sector size is the units that the hardware deals with. This ranges between different 
hardware types, but most PC-style hardware (floppies, IDE disks, etc.) use 512 byte 
sectors.

The cluster size is the allocation unit that the filesystem uses, and is what causes 
fragmentation - I'm sure you know about that. On a moderately sized ext3 filesystem, 
this is usually 4096 bytes, but you can check that with dumpe2fs. Remember that these 
are also usually called "blocks", only that I refer to them as clusters here.

The cluster size is what gets returned in st_blksize in the stat buffer, in order for 
programs to be able to calculate the actual disk usage of a file.

The block size is the size of the buffers that the kernel uses internally when it caches 
sectors that have been read from storage devices (hence the name "block device"). Since 
this is the most primitive form of storage in the kernel, all filesystem cluster sizes 
must be multiples of this. This block size is also what is almost always referred to by 
userspace programs. For example, when you run "du" without the -h or -H options, it will 
return how many of these blocks a file takes up. df will also report sizes in these 
blocks, the "Blocks" column in the fdisk -l output is of this type, and so on. It is 
what is most commonly referred to as a "block". Two disk sectors fit into each block.


The cylinder size is only used in the partition table and by the BIOS (and the BIOS 
isn't used by Linux).

"df" only operates on filesystems, so, no, it can't be used without a filesystem - 
without a filesystem, the data that it would return doesn't exist. "du" operates on 
individual files. 

à partir de ici .

    
réponse donnée RobotHumans 15.03.2012 - 15:45
la source

Lire d'autres questions sur les étiquettes