linux--(4) disk and file system management

Source: Internet
Author: User

Concept One: Linux-ext2 file system

Ext2 is partitioned into multiple blocks (block group) and a boot sector (boot sector), with Superblock, File system Description, block bitmap, INode in each block Bitmap, INode table, data block six parts.

Boot sector: You can install the bootloader and use it to make a multi-boot environment.

Superblock: records the entire file system information about the size of the general 1024bytes, you can use DUMPE2FS to view. This is a file system that requires only one superblock, that is, the superblock within the first Blockgroup, and, if so, the first one back.

File System Description: describes the start of block group at the end of block and so on. Can be viewed with DUMPE2FS.

block bitmap: record those blocks are empty.

iNode Bitmap: Ibid.

inode Table:inode block, record file attributes, permissions, and the file is actually stored in that block. Each inode has a fixed size of 128bytes and each file will occupy at least one Inode,inode record block number when there are 12 direct, one indirect, one double indirect, one three indirect record area.

Data BLOCK: The location of the datastore, the size and quantity of the block are determined when the format is complete, and cannot be changed afterwards. Only one file can be placed in each block (so fragmented small files can sometimes waste a lot of space).

Other:

Data consistency checks occur when data is inconsistent in ext2, and is performed through E2FSCK.

The log file system (journaling file systems) is used in ext3 for quick fixes.

EXT4 is a ext3 improvement and performance enhancement, and does not incorporate significant new functionality.

about VFS (virtual filesystem switch): We did not show the file system type we used when we entered the file system, but the system still reads the file normally, because of the existence of VFS, It helped us choose the right file system to operate on.

Concept II: Two types of connection files

Hard Link: Just create a new file name in a directory to connect to an inode number of associated records, so in general, the creation of hard link will not cause the new inode and block is occupied, unless the directory to write new records is just full. Deleting any hard link does not affect the other hard link's reading of the file, nor does deleting the source file. Until all hard link is deleted, the source file is actually deleted. Hard link cannot cross a file system or connect to a directory.

Symbolic Link: and window shortcut very much like, will create a separate file, occupy the Inode and block,block the information that points to the source file name address, when the source files are deleted, these symbolic Link will all expire.

Related commands:

ln [-SF] Source file destination file #产生连接文件, by default, hard link is generated.

-S #加上这个参数, the symbolic link is produced.

-F #如果目标文件存在则删除然后再创建.

Concept three:the role and difference of/etc/fstab and/etc/mtab

/etc/fstab: records the static file system information, records the file system mount related information, when the boot, Linux will check this file, according to the inside record to mount the file system.

/etc/mtab: Dynamic recording of the current system mount, mount and Umount will affect their records.

Refer to the following blog for details

http://blog.163.com/[email protected]/blog/static/165119518201281892121501/

Simple operation of the file system:

Disk directory and Capacity:

DF [-ahti] directory or file name #列出文件系统的整体磁盘使用量, this information source is superblock, what directory does not write will default to all the file system, listing a directory or file system, the file system will be listed in the information.

-a #列出所有的文件系统, including system-specific/proc and other file systems.

-H #以人们较易阅读的GB, MB, KB and other formats to display themselves.

-T #连同该分区的文件系统名称也显示出来.

-I. #不用硬盘容量而是用iNode的数量来显示大小.

Du [-AHSS] directory or file name #统计目录与其子目录的大小, the current path is counted when the directory file name is not written.

-a #列出当前目录下所有目录下, including system-specific/proc and other file systems.

-H #以人们较易阅读的GB, MB, KB and other formats to display themselves.

-S #列出目录的总大小.

-S #不包括子目录下的统计信息, only the size of each directory "own" is counted.

partitioning, formatting, checking, and mounting of disks.

Disk Partitioning:

Fdisk [-l] Device name #之后会进入fdisk的菜单, you can complete the partition by following the menu.

-L #列出此设备的分区表.

Formatting:

MKFS [-T file System format name] The device file name #只需指定文件系统 and is initialized with the default settings.

If we want to define the file system's volume label, block size, inode number, we can use the following command.

