1、 Review partitions and file systems

1.1 Partition type

Primary partition : All in all, it can only be divided into 4 individual

Extended partitions : There can only be one , It's also a kind of main partition , That is to say, the maximum number of primary partitions plus extended partitions is 4 individual . But the extended partition cannot store data and format , It must be subdivided into logical partitions before it can be used

       A logical partition : Logical partition is the partition in extended partition , If it is IDE Hard disk ,Linux Most support 59 Logical partitions , If it is SCSI Hard disk ,Linux Most support 11 Logical partitions .

1.2 Partition representation

       Device file name of the partition

              Primary partition 1        /dev/sda1

              Primary partition 2        /dev/sda2

              Primary partition 3        /dev/sda3

              Extended partitions        /dev/sda4

              A logical partition 1     /dev/sda5

              A logical partition 2     /dev/sda6

              A logical partition 3     /dev/sda7

       Device file name of the partition

              Primary partition 1        /dev/sda1

              Extended partitions        /dev/sda2

              A logical partition 1     /dev/sda5

              A logical partition 2     /dev/sda6

              A logical partition 3     /dev/sda7

1.3 file system

       ext2 yes ext Upgrade version of the file system ,RedHatLinux7.2 Before version, the system default is ext2 file system .1993 Released in , The biggest support 16TB Partition and maximum 2TB The file of (1TB=1024GB=1024*1024KB).

       ext3 yes ext2 Upgrade version of the file system , The biggest difference is with log function , To improve the reliability of the file system when the system suddenly stops . Maximum support 16TB Partition and maximum 2TB The file of .

       ext4 yes ext3 Upgrade version of the file system .ext4 In performance 、 A lot of improvements have been made in terms of scalability and reliability .ext4 The change of can be said to be earth shaking , For example, downward compatibility ext3、 Maximum 1EB And 16TB The file of 、 Wireless number subdirectory ,Extents Continuous block concept , Multi block allocation 、 Delayed allocation 、 Persistent preallocation 、 Fast FSCK、 Journal checksumming 、 No log mode 、 Online defragmentation 、inode enhance 、 Enabled by default barrier etc. . yes CentOS6.3 Default file system for (1EB=1024PB=1024*1024TB).

2、 File system common commands

2.1 df command 、du command 、fsck Command and dump2fs command

2.1.1 File system view command df

       $ df -ahTmk Mount point

              -a    Show all file system information , Including the filing system of the trust letter , Such as /proc、/sysfs

-h    Use custom units to display capacity , Such as KB,MB or GB etc.

-T    Show file system type

-m   With MB Show capacity in units

-k    With KB Show capacity in units . Default is to KB In units of

2.1.2 Statistics directory and file size

       $ du -ahs Directory or filename

              -a    Display the disk usage of each sub file . By default, only the disk usage of subdirectories is counted

-h    Use custom units to display disk usage , Such as KB,MB or GB etc.

-s     Count the total consumption , The usage of subdirectories and sub files is not listed

2.1.3 du Command and df Ming Lin's difference

       df Commands are considered from the file system , It's not just about the space the file takes up , Also count the space occupied by commands or programs ( The most common is that the document has been produced , But the program doesn't release space )

       du The command is file oriented , Only the space occupied by a file or directory is calculated

2.1.4 File system repair command fsck  

       $ fsck -ay Partition device filename

              -a    Don't show user tips , Auto repair file system

              -y    Auto repair . and -a It can inhibit , But some file systems only support -y

2.1.5 Display disk status command dumpe2fs

       $ dumpe2fs Partition device filename

2.2 Mount command

2.2.1 Query with auto mount

       $ mount -l             Query the system for mounted devices ,-l The volume label name is displayed

       $ mount -a             According to the configuration file /etc/fstab The content of , Automatically mount

2.2.2 Mount the command format

       $ mount [-t file system ] [-L Volume label ] [-o Special options ] Device file name Mount point

              -t file system           Add file system type to make mount type , Sure ext3( Hard disk )、ext4( Hard disk )、iso9660( CD drive ) Equal file system

              -L Volume label              The partition attached to the specified volume label , Instead of installing device file name mount

              -o Special options          Additional options for mounting can be specified

 

       mount -o Special options             Here's a list of common mount Special options

              atime/noatime        Update access time / Do not update access time . When accessing partition files , Whether to update the access time of the file , The default is update

              async/sync             asynchronous / Sync , The default is asynchronous

            auto/noauto            Automatically / Manual ,mount -a When the order is executed , Whether it will be installed automatically /etc/fstab File content mount , The default is automatic

              defaults                 Define default values , amount to rw, suid, dev, exec, auto, nouser, async These seven options

