Linux hard disk partition partition and file system management

Source: Internet
Author: User

File System Focus: Inode (Index node), block (logical block), Superblock (the block where each file system starts, for storing information such as the size of the file system, empty or filled chunks, and its respective totals, etc.)

Physical composition of the disk:
Circular disk Disc
Robotic arm, with a disk reading head on the robotic arm (rewritable disk data)
Spindle motor, can rotate disk, let the machine arm's reading head read and write data on disk drive

Physical composition of disk disks:
Sector (sector) is the smallest physical storage unit with 512bytes per sector
The sector is composed of a circle, that is, the magnetic column, the magnetic column is the smallest unit of partition
The first sector is the most important, there is MBR (main boot area) and partition table, wherein the MBR occupies 446bytes, and the partition table occupies 64bytes

Disk partitioning: Specify the start and end of a partition's magnetic column

The magnetic column range of a partition is recorded in the split table of the first sector

Inode: The permissions and attributes are stored:

 ?  The owner and group of the file (Owner/group);

? The access mode of the file (Read/write/excute);

? The type of the file (type);

? The time the file was established or changed (CTime), the last Read time (atime), the time of Near modification (mtime);

? The capacity of the file;

? Flags (flag) defining the profile characteristics, such as SetUID ... ;

? The direction of the real content of the file (pointer);

Data block: Storing the actual information
Superblock: Records the entire file system overall information, including the inode and block of the total, usage, amount of surplus, etc.

Since ext2 is an indexed file system, it is often not necessary to defragment often

If the hard disk file system is up to hundreds of GB, it would be unwise to put all the inode together with the block, because the number of inode and block is too large to manage, so the ext2 file system is basically differentiated into multiple block groups when formatted (block Group), each block group has its own inode/block/superblock system

A filesystem has only one superblock; except for the first block group that contains Superblock, the subsequent block group does not necessarily contain superblock, If it contains Superblock, the superblock is primarily a backup of Superblock in the first block group and can be used for superblock rescue.

DUMPE2FS/DEV/HDA2: Viewing information for hda2 partitions and Superblock

The directory does not only occupy a block, that is to say: Under the directory of the number of files if too many so that a block can not accommodate all the file name and Inode table, Linux will give the directory more than one block to continue to record the first closed data

If the file is too discrete, you can copy all the data in the filesystem, then reformat the file system, then the data can be copied back to solve the problem

journaled file system: ext3:
Preparation: When the system is going to write a file, it will now record the information that a file prepares to write in the log record block.
Actual write: Start writing permissions and data at the time; start updating metadata data
End: After completing the update of the data domain metadata, complete the record of the file in the log record block
When the file system is inconsistent, the system only need to check the log record block, you can find the abnormal file, and then for the file consistency check, and not for the whole block filesystem to check, to achieve the ability to quickly repair filesystem

The common supporting file systems are:
Traditional file system: Ext2,mimix,ms-dos,fat (with VFAT module), iso9660 (CD-ROM), etc.
journaled file system: Ext3,reiserfs,windows ' SNTFS,IBM ' s Jfs,sgi's XFS
Network File system: NFS,SMBFS

The standard file system for Linux is ext2

View Linux supported file systems: ll/lib/modules/$ (UNAME-R)/kernel/fs

View system currently loaded into memory supported file systems: Cat/proc/filesystems

Hard link (cannot cross filesystem, cannot link directory): Generate new file name via inode link of filesystem, not create new file
Soft Link: Equivalent to a shortcut under Windows

Create a link file: Ln [-sf] source file destination file

Linux repartitioning may require a reboot to update the core partition table, or it can be executed with the following command without restarting: The role of Partprobe;partprobe is that the core of the higher vocational School must read the new partition table.

Hard disk partition, preferably in the single-player maintenance mode is more secure, when you do fdisk, if a partition of the hard disk is still in use, it is likely that the system core can not reload the hard disk partition table, The solution is to love the partition in the use of the removal, and then re-enter Fdisk again, re-write partition table, you can succeed

Partition: Fdisk

FDISK has no way to handle disk partitions larger than 2TB! Although the ext3 file system has supported disks above 16TB, the split instruction is not supported; you need to use the parted directive