MKE2FS [-B Block Size] [-I allocates one inode per number of bytes] [-l volume label] [-CJ] Device file name

-B #设置block大小, support 1024, 2048, 4096bytes.

-I. #每多少bytes分配一个iNode.

-L #卷标名称.

-C #写一个-C will perform a quick read test and write-c-c will perform read-write testing.

-j #不写j格式化为ext2, wrote the J format to ext3.

Disk Check:

fsck [-t file system] [-AAYC] Device name #用来检查与修正文件系统错误的指令, because fsck may cause damage to the file system when it scans the hard drive , so when using this command, the partition must be in a state that is not mounted .

-T #输入要检查的文件系统类型, now do not enter the normal line.

-A #依据 the contents of/etc/fstab, scan the device that needs to be scanned once.

-A #自动修复有问题的扇区 without manual confirmation.

-y #同a, but some file systems only support Y does not support a.

-C #可以显示一个直方图提示进度.

Badblocks [-SVW] #用于检查坏轨, but it is seldom used now because the process is generally present in the format stage.

-S #显示进度.

-V #显示进度.

-W #用写入的方式检查, not recommended.

Disk Mount and unload:

Mount #虽然参数很多, but generally can not be used, is really simple to use, this command can also be used to mount CD, DVD, u disk, floppy disk, in addition, when the system error, you can use this command to re-mount the directory.

Usage One: Mount [device Name/label (volume label)] directory [-o] #将设备挂载到目录上-O followed by additional commands, the command can be followed (part).

RO,RW: The file system is read-only, or read-write.

Async,sync: The file system uses asynchronous or synchronous memory mechanisms.

Auto,noauto: Allows the secondary partition to be automatically mounted by mount-a.

Dev,nodev: Whether to allow the creation of device files on this partition.

Suid,nosuid: Can include suid, sgid files.

Exec,noexec: Whether executable files can be included.

User,nouser: Is it possible for a general user to perform monut on this partition?

#注: The default value is Rw,suid,dev,exec,auto,nouser,async.

Usage II: MOUNT-A #依照配置文件/etc/fstab data will be mounted on all mounted devices.

Usage Three: Mount [-l] #只输入mount时, all mount information is listed, plus-l adds a label.

Usage Four: Mount-o remount,rw,auto/#单独列出这个是因为这个命令很有用, when the file system problems can be re-loaded with this command, which is written in the case of the re-mount root directory, in addition to some other parameters.

Umount device file name or mount point #卸载

Disk parameter modification:

Mknod device file name [bcp] [Major] [Minor] (set the main device number and secondary device number)

b #设置设备为一个外部存储设备, such as hard disk.

C #设置设备为一个外部输入输出设备, such as a mouse.

P #设置成fifo文件.

E2label Device name New Label # Modify volume label

TUNE2FS-J Device Name # can convert ext2 to ext3, and some other features are not listed.

hdparm [-TT] Device name #测试硬盘性能, in addition to the IDE interface hard disk has some role not described here.

-T #测试硬盘实际访问性能.

-T #测试cache access performance.

boot mount: directly modify/etc/fstab this file.

Special Equipment Loop mount: We can also mount the file, such as to mount an image file, so that we can directly read the internal files, or we create a large file, the file is formatted (with MKFS), the file is mounted, as a partition to use.

Mount-o Loop file mount point #将iso文件或者格式化过的文件挂载到挂载点.

Build swap: divided into four steps, partition (FDISK), Format (MKSWAP), use (Swapon,swapoff), view (free), of course we can also use the file to build swap, It is the special equipment mount that is said in 4.

Partition: The difference between the normal partition is that you need to modify the system ID to 82.

Format: Mkswap device name #格式化为swap.

Use: Swapon device name #启动.

Deactivate: Swapoff device name #停用.

View: Free #列出内存情况.

Other questions:

1, when the partition size is high and 2TB, you can not use Fdisk, need to use the GNU parted, temporarily do not introduce.

2,boot sector relationship to Super Block: Superblock and boot sector size are 1024bytes, when the block size is 1024, the first block is the boot sector, The second one is Superblock, when block is 2048, they will be in the same block.

linux--(4) disk and file system management

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.