Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Deep cracking learning-Linux disk management and file system management

2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

one。 The detailed structure of the disk

1. Magnetic disk

two。 Magnetic head

3. Magnetic track

4. Sector

5. Cylindrical surface

The side and head of a disk

Each disk contains two sides, and each disk has a corresponding read / write head. Due to the limitations of the overall volume and production cost of the hard disk, the number of disks is limited, generally less than 5. The number of the disk starts from 0 from the bottom up, such as the bottom disk has 0 and 1 side, and the last disk is numbered as 2 sides and 3 sides.

Let's take a closer look at what a disk is through this picture.

Sectors and tracks

The following picture shows a disk surface in which circles of gray concentric circles are divided into tracks. By drawing a straight line from the center of the circle, the track can be divided into several arcs, and one arc on each track is called a sector (the green part of Toujian). A sector is the smallest unit of a disk, usually 512 bytes. (due to increasing disk size, some manufacturers set the size of each sector to 4096 bytes.)

Magnetic head and cylinder

A hard disk usually consists of an overlapping set of discs, each of which is divided into an equal number of tracks and numbered starting with the "0" of the outer edge, and the tracks with the same number form a cylinder called the cylinder of the disk. The number of cylinders of a disk is equal to the number of tracks on a disk. Because each disk has its own head, the number of disks is equal to the total number of heads.

Disk capacity calculation

Storage capacity = number of heads × number of tracks (cylinder) x number of sectors per sector x bytes per sector

The disk in the figure is a disk with 3 disks, 6 heads and 7 cylinders (7 tracks per disk). Each track in figure 3 has 12 sectors, so the capacity of this disk is:

Storage capacity 6 7 12 * 512 = 258048

The number of sectors of each track is the same as the old hard disk, the density of the outer ring is small, the density of the inner ring is high, and the amount of data that can be stored in each circle is the same. The density of the new hard disk data is the same, so that the longer the perimeter of the track, the more sectors and the greater the amount of data stored.

1. Sector: the minimum read and write unit of a hard disk

two。 Block / cluster: the smallest unit of the operating system for reading and writing to the hard disk

3.page: the smallest unit of operation between memory and the operating system.

two。 Disk partition representation

Partition: when representing a partition, add the partition after it based on the file name of the hard disk device (regardless of the primary partition,

Expand the partition, logical partition) corresponding to the numeric serial number. For example, the 1st partition table in the 1st IDE hard drive

It is shown as "hda1", the second partition is represented as "hda2", and the third partition in the second SCSI hard drive is represented as "sdb3".

The fifth partition is represented as "sdb5".

It should be noted that since there are only four primary partitions on the hard disk, the serial numbers of the primary and extended partitions are the same.

The limit is 1-4, and the sequence number of the logical partition will always start at 5. For example, even if only the 1st IDE hard drive is divided into

If there is a primary partition or an extended partition, the sequence number of the first new logical partition still starts at 5 and should be represented as

"hda5", the second logical partition is represented as "hda6".

III. Types of file systems used by Linux

XFS: a high-performance journaling file system that is especially good at handling large files and can support millions of terabytes of

Storage space. Since logging is enabled in the XFS file system, there is no fear of data corruption even if there is an outage.

This file system can recover data in a short time according to logging.

 SWAP: swap file systems that are used to establish swap partitions for Linux systems. The role of the swap partition is equivalent to that of the virtual

Storage can alleviate the problem of insufficient physical memory to some extent. It is generally recommended that the size of the swap partition be set to something

1.5 times the amount of memory. For example, for hosts with 512MB physical memory, the size of the swap partition is recommended

Set to 1024MB. If the physical memory of the server is large enough (such as more than 8GB), the swap partition may not be set.

Swap partitions are not used to directly store data such as users' files and directories.

four。 Let's practice and use commands.

1. View our disk partitions

two。 View the details of all our disk partitions

Sda1: preamble and display partition list contents

Start: start sector

End: end sector

Blocks: total capacity

3. Let's add a hard disk to the VM virtual machine.

4. Restart the computer

5. Check out our newly added disk

6. Commands to manage and understand the disk

7. Create the first primary partition

8. View partition messages

9. Add another primary partition

10. Add an extended partition

Extended partitions need to add logical partitions to store data

11. Let's add the first logical partition

twelve。 Add a second logical partition

13. Change the file system type

14. Delete partition

15. Save our settings and check our partition messages

16. Formatting

17. View mount point

18. Add mount points and mounts

19. We found that the content was missing.

20. Let's look at this picture to find out.

We only mount under this name, but the contents will always be in the disk partition, no matter what the name is, the content is still in the

21. Create SWAP virtual memory and start the swap partition

That's all we have.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report