Disk Format: MKFS
Mkfs–t EXT3/DEV/HDA3: Format/dev/hda3 as ext3 file system
VFAT can be used in Windows/linux shared U-Disk

Disk Inspection: Fsck,badblocks

Fsck–c–f–t EXT3/DEV/HDC6: Verifying disk/dev/hdc6
-C: Show progress
-F: Forced check
-T: Specify File System format

FSCK is an instruction used to check and fix file system errors. Note: This command is usually used only when root is a problem with your filesystem, otherwise it can be harmful to the system if you use this instruction under normal circumstances! Usually the use of this command is the case of the system has a great problem, so that you have to enter the Linux when booting into single-machine mode for maintenance behavior, you must use this command

If you suspect a problem with the hard drive you just formatted, you can also use fsck to check the hard drive! In addition, because fsck may cause some filesystem damage while scanning the hard drive, the inspected partition must not be mounted on the system when FSCK is executed! That is, it needs to be in the state of removal.

Lost+found: This directory is the directory where the problematic data will be placed if there is a problem when you use fsck to check the file system! Theoretically this directory should not have any data

Badblocks: Used to check the hard disk or floppy disk sector there is no bad track instructions
Badblocks–svw/dev/hda3
-S: List progress on the screen
-V: You can see the entry on the screen
-W: Test with Write, it is recommended not to use this parameter, especially when the device to be inspected has a file

Linux supported file system drivers are located in the directory:/LIB/MODULES/2.6.18-238.EL5/KERNEL/FS

Mount: Mount (example:)
Mount/dev/hdc6/mnt/hdc6
Mount–t Iso9660/dev/cdrom/media/cdrom
Mount–t Vfat–o Iocharset=cp950/dev/sda1/mnt/flash
Mount–o Loop Test.iso/mnt/dvd (ISO mount, the ISO file can be modified, this is why many ISO files are provided, but also to provide a verification code (MD5) to the user to confirm the ISO file is not a problem)

If you want to change the mount parameter, or when the root directory is read-only, how do I reload it? The most likely way to do this is to reboot;
Will/re-mount and add parameter RW with auto
Mount–o Remount,rw,auto/
The point is that-oremount,xx's options and Parameters! Please note that this is a very important mechanism to re-mount! Especially when you enter the single-player maintenance mode, your root directory is often read by the system mount bit, this time this command is too important

Umount: Uninstalling
UMOUNT–FN device file name or mount point
-F: Forced removal! can be used in situations like Network File System (NFS) that cannot be read
-N: Dismount without updating/etc/mtab

DUMPE2FS–H/DEV/HDC6: Viewing partition information

Boot mount:/etc/fstab Profile entry:
Disk Appliance file name or label for the appliance
Mount point
File system for disk partitioning
File system Parameters
Can be played by dump backup instructions
Whether to test sectors with fsck

Extended Swap partition:
1. Split: First use FDISK to partition the disk into a system as swap. Since the Linux fdisk preset will set the partition ID to the Linux filesystem, you need to set the system ID
2. Format: Using the Mkswap device file name in the established swap format, you can format the partition as the swap format
Mkswap/dev/hda4
3. Use: Finally start the swap device by: Swapon device file name
Swapon/dev/hda4
4. Observation: Finally, through the free command to observe the amount of memory

Use file to build swap:
1. DD If=/dev/zero of=/home/swapbs=1m count=512
2. Mkswap/home/swap
3. Swapon/home/swap | Swapoff/home/swap

Superblock size is 1024bytes
Superblock front need to keep 1024bytes down so that the boot manager can install

parted (partition of more than 2t hard drives):
PARTED/DEV/HDA Print: Viewing partitions
Parted/dev/had mkpart logical Ext3 19.2G 19.7G: Establishing logical partitions
Parted/dev/had RM 8: Deleting partitions

Inode Bitmap:inode Table (total number of inode, usage, remainder)
Inode table:inode table (inode points to block)

Boot automatically mount can refer to/etc/fstab settings, set up must use MOUNT–A test syntax correct no

Linux hard disk partition partition 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.