Linux disk and file system management

Source: Internet
Author: User

▲ETX2 File System

Typically, the size of a sector is 512 bytes (byte=8 a bits)

The main point of partitioning is to record the starting and ending cylinders for each partition.

MBR (Master boot Recorder) provides a maximum of 4 partitions of memory

In order to improve the reading efficiency of the head, the concept of logical block 1BLOCK=2^N sector is used.

The block at the beginning of each file system is called the Super block. Super fast storage File system size, empty and full blocks, and other information

EXT2 plans the Inode and block to store the attributes of the archive (stored in the inode) and the contents of the archive (stored in the block area). When creating a directory on the Linux ext2 file system, the Ext2 file system gives the directory an inode and at least one block. When a file is created, Ext2 assigns at least one inode to the file and the number of blocks relative to that file size. The inode itself does not log file names, only the related properties of the files are recorded, and the file names are recorded in the block area to which the directory belongs.

Use DUMPE2FS to view information such as Inode

The block and inode are determined when formatted. The number of files that a partition can hold is related to the inode. The size of an inode is 128 bytes. The block is a fixed size, typically the size of the 1024/2048/4096 block, which determines the size of the block, depending on the type of file the partition is about to store.

▲inode recorded Information

Owner and group of the file (Owner/group)

Storage mode for this file (Read/write/excute)

The type of the file (type F,b,c,s,l,p,d)

Time of the archive (ctime,atime,mtime)

The file's capacity

Flags that define file characteristics (flag such as Suid,sgid)

Pointing to the true content of the archive (pointer)

.............

▲ Introduction of log-file system

When the system is going to write to a file, it is recorded in the log record block: A file is ready to be written to disk.

Permission and data to begin writing to the file

Start updating data for metadata

Complete the update of the data and metadata, complete the record in the log record block

Operation of the Linux file system: asynchronous. When a file is read, the block data in which the file resides is loaded into memory, and if the file data is modified, the data in memory is marked as "dirty" and the data on the disk has not been modified and needs to be written to disk to ensure consistency.

Load point: Must be a directory (can record the node and file name related information, and the files cannot), but not a file

Linux supported file systems view/proc/filesystems or/lib/modules/' uname-r '/kernel/fs

▲ Simple operation of file system

DF [-AHIKBMHT] [ directory or file name ] displays the total capacity of the current disk in the system, using the capacity and remaining capacity information

Parameter-a lists all file systems, including file systems such as/proc

Parameter-B displays each file system in bytes

Parameter-k displays each file system in Kbytes

Parameter-m displays each file system in MBytes units

Parameter-h displays each file system in an easier-to-read manner

Parameter-I does not use the hard disk capacity, but the number of inode to display

The-h parameter is displayed with m=1000k instead of m=1024k.

Parameter-t displays the file system name of the partition

du [-AHSKM] [file or directory name] View the size of the disk cartridge directory

Parameter-a lists all file and directory capacities

Parameter-h is displayed in an easy-to-read capacity format (g/m)

Parameter-s lists the total, not the capacity that each directory occupies

Parameter-K lists the capacity display in Kbytes

Parameter-M with MBytes listing capacity display

ln [-SF] [source file] [target file]

parameter-S If LN does not add any parameters, the hard link,-s is symbolic link (soft connection)

Parameter-F If the destination file exists, the target file is actively removed and then established

Hard link (rigid connection, actual connection) cannot cross filesystem, cannot link directory

Symbolic Link (symbolic link, shortcut) is the same as a shortcut to Windows

▲ disk segmentation, format, inspection and Mount

Fdisk [-l] [device name] lists all the partitions of the device that can be searched in the entire system.

Parameter-l outputs all partition contents of the device after

d Delete a disk partition

n a new disk partition

P list the current disk partition to

Q Do not store away

W write to disk partition table and leave

Partprobe

MKE2FS [-BICJL] [appliance name] make Ext2 file system

Parameter-B can set the size of each block, support 1024,2048.4096bytes three kinds of

Parameter-I how much capacity to give an inode

Parameter-c check for disk errors, quick read test

Parameter-c-c measurement reading and writing, slow speed

