Linux系统磁盘的知识点有哪些
这篇文章主要讲解了"Linux系统磁盘的知识点有哪些",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"Linux系统磁盘的知识点有哪些"吧!
1、 磁盘分类
目前市场上的磁盘分类有:IDE磁盘(多用于PC机)、SATA磁盘、SAS磁盘、SSD磁盘等这么几种分类,企业中服务器大多为后面的两种,SATA磁盘多用于企业内部的一些业务、SAS磁盘多用于对外的业务(一些业务平台)。
SATA磁盘目前容量最大为4T、SAS磁盘一般都在300G–600G居多,企业生产环境中使用也最多的是这种容量的,实际生产中磁盘的使用主要是看性能需求,也就是磁盘的读写速度。
2、 磁盘的体系结构
企业级服务器多块磁盘的情况
3、 磁盘容量的计算
磁盘的结构一般包括磁道、盘面、扇区、碰头等
一个磁道的大小=512 字节*扇区数
一个盘面的大小=磁道的大小*磁道数
一个磁盘的大小=盘面大小*磁头数
因此,一个磁盘的容量=512 字节扇区数磁道数*磁头数
4、 磁盘分区
所有磁盘的分区信息都是存储在分区表中,Linux系统仅支持4个分区表信息(主分区+扩展分区),一个分区表的大小在64bytes
Linux一般分为三个分区分别是:boot分区、swap分区、/根分区
Linux的分区编号:主分区1-4,逻辑分区从5开始计算
实际生产环境分区要求
1、 最少要有/和swap两个分区
2、 swap(虚拟内存)=1.5*物理内存大小,一般大小于或等于16G的物理内存的服务器,swap分区一般都直接设置为16G大小
3、 建议设置/boot分区,Linux引导分区,如内核文件等,一般所有文件一共才几十M的大小,因此这个分区就设置为100-200M即可
5、 磁盘分区工具fdisk
fdisk是针对磁盘容量小于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: Success
[root@localhost ~]# fdisk /dev/sda1 #对/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 #删除一个分区l list known partition typesm print this menun add a new partition #新建一个分区o create a new empty DOS partition tablep print the partition table #打印出分区表信息q quit without saving changes #不保存退出s 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 exit #将分区信息写入分区表并退出程序x extra functionality (experts only)Command actione extendedp primary partition (1-4)pPartition number (1-4): 1First cylinder (1-2610, default 1): 设置起始柱面Using default value 1Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):设置大小或柱面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 打印分区表信息Disk /dev/sdb: 21.5 GB, 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 Linux分区完成后执行 partprobe 通知系统分区表发生改变接下来进行格式化分区[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,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 挂载分区至/mnt 下[root@Centos ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_root 50G 3.5G 44G 8% /tmpfs 932M 0 932M 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% /mnt
6、 磁盘分区工具parted
由于环境限制无法有2T或者以上大小的磁盘,只能模拟环境来使用parted分区工具来进行分区
[root@Centos ~]# parted /dev/sdb mklabel gpt将磁盘转换成 gpt 的格式[root@Centos ~]# parted /dev/sdb mkpart primary 0 200(200M)Warning: The resulting partition is not properly aligned for bestperformance.Ignore/Cancel? Ignore[root@Centos ~]# parted /dev/sdb p 打印分区表信息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分区并设置大小Information: You may need to update /etc/fstab.[root@Centos ~]# parted /dev/sdb p 打印分区表信息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 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 0 932M 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 END resize partition NUMBER 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
感谢各位的阅读,以上就是"Linux系统磁盘的知识点有哪些"的内容了,经过本文的学习后,相信大家对Linux系统磁盘的知识点有哪些这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!