2. Linux host planning and disk partitioning

Source: Internet
Author: User
Tags ide hard drive

A. Before installing Linux, you need to plan for use understanding, you have to target districtions features, server software capabilities, future upgrade requirements, hardware scalability

B. Disk partition planning for the installed host directory planning Rights planning IP planning

2.1 Linux and Hardware (the current brand of the server is basically support linnux, including each driver, but the desktop is not always, sometimes does not provide Linux drivers, so the hardware needs to confirm compatibility before purchase)

Need to consider computing power, data storage capacity, input/output I/O, network interface

2.2 File names for each hardware in Linux

"Linux, each device is treated as a file, such as the IDE interface hardware file name is/dev/sd[a-d], where the letter a-d any one,/DEV/SDA,/dev/sdb represents two files"

Device Name
The file name within Linux
Scsi/sata/usb interface hard disk (including USB memory)
/DEV/SD[A-P]
VIRTI/O interface
/DEV/VD[A-P] used in virtual machines
Floppy drive
/DEV/FD[0-7] is now largely unused
Printer
/dev/lp[0-2] (25Pin)/DEV/USB/LP[0-15]USB
Mouse/keyboard

/DEV/INPUT/MOUSE[0-15] General-purpose

/dev/psaux (PS/2 interface)

/dev/mouse (current mouse)

Cdrom/dvdrom

/DEV/SCD[0-1] Universal

/DEV/SR0[0-1] (general, CentOS more common)

/dev/cdrom (current CDROM)

Tape drive

/DEV/HT0 (IDE Interface)---basic elimination

/dev/st0 (SATA/SCSI interface)

/dev/tape (Current tape)

IDE Hard Drive
/DEV/HD[A-D] basically no longer
Adw

In recent years, the mature application of virtualization technology, convenient for us to learn, this time I was installed in the virtualization system.

Example: There are two SATA disks and a USB disk on the PC, 6 SATA slots on the motherboard, two SATA disks on SATA1 and SATA5, so what are the filenames of these devices in Linux?

File name on the SATA1 socket:/DEV/SDA SATA5 slot on the file name:/dev/sdb USB on the boot only after the error:/DEV/SDC

Hard disk Description:

Hard disk is composed of disk, mechanical arm, disk reading head and spindle motor, disk surface is divided into sectors, track hard disk capacity = number of cylinders * Number of heads * Number of sectors *512b

The first sector of the earlier hard disk has important information, called the MBR (Master boot Record) format, and in recent years, because of the expanding disk capacity, the disk partition larger than 2T cannot be read, so a new disk partition format was later--GPT

MSDOS (MRB) and GPT disk partition tables (partition table)

Linux, in order to be compatible with Windows disks, uses a Windows-enabled MBR to process the hypervisor and partition tables, while the Boot manager record area and partition table are placed on the first sector of the disk, which is 512byte:

These two data are mainly included:

* Main boot Record area (master boot record,mbr): Where the boot manager can be installed, there are 446bytes

* Partitioned tables (partition Table): Record the status of the entire hard disk partition, 64bytes

Each partition information is represented by 16 bytes, and four partitions use 16x4=64 bytes, 64 bytes distributed in the MBR's 第467-510 byte, followed by two bytes AA and 55 known as magic number, Bois read the MBR always check that the last is not the two magic numbers, if not it is considered to be a hard disk that is not partitioned.

Since the partition table is located in chunks with only 64bytes capacity, there can be up to four record areas, each recording the starting and ending magnetic column numbers for that segment, and the records of these four partitions are referred to as primary (Primary) or extended (extended) partition slots.

    • In fact, the so-called "Partition" is only for the 64bytes partition table for the setting!

    • Hard disk default partition table can only write four sets of partition information

    • These four sets of partitioning information we call Primary (Primary) or extended (extended) partition slots .

    • The smallest unit of a partition slot is "usually" a magnetic column.

    • When the system is written to disk, it must refer to the disk partition table in order to process the data for a partition slot .


2.3 Benefits of Disk partitioning

(Data security system effectiveness considerations)

If we partition a disk, P1,P2,P3,P4,P1-P3 the primary partition, P4 as the extended partition, because the purpose of the extended partition is to use additional sectors to record the partition information, the extended partition itself cannot be formatted. We can then continue to record the partition by the block that the extended partition points to.

The extended partition continues the partition, which is called logical partition (logical partition), and the device name number of the logical partition in Linux starts with number 5th.

P1 (/DEV/SDA1) P2 (/dev/sda2) P3 (/dev/sda3) P4 (/DEV/SDA4) L1 (/DEV/SDA5)

