Linux disk and file management

Source: Internet
Author: User

Linux disk and file management

In Linux O & M, O & M personnel mainly Manage Server I/O devices: disks and NICs. Here we mainly introduce disk management.

Everything in Linux is a file, and the hardware device also has a corresponding file. Accessing a device in Linux is actually accessing the corresponding file interface.

File interfaces: open (), read (), write (), close (), and so on.

Device Type:

Block: random access. The data exchange unit is block"

Character device (character): a linear device. The unit of data exchange is "character ". For example, enter the keyboard

Device Files: FHS (hierarchical standard for file systems)

In Linux, the/dev/directory is used to store device files. The device files are associated with the device driver and the device access portal.

Device management: Device number

Device No.: main device No. (major), sub-device No. (minor)

Major: Specifies the device type, which is used to indicate the required driver.

Minor: a specific device (c, character, and B) driven by drivers for different devices of the same type)

Linux disk device file name:

IDE (ATA): 133 MB/s,/dev/hd

SCSI: 640 MB/s

SATA: 6 Gbps

SAS: 6 Gbps

USB: 480 MB/s

Identify hard drive devices in Linux except IDE:/dev/sd

Mark Different Hard Drive devices:/dev/sd [a-z]

Mark different partitions on the same device:/dev/sd [a-z] [1-]

1-4: primary or extended partition ID

5 +: Logical partition ID

Mechanical hard drive Introduction: track, sector, cylinder cylindrical

MBR: 0 channels, 0 sectors, master boot record)

MBR is divided into three parts: 446 bytes: bootloader, boot program

64 bytes: partitioned table

16 bytes: Mark a partition

2 bytes: 55AA. indicates whether the MBR information is valid.

If a single hard disk exceeds 2 TB, you cannot use MBR partitioning. You can only use GPT partitioning.

Partitioning: separates buckets into multiple small spaces. Each space can use a file system independently;

Partition tool:

Fdisk, parted, sfdisk

Use of the fdisk tool:

Fdisk supports up to 15 partitions on one hard disk;

Fdisk partition management sub-command:

M: get help to display sub-commands

P: displays existing partition tables.

N: Create

D: Delete

T: Modify the partition ID.

L: list all supported ID types

W: Save and exit

Q: discard the modification and exit

After the partition is created, check whether the kernel recognizes the new partition:

# Cat/proc/partitions

There are three commands for the kernel to re-read the disk partition table:

CentOS 5: partprobe [DEVICE]

CentOS 6, 7:

Partx

Kpartx

Partx command: Note: The partition on the mounted hard disk must be executed. You may need to run the command twice or more times to read the partition successfully.

Partx DEVICE

Partx-a DEVICE

Partx-a-n M: N DEVICE

M

M:

: N

Kpartx command:

Kpartx-af DEVICE

After creating a partition, you must create a file system and format it.

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • 3
  • Next Page

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.