exec/noexec           perform / Don't execute , Set whether executable files are allowed to be executed in the file system , The default is exec allow

              remount               Remount the mounted file system , It is generally used to specify special permission to modify

              rw/ro                    Reading and writing / read-only , When the file system mounts , Whether you have read and write permissions , The default is rw

              suid/nosuid            have / No SUID jurisdiction , Set whether the file system has SUID and SGID Authority , The default is to have

              user/nouser            allow / Ordinary users are not allowed to mount , Set whether the file system allows ordinary users to mount , Not allowed by default , Only root You can mount partitions

              usrquota                Write represents that the file system supports user disk quotas , Not supported by default

              grpquota                Write represents the disk quota of the file system support group , Not supported by default

 

       $ mount -o remount,noexec /home                     Re mount /boot Partition , And use noexec jurisdiction

       $ cd /home

       $ vi hello.sh

       $ chmod 755 hello.sh

       $ ./hello.sh

       $ mount -o remount,exec /home                  Remember to change it back , Otherwise, it will affect the system startup

2.3 Mount CD and U disc

2.3.1 Mount the cd-rom

       $ mkdir /mnt/cdrom                                         Set up the hardpoint

       $ mount -t iso9660 /dev/cdrom /mnt/cdrom         Mount the cd-rom

       $ mount /dev/sr0 /mnt/cdrom                             Same as the previous order

2.3.2 Unload command

       $ umount Device file name or mount point                        Compact disc 、U Disk and other media , You need to remove the load first

              $ umount /mnt/cdrom

2.3.3 mount U disc

       $ fdisk -l                                                  see U Disk device file name

       $ mount -t vfat /dev/sdb1 /mnt/usb/             mount U disc       

              Be careful :Linux Not supported by default NTFS File system

2.4 Support NTFS file system

2.4.1 download NTFS-3G plug-in unit

       http://www.tuxera.com/community/ntfs-3g-download/

2.4.2 install NTFS-3G

       $ tar -zxvf ntfs-3g_ntfsprogs-2013.1.13.tgz         decompression

       $ cd ntfs-3g_ntfsprogs-2013.1.13                       Go to unzip directory

       $ ./configure                                                    Compiler ready . Installation directory not specified , Install to default location

       $ make                                                            compile

       $ make install                                                  Compilation and installation

2.4.3 Use

       $ fdisk -l                                                         see NTFS Format hard disk file name

$ mount -t ntfs-3g Partition device filename Mount point       mount NTFS Hard disk

3fdisk Partition

3.1 fdisk Command partitioning process

3.1.1 Add a new hard disk

      

3.1.2 View new hard disk

       $ fdisk -l

3.1.3 Use fdisk Command partition

       $ fdisk /dev/sdb/

 

       fdisk Instructions for interaction

       a      Set bootable flag

       b     edit bsd Disk label

       c      Set up DOS Operating system compatibility flag

       d     Delete a partition

       l      Show known file system types .82 by Linux swap Partition ,83 by linux Partition

       m    Show the guild leader menu

       n     New partition

       o     Create gaps DOS Partition table

       p     Show a list of partitions

       q     Exit without saving

       s      New blank SUN Disk label

       t      Change a partitioned system ID

       u     Change the reality record unit

       v     Verify partition table

       w     Save and exit

       x     Additional features

3.1.4 Reread partition table information

       $ partprobe

3.1.5 format partition

       $ mkfs -t ext4 /dev/sdb1               Only primary and logical partitions can be formatted , No way to expand the partition

3.1.6 Set up mount point and mount

       $ mkdir /disk1

       $ mount /dev/sdb1 /disk1/

3.2 Partition auto mount and fstab Repair

3.2.1 /etc/fstab file

       The first 1 Field : Partition device files or UUID( Universal unique ID of hard disk )

       The first 2 Field : Mount point

       The first 3 Field : file system name

       The first 4 Field : Mount parameters

       The first 5 Field : Specifies whether the partition is dump Backup ,0 No backup ,1 Represents daily backup ,2 Represents irregular backup

       The first 6 Field : Determine whether the zoning is fsck testing ,0 For not testing , Other numbers represent the priority of detection , Well, of course. 1 The priority ratio 2 high

3.2.2 Partition auto mount

       $ vi /etc/fstab

              /dev/sdb1        /disk1             ext4        defaults          1 2

       $ mount -a             According to the configuration file /etc/fstab The content of , Automatically mount

3.2.3 /etc/fstab File repair

       $ mount -o remount,rw /

4. Distribute swap Partition

4.1 free command

       $ free             Check memory and swap Partition usage

       cached( cache ) It means to save the read data in memory , When reading again , Read directly from memory instead of hard disk , Speed up the data reading process

       buffer( buffer ) When writing data is , First, save the scattered write operations to memory , When it reaches a certain level, write to the hard disk again , Reduced disk fragmentation, repeated finding of kernel hard disk , Speed up the data writing process .

4.2 newly build swap Partition

       $ fdisk /dev/sdb             Don't forget to partition ID Change it to 82

4.3 format

       $ mkswap /dev/sdb6

4.4 Join in swap Partition

       $ swapon /dev/sdb6       Join in swap Partition

       $ swapoff /dev/sdb6       Cancel swap Partition

4.5 swap Partition boot automatically mount

       $ vi /etc/fstab

       /dev/sdb6        swap       swap      defaults          0 0

1、 Review partitions and file systems