Ext3 (Italiano)

From ArchWiki
Revision as of 23:07, 12 July 2010 by Morbin (Talk | contribs) (Using Directory Indexing)

Jump to: navigation, search


Tango-preferences-desktop-locale.pngThis article or section needs to be translated.Tango-preferences-desktop-locale.png

Notes: please use the first argument of the template to provide more detailed indications. (Discuss in Talk:Ext3 (Italiano)#)

Panoramica

Vi è un gran numero di fan del Third Extended Filesystem ("ext3"). A livello kernel e codice userspace è stato provato, testato, corretto, e migliorato più di quasi tutti gli altri filesystem compatibili con Linux. È semplice, robusto, ed estensibile. In questo articolo si illustreranno alcuni suggerimenti che possono migliorare sia le prestazioni che l'affidabilità del filesystem.

Nel corso di questo articolo, /dev/hdXY sarà utilizzato come una partizione generica. È necessario sostituirla con il nodo del dispositivo effettivo per la partizione, come /dev/hdb1 per la prima partizione del disco slave primario o /dev/sda2 per la seconda partizione del primo disco SCSI o Serial ATA.

Usare le utilità tune2fs e e2fsck

Prima di iniziare, assicurarsi di avere dimestichezza con lo strumento tune2fs per modificare le opzioni dei filesystem di una partizione ext2 o ext3. Leggere attentamente la pagina man tune2fs:

$ man tune2fs

È generalmente una buona idea eseguire un controllo del filesystem utilizzando l'utilità e2fsck dopo aver completato le modifiche desiderate in un filesystem. In questo modo si verifica che il filesystem sia pulito ed eventualmente corretto, se necessario. Si dovrebbe anche leggere la pagina del manuale per l'utilità e2fsck, se non lo si è ancora fatto:

$ man e2fsck

WARNING: SOLO DISPOSITIVI SMONTATI: Assicurarsi che tutti i filesystem siano smontati prima di modificarli con le utilità tune2fs o e2fsck! Avviare da LiveCD come Archie o Knoppix se non si può fare diversamente. L'alterazione o la messa a punto di un filesystem mentre è montato può causare gravi danneggiamenti! Siete stati avvertiti!

Utilizzo di indicizzazione Directory

Questa funzione migliora l'accesso ai file nelle directory di grandi dimensioni o directory contenenti molti file utilizzando un sistema di hash binari per memorizzare le informazioni della directory. È perfettamente sicuro da usare e fornisce un miglioramento sostanziale nella maggior parte dei casi, quindi è una buona idea abilitarlo:

# tune2fs -O dir_index /dev/hdXY

Questo avrà effetto solo con le directory create su quel filesystem dopo aver eseguito tune2fs. Per applicare questa funzionalità alle directory esistenti, si deve eseguire l'utilità e2fsck per ottimizzare e reindicizzare le directory sul filesystem:

# e2fsck -D -f /dev/hdXY

Note: Questo dovrebbe funzionare sia con filesystem ext2 che ext3. A seconda delle dimensioni del file system, l'operazione potrebbe richiedere molto tempo.

Note: L'indicizzazione della directory è attivata per impostazione predefinita in Arch Linux per mezzo di /etc/mke2fs.conf

Enable Full Journaling

By default, ext3 partitions mount with the 'ordered' data mode. In this mode, all data is written to the main filesystem and its metadata is committed to the journal, whose blocks are logically grouped into transactions to decrease disk I/O. This tends to be a good default for most people. However, I've found a method that increases both reliability and performance (in some situations): journaling everything, including the file data itself (known as 'journal' data mode). Normally, one would think that journaling all data would decrease performance, because the data is written to disk twice: once to the journal then later committed to the main filesystem, but this does not seem to be the case. I've enabled it on all nine of my partitions and have only seen a minor performance loss in deleting large files. In fact, doing this can actually improve performance on a filesystem where much reading and writing is to be done simultaneously. See this article written by Daniel Robbins on IBM's website for more information.


There are two different ways to activate journal data mode. The first is by adding data=journal as a mount option in /etc/fstab. If you do it this way and want your root filesystem to also use it, you should also pass rootflags=data=journal as a kernel parameter in your bootloader's configuration. In the second method, you will use tune2fs to modify the default mount options in the filesystem's superblock:

# tune2fs -O has_journal -o journal_data /dev/hdXY

Please note that the second method may not work for older kernels. Especially Linux 2.4.20 and below will likely disregard the default mount options on the superblock. If you're feeling adventurous you may also want to tweak the journal size. (I've left the journal size at the default.) A larger journal may give you better performance (at the cost of more disk space and longer recovery times). Please be sure to read the relevant section of the tune2fs manual before doing so:

