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

What are the knowledge points of Linux system disk

2025-01-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly explains "what are the knowledge points of Linux system disk". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what are the knowledge points of Linux system disk".

1. Disk classification

At present, there are several types of disks on the market: IDE disks (mostly used for PCs), SATA disks, SAS disks, SSD disks and so on. Most of the servers in enterprises are the latter two. SATA disks are mostly used for some internal businesses, and SAS disks are mostly used for external services (some business platforms).

At present, the maximum capacity of SATA disks is 4T, and SAS disks are generally mostly in 300G-600G. This capacity is also most used in enterprise production environments. In actual production, the use of disks mainly depends on performance requirements, that is, disk read and write speed.

2. The architecture of disk

The case of enterprise server with multiple disks

Linux system disk detailed explanation Linux system disk detailed explanation 3. Disk capacity calculation

The structure of disk generally includes track, disk surface, sector, contact and so on.

Size of a track = 512 bytes * number of sectors

Size of a disk = size of track * number of tracks

Size of a disk = disk size * number of heads

Therefore, the capacity of a disk = 512 bytes number of sectors * number of heads

4. Disk partition

The partition information of all disks is stored in the partition table. The Linux system only supports four partition table information (primary partition + extended partition). The size of one partition table is in 64bytes.

Linux is generally divided into three partitions: boot partition, swap partition, / root partition

Partition number of Linux: primary partition 1-4. Logical partition starts at 5.

Zoning requirements for actual production environment

1. At least two partitions: / and swap are required

2. Swap (virtual memory) = 1.5 * physical memory size. For servers whose physical memory is generally equal to or equal to 16G, swap partitions are generally directly set to 16G.

3. It is recommended to set / boot partition, Linux boot partition, such as kernel files, etc. Generally, all files are only tens of megabytes in size, so this partition can be set to 100-200m.

5. Disk Partition tool fdisk

Fdisk is for disk capacity less than 2T.

[root@cairui ~] # fdisk-- helpfdisk: invalid option -'- 'fdisk: Usage:fdisk [options] change partition tablefdisk [options]-l list partition table (s) fdisk-s give partition size (s) in blocksOptions:-b sector size (512, 1024 2048 or 4096)-c switch off DOS-compatible mode-h print help-u give sizes in sectors instead of cylinders-v print version-C specify the number of cylinders-H specify the number of heads-S specify the number of sectors per track: SuccessLinux system disk detail Linux system disk detail [root@localhost] # fdisk / dev/sda1 # partitioning / dev/sda1 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0x02fadd9c.Changes will remain in memory only Until you decide to write them.After that, of course, the previous content won't be recoverable.Warning: invalid flag 0x0000 of partition table 4 will be corrected by w (rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended toswitch off the mode (command 'c') and change display units tosectors (command 'u') .Command (m for help): mCommand actiona toggle a bootable flagb edit bsd disklabelc toggle the dos compatibility flagd delete a partition # Delete a partition l list known partition typesm print this menun add a new partition # create a new partition o create a new empty DOS partition tablep print the partition table # print out partition table information q quit without saving changes # exit s create a new empty Sun disklabelt without saving Change a partition's system idu change display/entry unitsv verify the partition tablew write table to disk and exit # writes partition information to the partition table and exits the program x extra functionality (experts only) Command actione extendedp primary partition (1-4) pPartition number (1-4): 1First cylinder (1-2610) Default 1): set the starting cylinder Using default value 1Last cylinder, + cylinders or + size {K Magi M Magi G} (1-2610) Default 2610): set size or cylindrical Using default value 2610Command (m for help): mCommand actiona toggle a bootable flagb edit bsd disklabelc toggle the dos compatibility flagd delete a partitionl list known partition typesm print this menun add a new partitiono create a new empty DOS partition tablep print the partition tableq quit without saving changess create a new empty Sun disklabelt change a partition's system idu change display/entry unitsv verify the partition tablew write table to disk and exitx extra functionality (experts only) Command (m for help): wThe partition table has been altered calling ioctl () to re-read Partition table.Syncing disks.Command (m for help): P print partition table information Disk / dev/sdb: 21.5GB 21474836480 bytes255 heads, 63 sectors/track 2610 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytes121 / 753I/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0xb712cc55Device Boot Start End Blocks Id System/dev/sdb1 1 2610 20964793 + 83 after the partition is completed, execute partprobe to notify the system that the partition table has changed. Then format the partition [root@Centos ~] # mkfs.ext3 / dev/sdb1mke2fs 1.41.12 (17-May-2010) Filesystem label=OS type: LinuxBlock size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks Stripe width=0 blocks1310720 inodes, 5241198 blocks262059 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=4294967296160 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks:32768, 98304,163840,229376,294912,819200,884736,1605632,2654208 blocks 4096000Writing inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 24 mounts or180 days, whichever comes first. Use tune2fs-c or-i to override. [root@Centos ~] # tune2fs-c-1 / dev/sdb1tune2fs 1.41.12 (17-May-2010) Setting maximal mount count to-1 [root@Centos ~] # mount / dev/sdb1 / mnt mount partition to [root@Centos ~] # df-hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 50G 3.5G 44G 8% / tmpfs 932M 0932M 0% / dev/shm/dev/sda1 485m 39m 421m 9% / boot122 / 753/dev/mapper/VolGroup-lv_home 26G 215m 24G 1% / home/dev/sdb1 20G 172m 19G 1% / mnt6, Disk Partition tool parted

