Introduction to Linux File system

Source: Internet
Author: User

Introduction to the hard Drive interface:
    1. IDE:并行接口,133MB/s       2. SCSI:并行接口,Ultrascsi320, 320MB/S, UltraSCSI640, 640MB/S    3. SATA:串行接口,6gbps    6g/8  GB/S      4. SAS:串行接口,6gbps  是SCSI升级版

Parallel interface transmission rate is slow because the parallel is prone to electromagnetic interference, so only low frequency
Serial interface Although only one device can be high frequency, so speed than parallel block

Mechanical hard Drive diagram:

MBR Introduction:

The Master boot record (Mbr,main boot recording) is the boot code at the front of the disk. It is responsible for the identification of partition legitimacy and the location of partition guidance information when disk operating system reads and writes disk.
The MBR is divided into three parts:

    1. 446bytes:bootloader, programs, boot operating system programs;
    2. 64bytes: Partition table, each 16bytes to identify a partition, a total of only 4 partitions;
    3. The validity of the 2BYTES:MBR area is identified; 55AA is effective;
Block Partitioning tool fdisk

CENTOS6 start from cylinder
Centos7 start from sector

Common Options Introduction

N: Create a new partition
D: Delete an existing partition
T: Modify the partition type
L: View all already ID
W: Save and exit
Q: Do not save and exit
M: View Help information
P: Show existing partition information

Create an extended partition
 [[email protected] ~]# Fdisk/dev/sdbcommand (M for help): Npartition Type:p Primary (3 primary, 0 Extende D, 1 free) e extendedselect (default e): Eselected partition 4First sector (46528512-62914559, default 46528512): Using Default value 46528512Last sector, +sectors or +size{k,m,g} (46528512-62914559, default 62914559): +1gpartition 4 of type Extended and of size 1 GiB is SetCommand (M for help): pdisk/dev/sda:32.2 GB, 32212254720 bytes, 62914560 sectorsunits = Sectors of 1 * bytessector size (logical/physical): bytes/512 bytesi/o size (minimum/optimal): bytes /Bytesdisk label Type:dosdisk identifier:0x00099ba6 Device Boot Start End Blocks Id system/ DEV/SDA1 * 2048 391167 194560, linux/dev/sda2 391168 4585471 2097152 Swap/solaris/dev/sda3 4585472 46528511 20971520 linux/dev/sda4 46528512 48625663 10485 5 Extended  
adding logical partitions
Command (m for help): nPartition type:   p   primary (3 primary, 0 extended, 1 free)   e   extendedSelect (default e): eSelected partition 4First sector (46528512-62914559, default 46528512):Using default value 46528512Last sector, +sectors or +size{K,M,G} (46528512-62914559, default 62914559): +5GPartition 4 of type Extended and of size 5 GiB is set

W Save partition operation

To brush the partition information to the kernel
[[email protected] ~]# partx -a /dev/sdapartx: /dev/sda: error adding partitions 1-3[[email protected] ~]# partx -a /dev/sdapartx: /dev/sda: error adding partitions 1-6[[email protected] ~]# partx -a /dev/sdapartx: /dev/sda: error adding partitions 1-6#删除操作 慎用#[[email protected] ~]# partx -d /dev/sda6#查看[[email protected] ~]# cat /proc/partitionsmajor minor  #blocks  name   8        0   31457280 sda   8        1     194560 sda1   8        2    2097152 sda2   8        3   20971520 sda3   8        4          1 sda4   8        5    2097152 sda5   8        6    1048576 sda6   8       16   10485760 sdb  11        0    1048575 sr0

Finish creating the partition faster, then go on to create the file system on the partition fast

File system diagram

Inode View

[[email protected] ~]# ls -i33574978 anaconda-ks.cfg

Meta Data View

[[email protected] ~]# stat anaconda-ks.cfg  File: ‘anaconda-ks.cfg’  Size: 1587        Blocks: 8          IO Block: 4096   regular fileDevice: 803h/2051d  Inode: 33574978    Links: 1Access: (0600/-rw-------)  Uid: (    0/    root)   Gid: (    0/    root)Context: system_u:object_r:admin_home_t:s0Access: 2018-04-22 06:29:43.493008377 -0400Modify: 2018-04-22 06:29:43.494008377 -0400Change: 2018-04-22 06:29:43.494008377 -0400 Birth: -
VFS Classification (Virtual File System)

Linux file system: ext2 (no log function), ext3, Ext4, XFS, ReiserFS, Btrfs
Disc: iso9660
Network File System: NFS, CIFS
Cluster file system: GFS2, OCFS2
Kernel-level Distributed File system: Ceph
Windows file System: VFAT, NTFS
Pseudo file system: Proc, SYSFS, Tmpfs, hugepagefs
UNIX File systems: UFS, FFS, JFS
Swap file system: Swap
Distributed file system for user space: MogileFS, Moosefs, Glusterfs

Concrete implementation of MKE2FS

MKE2FS Common Options