# tune2fs -J size=$SIZE /dev/hdXY

Disable Lengthy Boot-Time Checks

WARNING: Only do this on a journaling filesystem such as ext3. This may or may not work on other journaling filesystems such as ReiserFS or XFS, but has not been tested. Doing so may damage or otherwise corrupt other filesystems. You do this AT YOUR OWN RISK.

Hmm..It seems that our ext3 filesystems are still being checked every 30 mounts or so. This is a good default for many because it helps prevent filesystem corruption when you have hardware issues, such as bad IDE/SATA/SCSI cabling, power supply failures, etc. One of the driving forces for creating journaling filesystems was that the filesystem could easily be returned to a consistent state by recovering and replaying the needed journaled transactions. Therefore, we can safely disable these mount-count- and time-dependent checks if we are certain the filesystem will be quickly checked to recover the journal if needed to restore filesystem and data consistency. Before you do this please make sure your filesystem entry in /etc/fstab has a positive integer in its 6th field (pass) so that it is checked at boot time automatically. You may do so using the following command:

# tune2fs -c 0 -i 0 /dev/hdXY

If you just want to limit the checks to happen less often without totally disabling them (for peace of mind). A great method is to change from a number of count's check to a time frame check. See the man. Here is once every month...

# tune2fs -c 0 -i 1m /dev/hdXY

Reclaim Reserved Filesystem Space

Ext3 partition contain a used space of 5% for special reasons by default. The main reason for such space is so root can log in even when the filesystem becomes 100% used. Without this option, the root user might not be able to log in to "clean up" because the system could become unstable, trying to write logs to a 100% full system for example. The other reason is to help with less fragmentation on the filesystem.

The issue with this is that hard drives are getting so big the 5% can add up to be quite a large amount of wasted space. (eg. 100 GB = 5 GB reserved). Now if you separate your filesystems to like /home for example it might be a good idea to adjust these and reclaim that wasted space. It's a safe bet to leave your / filesystem at 5% reserved just in case. Leave reserved space for filesystems containing /var and /tmp also or else you'll end up with problems.

Now to change your reserved space to 1% of the drive, which is fair for non-root filesystems.

# tune2fs -m 1 /dev/sdXY

Assigning a Label

Once you have created and formated a partition, you can assign it a label using the e2label command. This allows you to add the partition to /etc/fstab using a label instead of using a device path (usefull for an USB drive). To add a label to a partition, type the following command as root:

   e2label /dev/sdXY new-label

If the optional argument new-label is not present, e2label will simply display the current filesystem label. If the optional argument new-label is present, then e2label will set the filesystem label to be new-labelq. Ext2 and ext3 filesystem labels can be at most 16 characters long; if new-label is longer than 16 characters, e2label will truncate it and print a warning message.

User experiences

I never had problems with these tips on large (>750) filesystems. Disabling lengthy boot-time works fine as well.


I get filesystem errors even with this tips. Do not disable lengthy Boot-Time

If you have some big partitions, do not enable full journaling on them. I experienced reproducible freezes (about 30 seconds) when enabling this on my 250gb home partition.

Did you try tweaking bdflush as described by Daniel Robbins?