Linux system management disk and file method

  
                

The management of disks and files is an important part of the daily maintenance of Linux systems. Because disks are also used as files in Linux, the management of disks and files is actually the management of Linux files. This article will introduce the management methods of Linux and Linux disk systems and files.

First, the file interface: open (), read (), write (), close () and so on.

Device Type:

Block Device: The feature of random access, the unit of data exchange is “block”,

character device (character): linear device, The data exchange unit is “character”. For example: keyboard input

device file: FHS (level system standard for file system)

The /dev/directory in Linux is used to store device files, device files are associated with device drivers and access devices. Portal

Device Management: Device Number

Device Number: Major, Major Device Number (minor)

major: Device Type, Distinguish Device Type for indicating the desired driver

minor: under the same type of different devices, particularly devices (c, character device, b block device) driver driving

II. Linux disk device file naming:

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

SCSI: 640MB/s

SATA: 6Gbps

SAS: 6Gbps

USB: 480MB/s

Identifying hard disk devices in Linux other than IDE: /dev/sd

Marking different hard disk devices: /dev/sd [az]

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

1-4: Primary or extended partition ID

5+: Logical partition identifier

Third, mechanical hard disk introduction: track track, sector sector, cylinder cylinder

MBR: 0 track 0 sector, master boot sector (master boot record )

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

64bytes: partition table

16bytes: mark a partition

2bytes:55AA, current Whether the MBR information is valid or not

If the single hard disk exceeds 2T, the MBR partition cannot be used, only the GPT partition can be used.

Partition: Separate storage space into multiple small spaces, each space File system can be used independently;

Partitioning tools:

fdisk, parted, sfdisk

Use of fdisk tools:

fdisk supports up to one hard disk 15 partitions;

fdisk partition management subcommand:

m: Get help for displaying subcommands

p: Display existing partition table
>

n: Create

d: Delete

t: Modify Partition ID

l: List all supported ID types

w: Save and exit

q: Discard changes and exit

4. After the creation is complete, check whether the kernel has been identified. New partition:

# cat /proc/partitions

There are three commands that allow the kernel to reread the disk partition table:

CentOS 5: partprobe [DEVICE]

CentOS 6,7:

partx

kpartx

partx command: Note: The partition on the mounted hard disk needs to be executed, and the command may need to be executed twice or Partition can be read successfully

partx DEVICE

partx -a DEVICE

partx -a -n M:N DEVICE

M

M:

: N

2.kpartx command: the need to create a file system

kpartx -af DEVICE

and create a partition after Formatting

The above is the Linux system disk and file management method. After learning the method of this article, you will partition, rename, and format the Linux disk.

Copyright © Windows knowledge All Rights Reserved