请选择 进入手机版 | 继续访问电脑版
素材分类
开启左侧

Linux系统磁盘详解

[复制链接]
依安时尚视听 发表于 2018-5-7 12:13:35 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
导读一切有体系皆一样,皆是一种硬件被装置于某个硬件之上,那个硬件无中非是一种存储装备,凡是电脑系统皆是装置正在磁盘中,以是Linux体系也是一样,皆是装置正在磁盘中,可是它取Windows体系纷歧样,由于Linux皆是需求创立文件体系才可使用。
1、 磁盘分类
今朝市场上的磁盘分类有:IDE磁盘(多用于PC机)、SATA磁盘、SAS磁盘、SSD磁盘等那么几种分类,企业中效劳器年夜多为前面的两种,SATA磁盘多用于企业内乱部的一些营业、SAS磁盘多用于对中的营业(一些营业仄台)。
SATA磁盘今朝容量最年夜为4T、SAS磁盘普通皆正在300G--600G占多数,企业消费情况中利用也最多的是这类容量的,实践消费中磁盘的利用次要是看机能需供,也便是磁盘的读写速率。
2、 磁盘的系统构造
企业级效劳器多块磁盘的状况
Linux体系磁盘详解51 做者:依安时髦视听 帖子ID:1955


3、 磁盘容量的计较
磁盘的构造普通包罗磁讲、盘里、扇区、见面等
一个磁讲的巨细=512 字节*扇区数
一个盘里的巨细=磁讲的巨细*磁讲数
一个磁盘的巨细=盘里巨细*磁头数
因而,一个磁盘的容量=512 字节*扇区数*磁讲数*磁头数
Linux体系磁盘详解57 做者:依安时髦视听 帖子ID:1955


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
Linux体系磁盘详解12 做者:依安时髦视听 帖子ID:1955


[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% /mnt6、 磁盘分区东西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系统上传下载等操作命令分享
下一篇:Android、iOS 、Windows,跨平台信息无缝对接即将到来
回复

使用道具 举报

精彩评论11

zzz222 发表于 2018-5-8 13:43:43 | 显示全部楼层
写的真的很不错
回复

使用道具 举报

dreamxyp@56.com 发表于 2018-5-8 13:44:33 | 显示全部楼层
没看完~~~~~~ 先顶。
回复

使用道具 举报

pybbs 发表于 2018-5-8 13:45:05 | 显示全部楼层
LZ真是人才
回复

使用道具 举报

ananokok 发表于 2018-5-8 13:45:10 | 显示全部楼层
Linux系统磁盘详解64 作者:ananokok 帖子ID:1955不错
回复

使用道具 举报

any941 发表于 2018-5-8 13:45:45 | 显示全部楼层
前排支持下
回复

使用道具 举报

nestnall 发表于 2018-5-8 13:46:38 | 显示全部楼层
路过,支持一下啦
回复

使用道具 举报

eason320hk 发表于 2018-5-8 13:46:47 | 显示全部楼层
找到好贴不容易,我顶你了,谢了
回复

使用道具 举报

hoei 发表于 2018-5-8 13:47:13 | 显示全部楼层
前排支持下分享,筋斗云论坛是个神奇的地方。
回复

使用道具 举报

AgKDjFcG 发表于 2018-5-8 13:50:08 | 显示全部楼层
帮帮顶顶!!支持筋斗云论坛。。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝0

帖子175

发布主题
推荐阅读 更多
阅读排行 更多
广告位

技术技术

客服客服

投诉投诉

举报举报


联系邮箱:
jdyweb@163.com
微信扫一扫
关注“筋斗云论坛”公众号
关注官方微信

微信号:6290810

公众号:筋斗云论坛

QQ1群:705711158

QQ2群:551249544

全国服务热线:

17156822352

(工作日:周一至周五 9:00-16:00)
上海市筋斗云网络科技
jdyweb@163.com

小黑屋- 筋斗云论坛  |appname

Powered by JDYBBS.COM X3.3© 2016-2018 Comsenz Inc.