In summary, summarize the characteristics of the MBR partition:

    • There can be up to four primary and extended partitions (

    • An extended partition can have at most one

    • Logical partitions are divided by extended partitions.

    • After being able to be formatted, the partition as the data access is the primary partition and logical partition, and the extended partition cannot be formatted.

    • The number of logical partitions varies by operating system, and SATA drives in Linux systems can already exceed more than 63 partition limits.

Disadvantages of MBR:

    1. The operating system cannot fetch more than 2.2T of disk capacity 2. The MBR has only one chunk, which is destroyed after it is often unable or difficult to rescue 3. MBR of the Storage Boot management program block only 446bytes, unable to accommodate more program code


GPT disk partition table GUID partition table

Currently due to advances in technology, the past sector is 512bytes, now has 4 K sector design appears, in order to be compatible with all the disk, so in the definition of the sector, most will use logic block (Logical block Address,lba) to deal with, GPT plans all chunks of the disk with this LBA (preset 512bytes), and the first LBA is called a LBA0

MBR uses only the first 512bytes chunk to record, GPT uses 34 LBA chunks to record partitions, and GPT takes the last 33 LBA of the disk for backup.

    • LBA0 (MBR compatible block)

      Similar to MBR mode, this compatible block is divided into two parts, the first part of the same as the MBR 446bytes, stored the first stage of the boot management program, the original partition record area, the compatibility mode into a special flag to indicate that the disk is in GPT format, But do not understand the GPT Partition table management program, do not know this disk, play a further protection role.

    • LBA1 (GPT table header record)

      This section records the location and size of the partition table itself, and records the GPT partition of the backup, and also places the inspection Mechanism code (CRC32) of the partition table, which is used by the operating system to determine if the GPT is correct, and if there is an error, the record can be used to obtain the backup.

    • Lba2-33 (Actual Records Division information section)

      Starting from the LBA2 block, each LBA can record 4 partition records, so by default, there can be a total of 4*32=128 partition records, each LBA has 512bytes,gpt each record with 64bits to record the start/end sector number, His maximum capacity is limited to 2 of the 64 square *512bytes=8zb


GPT partition has no so-called primary partition, extended partition, logical partition concept, each partition record is independent, of course, each can be regarded as the primary partition, each can be formatted.

Not all operating systems can read to the GPT disk format, and not all hardware can support the GPT format, whether to read and write to the GPT format and the power-on detection program, the boot of the detection program is the BIOS and UEFI.


2.4 Bios and UEFI boot detection program during boot

CMOS is a storage device that records various hardware parameters and is embedded in the motherboard, and many times it is battery powered.

The BIOS is a software program written to the motherboard, which is the first program that the computer system will actively execute when it is powered on.

The BIOS will load the basic hardware driver program, identify and analyze the calculation on those devices (such as storage devices), we use the hard disk, the BIOS will be based on the user's settings to obtain a bootable hard disk, and go to this hard drive to read the first sector of the MBR location, MBR inside has a 446bytes part inside to place the most basic boot management program, at this time the BIOS becomes complete, next is the MBR inside the boot management program work.

The Boot Manager---purpose is to load the core file, the boot Manager is the operating system at the time of installation provided, so he will know the hard disk File system format, so you can read the core files, and then the core file work, Boot Manager and BIOS also completed the work, The work will then be handed over to the operating system.

In short, the entire boot process to the operating system before the action is this:

    1. BIOS: Power-on automatic execution software, is to recognize the hardware and load the drive, and find the hard drive to be bootable

    2. MBR: 446bytes Boot management program in the first sector of a hard drive unit

    3. Boot Manager: A software that can read the core file to execute

    4. Core file: Start operating system features


2.5 Disk Partitioning

The relationship between the file system and the directory tree under Linux (Mount)

The so-called "mount" is to use the directory as a point of entry, the disk partition in this directory, through this directory to read the partition data.

[Email protected] ~]# fdisk-l
Warning:fdisk GPT support are currently new, and therefore in an experimental phase. Use at your own discretion.

disk/dev/sda:53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * MB = bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes
Disk label TYPE:GPT
Disk identifier:0f1c34e5-5c72-417f-9b2d-11c94d621598


# Start End Size Type Name
1 2048 6143 2M BIOS boot parti
2 6144 2103295 1G Microsoft Basic
3 2103296 85997567 40G Linux LVM
4 85997568 88094719 1G linux filesyste linux filesystem
5 88094720 92289023 2G Microsoft basic Microsoft Basic data
6 92289024 93313023 500M Linux swap Linux Swap

disk/dev/mapper/centos-root:10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * MB = bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes


disk/dev/mapper/centos-swap:2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * MB = bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes


disk/dev/mapper/centos-home:5368 MB, 5368709120 bytes, 10485760 sectors
Units = sectors of 1 * MB = bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): bytes/512 bytes

[Email protected] ~]# lsblk
NAME maj:min RM SIZE RO TYPE mountpoint
Fd0 2:0 1 4K 0 disk
SDA 8:0 0 50G 0 disk
├─SDA1 8:1 0 2M 0 part
├─sda2 8:2 0 1G 0 part/boot
├─sda3 8:3 0 40G 0 part
│├─centos-root 253:0 0 10G 0 LVM/
│├─centos-swap 253:1 0 2G 0 LVM [swap]
│└─centos-home 253:2 0 5G 0 lvm/home
├─SDA4 8:4 0 1G 0 part
├─sda5 8:5 0 2G 0 part
└─sda6 8:6 0 500M 0 part
Sr0 11:0 1 1024M 0 rom
[Email protected] ~]#

Planning for mount points and disk partitioning:

Beginners, it is recommended to choose Custom, do not use the default auto-partitioning mode, which is not good for learning Linux partition, because you do not know what the ghost of this partition.

First contact with Linux, as long as the partition "/" and "SWAP"

Reserve a portion of the space as part of the learning process for doing zoning exercises.

A little trouble. Disk planning and partitioning, based on needs and uses, to analyze directories that require larger capacity, and directories that read and write frequently, need to separate these directories from the root directory. In the default CentOS, the bottom directory is a directory that is relatively large in volume and read-write frequently.

/boot//home/var Swap













This article is from the "Red Dust Have Love" blog, please make sure to keep this source http://19335.blog.51cto.com/9335/1978260

2. Linux host planning and disk partitioning

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.