Mke2fs [OPTIONS] device
-t {EXT2|EXT3|EXT4}: Indicates the type of file system to be created
Mkfs.ext4 = mkfs-t Ext4 = mke2fs-t ext4< br>-b {1024|2048|4096}: Indicates the block size of the file system;
-L LABEL: Indicates the volume label;
-j: Create a file system with logging capability ext3;
Mke2fs-j = mke2fs-t ext3 = mkfs-t ext3 = Mkfs.ext3
-i #:bytes-per-inode, which indicates the ratio of inode to byte, that is, each number of bytes creates a indode;
-N #: Directly indicates the number of inode to be created for this file system;
-M #: Specifies the reserved space, percentage, default 5%
-O [^]feature: Creates a target file system with the specified attributes;

# 格式化会损坏原有数据,慎用[[email protected] ~]# mkfs.ext4 /dev/sda5mke2fs 1.42.9 (28-Dec-2013)Filesystem label=OS type: LinuxBlock size=4096 (log=2)                            #每块大小Fragment size=4096 (log=2)     Stride=0 blocks, Stripe width=0 blocks131072 inodes, 524288 blocks                       #inode数量  block数量26214 blocks (5.00%) reserved for the super user   #超级块First data block=0                                 #编号始Maximum filesystem blocks=536870912                #编号末16 block groups                                    #块组32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks:               #超级块备份地址    32768, 98304, 163840, 229376, 294912 Allocating group tables: doneWriting inode tables: doneCreating journal (16384 blocks): doneWriting superblocks and filesystem accounting information: done

View Inode Size

[[email protected] ~]# dumpe2fs -h /dev/sda5 |grep node
数据块大小:524288*4096/1024/1024/1024 = 2Ginode数据大小:131072*256 /1024/1024 = 32M   #所以是先有数据块,从数据块中提取部分作为inode

Volume label setting:

[[email protected] ~]# e2label /dev/sda5mydata[[email protected] ~]# e2label /dev/sda5 MYDATE[[email protected] ~]# e2label /dev/sda5MYDATE

Blkid viewing file format types

[[email protected] ~]# blkid /dev/sda5/dev/sda5: UUID="18003fb5-93d9-4822-b998-0f2f99323798" TYPE="ext4"
TUNE2FS View or modify some properties of the EXT series file system

Common options

-j:ext2-ext3;
-L LABEL: Modify the volume label;
-M #: Adjust the percentage of reserved space;
-O [^]feather: Turn on or off a feature;
-O [^]mount_options: Turn on or off a default mount option

#查看块使用情况

[[email protected] ~]# tune2fs -l /dev/sda5   

Set ACL properties Setfacl getfacl attribute

[[email protected] ~]# tune2fs -o acl  /dev/sda5[[email protected] ~]# tune2fs -l /dev/sda5 |grep ‘Default mount options‘[[email protected] ~]# tune2fs -o ^acl  /dev/sda5
Self Test Tool e2fsck

Common options

-Y: Answer all questions automatically for Yes;
-F: Force detection even if the file system is in clean state;

[[email protected] ~]# e2fsck /dev/sda5e2fsck 1.42.9 (28-Dec-2013)MYDATE: clean, 11/131072 files, 69339/2097152 blocks
Mount Tool Mount

Common options

-r:readonly, read-only mount;
-w:read and write, read-write Mount;
-N: By default, the device mount or unload operation is updated synchronously to the/etc/mtab file; n is used to prohibit this feature;
-T Vfstype: Indicates the type of file system on the device to be mounted, and in most cases can be omitted, at which point mount will determine the file system type of the device to be mounted by blkid;
-L LABEL: Specifies the device as a volume label when mounted;
Mount-l LABEL dir
-U UUID: Specifies the device as a UUID when mounted;
Mount-u UUID dir
-O Options: Mount options
Sync/async: synchronous/asynchronous operation;
Atime/noatime: Whether a file or directory updates its access timestamp when it is accessed;
Diratime/nodiratime: Whether the directory updates its access timestamp when it is accessed;
Remount: Re-mount;
ACL: Support the use of FACL function;
RO: Read-only
RW: Read and Write
Dev/nodev: Whether to create device files on this device; Mknod
Exec/noexec: Whether the program files on this device are allowed to run;
Auto/noauto: whether to mount automatically
User/nouser: Whether to allow ordinary users to mount the file system;
Suid/nosuid: Allow suid and Sgid special permissions on program files to take effect;
Relatime:mtime Update atime optimization function compared to atime time new
Defaults:use default OPTIONS:RW, suid, Dev, exec, auto, nouser, async, and Relatime.

Mount

[[email protected] mnt]# mount /dev/sda5 t1/[[email protected] t1]# mount |grep ‘t1‘/dev/sda5 on /mnt/t1 type xfs (rw,relatime,seclabel,attr2,inode64,noquota)

Unloading

[[email protected] mnt]# umount t1/[[email protected] mnt]# umount /dev/sda5

Force Uninstall

[[email protected] mnt]# fuser -km t1

Introduction to Linux File system

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.