Parameter-j actively joins the log and becomes EXT3

Parameter-l followed by volume label name (Label)

fsck [-atcary] [appliance name]

The parameter-t fsck can check several different filesystem. Use ls–l/sbin/fsck* to check it out, you know there are several filesystem

Parameter-A according to the contents of the/etc/fstab, all the devices are scanned once. Normally the boot process is performed once

Parameter-a automatically fixes the problematic sectors that are checked, without always pressing Y

Parameter-R must let the user decide whether to repair

The parameter-y is similar to-a, but some filesystem only support the-y parameter

Parameter-C can use a bar chart to show the current progress during the inspection process.

Parameter-F forced check

The system has a great problem, causing the Linux boot time to enter the single stand-alone mode for maintenance behavior, only use fsck, the checked partition must not be mounted on the system.

badblocks [-SVW] [device name]

Parameter-s lists progress on the screen

Parameter-V to see progress on the screen

The parameter,-W, is tested using a write method. This parameter is not recommended when the device to be inspected has a file

Sync writes the data back to the disk that the system is temporarily present in memory

Mount [-TONL] [device name code] [Mount Point]

Parameter-A in accordance with the contents of/etc/fstab all relevant disks are hung up

parameter-n Generally speaking, when we mount the file system to Linux, Linux proactively logs the current partition and the file system with the corresponding mount point to the/etc/mtab file. When the system cannot write to/etc/mtab, it is possible to add the-n parameter to skip writing the mTAB action.

The parameter-l system can be mounted using the partition's label in addition to the device name code. So it's a good idea to take a unique name for the partitioning system.

Parameter-t Linux supports the file format. For example,-t ext3 to tell the system to mount the partition using the Ext3 file format. Because each file system is not the same, so before mounting to know the file system of the partition, if the mount does not add-t file system format, then Linux in the default case, will be active to/etc/filesystems this file in the standard file system format to try to mount the active. You can also mount a directory to another directory using mount

E2label Appliance name New label name

As for the system-supported filesystem types in/lib/modules/' Uname–r '/kernel/fs or/proc/filesystems. Common Linux usage file systems such as Ext2,ext3,reiserfs. Vfat,msdos such as Windows common FileSystem. ISO9660 is the format of the disc. NFS,SMBFS and other network related file system.

Parameter-O can be attached after some mount, additional parameters! such as account number, password, read and write permissions, etc.

RO,RW This partition is read-only RO or writable RW

Async,sync This partition is synchronous write (sync) or asynchronous (async), the default is async

Auto,noauto allows this partition to be automatically mounted with mount–a (auto)

Dev,nodev whether this partition is allowed to contain Suid/sgid file formats

Exec,noexec is allowed to have executable binary files on this partition

User,nouser whether this partition allows users to execute mount. In general, Mount is only available as root, but with the user parameter, you can enable a typical user to mount the partition

Defaults default value is: Rw,suid,dev,exec,auto,nouser,and Async

Remount re-mount, use when system error or re-update parameters

▲ Set Startup load

Mount Floppy Disk

Mount–t Ext2/dev/fd0/mnt/floppy

Mount–t Vfat/dev/fd0/mnt/floppy

Mounting Windows disks

Mount–t vfat/dev/hda1/mnt/windows

Mount–t Vfat–o Iochartset=cp950/dev/hda1/mnt/windows

Boot Mount/etc/fstab and/etc/mtab

The root directory/is the one that must be loaded, and is the first loaded

Other load points must be established directories

All load points must be established directories

All loading points can only be loaded once at the same time

All partitions can only be loaded once at the same time

If you uninstall, you must move the working directory outside of the loading point (and its subdirectories)

▲ Setting up virtual memory

FDISK create a new partition MKSWAP/DEVSDA?

Swapon/dev/sda? Swapoff/dev/sda?

DD If=/dev/zero Of=/tmp/swap bs=1m count=100 or

DD </dev/zero>/tmp/swap bs=1m count=100

Mkswap/tmp/swap

Swapon/tmp/swap

Swapoff/tmp/swap

Note Use free to view memory

Linux 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.