Due to environmental limitations, there are no disks of 2T or more size, so we can only simulate the environment to partition using the parted partitioning tool.

[root@Centos ~] # parted / dev/sdb mklabel gpt converts the disk to gpt format [root@Centos ~] # parted / dev/sdb mkpart primary 0200 (200m) Warning: The resulting partition is not properly aligned for bestperformance.Ignore/Cancel? Ignore [root@Centos ~] # parted / dev/sdb p print partition table information Model: VMware, VMware Virtual S (scsi) Disk / dev/sdb: 1074MBSector size (logical/physical): 512B/512BPartition Table: gptNumber Start End Size File system Name Flags1 17.4kB 200MB 200MB primary [root@Centos ~] # parted / dev/sdb mkpart primary 201 1073 partition and set the size Information: You may need to update / etc/fstab. [root@Centos ~] # parted / dev/sdb p print partition table information Model: VMware VMware Virtual S (scsi) Disk / dev/sdb: 1074MBSector size (logical/physical): 512B/512BPartition Table: gptNumber Start End Size Filesystem Name Flags1 17.4kB 200MB 200MB primary2 201MB 1073MB 871MB primary [root@Centos ~] # mkfs.ext4 / dev/sdb1mke2fs 1.41.12 (17-May-2010) Filesystem label=OS type: LinuxBlock size=1024 (log=0) Fragment size=1024 (log=0) 123 / 753Stride=0 blocks, Stripe width=0 blocks48960 inodes, 195296 blocks9764 blocks (5.00%) reserved for the super userFirst data block=1Maximum filesystem blocks=6737100824 block groups8192 blocks per group, 8192 fragments per group2040 inodes per groupSuperblock backups stored on blocks:8193 24577, 40961, 57345, 73729Writing inode tables: doneCreating journal (4096 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 36 mounts or180 days, whichever comes first. Use tune2fs-c or-i to override. [root@Centos ~] # tune2fs-c-1 / dev/sdb1tune2fs 1.41.12 (17-May-2010) Setting maximal mount count to-1 [root@Centos ~] # mount / dev/sdb1 / mnt [root@Centos ~] # df-hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 50G 3.5G 44G 8% / tmpfs 932M 0932M 0% / dev/shm/dev/sda1 485M 39M 421M 9% / boot/dev / mapper/VolGroup-lv_home 26G 215M 24G 1% / home/dev/sdb1 185M 5.6M 170M 4% / mnt [root@cairui ~] # parted-- helpUsage: parted [OPTION]. [DEVICE [COMMAND [PARAMETERS]...]...] Apply COMMANDs with PARAMETERS to DEVICE. If no COMMAND (s) are given, run ininteractive mode.OPTIONs:-h, help displays this help message-l,-- list lists partition layout on all block devices-m,-- machine displays machine parseable output-s,-- script never prompts for user intervention-v,-- version displays the version-a -- align= [none | cyl | min | opt] alignment for new partitionsCOMMANDs:align-check TYPE N check partition N for TYPE (min | opt) alignmentcheck NUMBER do a simple check on the file systemcp [FROM-DEVICE] FROM-NUMBER TO-NUMBER copy file system to another partitionhelp [COMMAND] print general help, or help onCOMMANDmklabel,mktable LABEL-TYPE create a new disklabel (partitiontable) mkfs NUMBER FS-TYPE make a FS-TYPE file system onpartition NUMBERmkpart PART-TYPE [FS-TYPE] START END make a partitionmkpartfs PART-TYPE FS-TYPE START END make a partition with a file systemmove NUMBER START END move partition NUMBERname NUMBER NAME name partition NUMBER as NAMEprint [devices | free | list All | NUMBER] display the partition table,available devices, free space, all found partitions, or a particularpartitionquit exit programrescue START END rescue a lost partition near STARTand ENDresize NUMBER START ENDresize partitionNUMBER and its filesystemrm NUMBER delete partition NUMBERselect DEVICE choose the device to editset NUMBER FLAG STATE change the FLAG on partition NUMBERtoggle [NUMBER [FLAG]] toggle the state of FLAG on partitionNUMBERunit UNIT set the default unit to UNITversion display the version number andcopyright information of GNU Parted thank you for reading The above is the content of "what are the knowledge points of the Linux system disk?" after the study of this article, I believe you have a deeper understanding of what the knowledge points of the Linux system disk are, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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

Development

Wechat

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

12
Report