文档库 最新最全的文档下载
当前位置:文档库 › Linux文件系统方案

Linux文件系统方案

文档标题文档模板01 文档副标题

DEV-07-001

Version 1.0

2015-03-01

文档控制页面编写/修改

审阅

Linux 磁盘与文件系统

一、硬盘

硬盘主要是有许多的圆形硬盘片组成,按照盘片能够容纳的数据量,分为单盘和多盘的硬盘

硬盘的容量公式:柱面*磁头*扇区*512字节,512字节就是每个扇区的大小

硬盘的分区

分区的起始和结束柱面的数据放在主引导分区,即MBR.MBR就是在一块硬盘上的第0个轨道上,这也是计算机启动之后要去使用硬盘室必须要读的第一个区域。这个分区记录了硬盘的分区信息,以及启动可以写入引导程序的位置。MBR的最大限制是,他得大小不能道道存储所有分区和引导信息,因此mbr仅提供最多四个分区记忆。这就是主分区P与扩展分区E,如果超过四个就必须使用3P+E来完成。

文件系统:

每一个分区就是一个文件系统。

逻辑块是在分区进行文件系统格式化时所指定的最小存储单位,这个最小存储单位室以扇区大小为基础的(扇区为硬盘的最小物理存储单位),所以块的大小就是扇区大小的2的n次方倍。

块的规划k考虑的问题:

。文件读取效率

。文件大小可能造成硬盘空间浪费

因此在规划磁盘的时候,需要考虑到主机的用途。例如bbs主机由于文章较短,也就是说文件小,那么块小一点;如果主机主要用于存储文件,那么考虑效率,块就大一点。

二、LINUX的ext2/ext3/ext4文件系统

Ext3文件系统时ext2文件系统的升级版。Ext4 是在ext3的基础之上开发出来的

?Ext2 stands for second extended file system.

?It was introduced in 1993. Developed by Rémy Card.

?This was developed to overcome the limitation of the original ext file system.

?Ext2 does not have journaling feature.

?On flash drives, usb drives, ext2 is recommended, as it doesn’t need to do the over head of journaling.

?Maximum individual file size can be from 16 GB to 2 TB

?Overall ext2 file system size can be from 2 TB to 32 TB

Ext3

?Ext3 stands for third extended file system.

?It was introduced in 2001. Developed by Stephen Tweedie.

?Starting from Linux Kernel 2.4.15 ext3 was available.

?The main benefit of ext3 is that it allows journaling.

?Journaling has a dedicated area in the file system, where all the changes are tracked. When the system crashes, the possibility of file system corruption is less because of journaling.

?Maximum individual file size can be from 16 GB to 2 TB

?Overall ext3 file system size can be from 2 TB to 32 TB

?There are three types of journaling available in ext3 file system.

o Journal –Metadata and content are saved in the journal.

o Ordered –Only metadata is saved in the journal. Metadata are journaled only after writing the content to disk. This is the

default.

o Writeback –Only metadata is saved in the journal. Metadata might be journaled either before or after the content is written

to the disk.

?You can convert a ext2 file system to ext3 file system directly (without backup/restore).

Ext4

?Ext4 stands for fourth extended file system.

?It was introduced in 2008.

?Starting from Linux Kernel 2.6.19 ext4 was available.

?Supports huge individual file size and overall file system size.

?Maximum individual file size can be from 16 GB to 16 TB

?Overall maximum ext3 file system size is 1 EB (exabyte). 1 EB = 1024 PB (petabyte). 1 PB = 1024 TB (terabyte).

?Directory can contain a maximum of 64,000 subdirectories (as opposed to 32,000 in ext3)

?You can also mount an existing ext3 fs as ext4 fs (without having to upgrade it).

?Several other new features are introduced in ext4: multiblock allocation, delayed allocation, journal checksum. fast fsck, etc. All you need to know is that these new features have improved the

performance and reliability of the filesystem when compared to ext3.

?In ext4, you also have the option of turning the journaling feature “off”.

?Creating an ext2, or ext3, or ext4 filesystem

?Once you’ve partitioned your hard disk using fdisk command, use mke2fs to create either ext2, ext3, or ext4 file system.

?Create an ext2 file system:

?mke2fs /dev/sda1

?Create an ext3 file system:

?mkfs.ext3 /dev/sda1

?

?(or)

?

?mke2fs –j /dev/sda1

?Create an ext4 file system:

?mkfs.ext4 /dev/sda1

?

?(or)

?

?mke2fs -t ext4 /dev/sda1

?Converting ext2 to ext3

?For example, if you are upgrading /dev/sda2 that is mounted as /home, from ext2 to ext3, do the following.

?umount /dev/sda2

?

?tune2fs -j /dev/sda2

?

?mount /dev/sda2 /home

?Note: You really don’t need to umount and mount it, as ext2 to ext3 conversion can happen on a live file system. But, I feel better doing the conversion offline.

?Converting ext3 to ext4

?If you are upgrading /dev/sda2 that is mounted as /home, from ext3 to ext4, do the following.

?umount /dev/sda2

?

?tune2fs -O extents,uninit_bg,dir_index /dev/sda2

?

?e2fsck -pf /dev/sda2

?e4fsck -yfDC0 /dev/sda2

?mount /dev/sda2 /home

?Again, try all of the above commands only on a test system, where you can afford to lose all your data.

EXT4文件系统的特点

相关文档