linux 系统磁盘管理体系

匿名 (未验证) 提交于 2019-12-02 21:56:30

Ŀ¼

磁盘就像是森林,是所有硬式存储的统称,如最早出现的软盘,现在的硬盘,都是磁盘中的一部分。

磁盘开始指的是1.44MB的3.5英寸磁盘,这是很早时候的电脑储存盘,也叫软盘。

软盘在如今已经很少被使用了,使用软盘需要安装软盘驱动。软盘容量小,容易损坏。随着数据的大量增长,软盘已经不满足日益所需的数据存储需求,如是,硬盘便被研发出来。

硬盘就是计算机中的最大的存储装置了,就是将磁盘的储存片装到硬质金属盒子里可以得到更好的保护,而且在使用寿命上也比软盘优越得多,只有低格才对硬盘有很大的伤害,其它的读写是不要紧的,也就叫硬盘。

磁盘是一种统称,即是一开始的软盘,又是现如今的硬盘,但是在现在,说起磁盘,都指的是硬盘。

盘面数量==磁头数量

作用:用来写入和读取数据的

径向运动寻道

从外面到里面最外面是0磁道

磁道上面的最小的单位

默认大小512字节

不同盘面上面的相同的磁道组成的圆柱体

不同盘面上的相同的呼啦圈组成的圆柱体

磁盘默认是按照柱面进行读写

磁头之间的切换速度接近于光速

磁头径向运动-寻道机械运动慢

磁盘是按柱面进行读写的,表示一个柱面的大小

磁盘大小=柱面的大小*柱面的数量

柱面的大小=一个磁道的大小*磁头数量

一个磁道的大小=一个扇区的大小*扇区数量/每个磁道

fdisk 查看磁盘详细信息

echo + bc

awk

rpm(round per minute)
10k rpm
15k rpm
5400 rpm
7200 rpm

M.2接口是为超极本(Ultrabook)量身定做的新一代接口标准,以取代原来的mSATA接口。无论是更小巧的规格尺寸,还是更高的传输性能,M.2都远胜于mSATA
M2接口百度百科

你了解M.2固态硬盘吗?

装机到底要不要买M.2接口的SSD?

SATA、MSATA、PCIE和M2都是什么?

固态硬盘SATA和MSATA有什么区别?
https://baike.baidu.com/item/m.2%E6%8E%A5%E5%8F%A3
http://baijiahao.baidu.com/s?id=1604321789851430125&wfr=spider&for=pc
http://www.sohu.com/a/253988990_610530
http://www.sohu.com/a/229021919_463982
https://zhidao.baidu.com/question/754765227221408324.html

  • 机械和固态的对比
机械(HDD)         固态(SSD) 容量大价格低      容量小价格高 抗击打能力弱      抗击打能力高 读写速度稍慢      读写速度很快 数据恢复易           数据恢复难 使用时间无限      使用时间1-2w次

适用于磁盘小于2TB的磁盘,分区类型MBR,主分区4或主分区3+扩展分区(逻辑分区+…),分区后需要保存后生效

模拟环境:

虚拟机增加一块10GB硬盘

[root@gjy ~]# lsblk NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT sda      8:0    0   20G  0 disk  ├―sda1   8:1    0  500M  0 part /boot ├―sda2   8:2    0    1G  0 part [SWAP] └―sda3   8:3    0 18.5G  0 part / sdb      8:16   0   20G  0 disk  ├―sdb1   8:17   0    1G  0 part  ├―sdb2   8:18   0    2G  0 part  ├―sdb3   8:19   0    7G  0 part  ├―sdb4   8:20   0    1K  0 part  └―sdb5   8:21   0    5G  0 part  sdc      8:32   0    3T  0 disk  sdd      8:48   0  200G  0 disk  sr0     11:0    1  4.3G  0 rom
[root@gjy ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2).  Changes will remain in memory only, until you decide to write them. Be careful before using the write command.   Command (m for help):    #如果回复m,每个参数含义  Command (m for help):   a   toggle a bootable flag                   #切换分区启动标记    b   edit bsd disklabel                       #编辑sdb磁盘标签    c   toggle the dos compatibility flag        #切换dos兼容模式 ** d   delete a partition                       #删除分区    g   create a new empty GPT partition table   #创建新的空白GPT分区表    G   create an IRIX (SGI) partition table     #创建IRIX (SGI)分区表 ** l   list known partition types               #显示分区类型 ** m   print this menu                          #显示帮助菜单 ** n   add a new partition                      #新建分区    o   create a new empty DOS partition table   #创建新的空白分区表 ** p   print the partition table                #显示分区表的信息 ** q   quit without saving changes              #不保存退出    s   create a new empty Sun disklabel         #创建新的Sun磁盘标签    t   change a partitions system id            #修改分区ID,可以通过l查看id    u   change display/entry units               #修改容量单位,磁柱或扇区    v   verify the partition table               #检验分区表 ** w   write table to disk and exit             #保存退出    x   extra functionality (experts only)       #拓展功能   
 分区具体过程(分4个主分区)   1. 输入n进行分区  有时输入信息不正确,利用ctrl+u ctrl+backspace进行错误信息删除  #创建一个1G 的分区 Command (m for help): n Partition type:    p   primary (0 primary, 0 extended, 4 free)    e   extended Select (default p):  Using default response p Partition number (1-4, default 1):  First sector (2048-41943039, default 2048):  Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +1G Partition 1 of type Linux and of size 1 GiB is set   2. 输入p查看分区 Command (m for help): p  Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x5b38e62c     Device Boot      Start         End      Blocks   Id  System     #一个分区 /dev/sdb1            2048     2099199     1048576   83  Linux  #创建2G 的分区 Command (m for help): n Partition type:    p   primary (1 primary, 0 extended, 3 free)    e   extended Select (default p):  Using default response p Partition number (2-4, default 2):  First sector (2099200-41943039, default 2099200):  Using default value 2099200 Last sector, +sectors or +size{K,M,G} (2099200-41943039, default 41943039): +2G Partition 2 of type Linux and of size 2 GiB is set  #查看分区 Command (m for help): p  Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x5b38e62c     Device Boot      Start         End      Blocks   Id  System    # 变成了2个分区 /dev/sdb1            2048     2099199     1048576   83  Linux /dev/sdb2         2099200     6293503     2097152   83  Linux #创建7G 的分区 Command (m for help): n Partition type:    p   primary (2 primary, 0 extended, 2 free)    e   extended Select (default p):  Using default response p Partition number (3,4, default 3):  First sector (6293504-41943039, default 6293504): +7G Last sector, +sectors or +size{K,M,G} (14680064-41943039, default 41943039):  Using default value 41943039 Partition 3 of type Linux and of size 13 GiB is set  #查看分区 Command (m for help): p  Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x5b38e62c     Device Boot      Start         End      Blocks   Id  System #变成了3个分区 /dev/sdb1            2048     2099199     1048576   83  Linux /dev/sdb2         2099200     6293503     2097152   83  Linux /dev/sdb3        14680064    41943039    13631488   83  Linux  #删除第三个分区 Command (m for help): d Partition number (1-3, default 3): 3 Partition 3 is deleted #再次查看分区 Command (m for help): p  Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x5b38e62c     Device Boot      Start         End      Blocks   Id  System     #只剩下前两个分区 /dev/sdb1            2048     2099199     1048576   83  Linux /dev/sdb2         2099200     6293503     2097152   83  Linux  #创建一个拓展分区,按e 或者默认剩余的全给拓展分区 Command (m for help): n Partition type:    p   primary (3 primary, 0 extended, 1 free)    e   extended Select (default e):  Using default response e Selected partition 4 First sector (20973568-41943039, default 20973568):  Using default value 20973568 Last sector, +sectors or +size{K,M,G} (20973568-41943039, default 41943039):  Using default value 41943039 Partition 4 of type Extended and of size 10 GiB is set  Command (m for help): p  Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0x5b38e62c     Device Boot      Start         End      Blocks   Id  System /dev/sdb1            2048     2099199     1048576   83  Linux /dev/sdb2         2099200     6293503     2097152   83  Linux /dev/sdb3       20973568    41943039    10484736    5  Extended  #保存退出  Command (m for help): w The partition table has been altered!  Calling ioctl() to re-read partition table. Syncing disks.
     设备名称    分区信息    设备类型 /dev/sda    /dev/sda1   第一块物理磁盘第一分区 /dev/sdb    /dev/sdb2   第二块磁盘第二个分区 /dev/vdd    /dev/vdd4   第四块虚拟磁盘的第四个分区   系统中分区由数字编号表示,1-4表示给主分区使用和扩展分区,逻辑分区从5开始 详细可参考下面网站: https://baike.baidu.com/item/%E4%B8%BB%E5%BC%95%E5%AF%BC%E8%AE%B0%E5%BD%95/7612638  前面我们已经提到过MBR分区表只能分配4个主分区,但现在还有一种新型的分区表GPT,GPT支持分配128个主分区。注意MBR与GPT之间不能互转,会导致数据丢失。 详细可参考下面网站: http://www.360doc.com/content/18/0614/22/6140124_762487520.shtml  MBR位置:0磁头0磁道1扇区。
[root@gjy ~]# df -h Filesystem      Size  Used Avail Use% Mounted on /dev/sda3        48G  3.0G   45G   7% / devtmpfs        980M     0  980M   0% /dev tmpfs           991M     0  991M   0% /dev/shm tmpfs           991M   18M  973M   2% /run tmpfs           991M     0  991M   0% /sys/fs/cgroup /dev/sda1       197M  105M   93M  54% /boot /dev/sr0        4.3G  4.3G     0 100% /mnt tmpfs           199M     0  199M   0% /run/user/0 tmpfs           199M     0  199M   0% /run/user/1011 [root@gjy ~]# du -sh /etc 166M    /etc [root@gjy ~]# lsblk NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT sda      8:0    0   50G  0 disk  ├―sda1   8:1    0  200M  0 part /boot ├―sda2   8:2    0    2G  0 part [SWAP] └―sda3   8:3    0 47.8G  0 part / sr0     11:0    1  4.3G  0 rom  /mnt  虚拟机添加磁盘分别为20G  3T,添加完成后要重启虚拟机 [root@gjy ~]# ll /dev/sd* brw-rw----. 1 root disk 8,  0 Jul 16 18:33 /dev/sda brw-rw----. 1 root disk 8,  1 Jul 16 18:33 /dev/sda1 brw-rw----. 1 root disk 8,  2 Jul 16 18:33 /dev/sda2 brw-rw----. 1 root disk 8,  3 Jul 16 18:33 /dev/sda3 brw-rw----. 1 root disk 8, 16 Jul 16 18:33 /dev/sdb brw-rw----. 1 root disk 8, 32 Jul 16 18:33 /dev/sdc [root@gjy ~]# lsblk NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT sda      8:0    0   50G  0 disk  ├―sda1   8:1    0  200M  0 part /boot ├―sda2   8:2    0    2G  0 part [SWAP] └―sda3   8:3    0 47.8G  0 part / sdb      8:16   0   20G  0 disk  sdc      8:32   0    3T  0 disk  sr0     11:0    1  4.3G  0 rom    fdisk  只支持MBR分区表,适用于2TB以下的分区。 [root@web ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2).
[root@gjy ~]# mkfs.xfs /dev/sdb1 meta-data=/dev/sdb1              isize=512    agcount=4, agsize=65536 blks          =                       sectsz=512   attr=2, projid32bit=1          =                       crc=1        finobt=0, sparse=0 data     =                       bsize=4096   blocks=262144, imaxpct=25          =                       sunit=0      swidth=0 blks naming   =version 2              bsize=4096   ascii-ci=0 ftype=1 log      =internal log           bsize=4096   blocks=2560, version=2          =                       sectsz=512   sunit=0 blks, lazy-count=1 realtime =none                   extsz=4096   blocks=0, rtextents=0                     
[root@web ~]# mkdir   /mnt/data2  创建目录 [root@web ~]# ll /data2 total 0 [root@gjy ~]# mount /dev/sdb1 /mnt/data2   ## 临时挂载 [root@gjy ~]# df Filesystem     1K-blocks    Used Available Use% Mounted on /dev/sda3       19399680 1720548  17679132   9% / devtmpfs         1012904       0   1012904   0% /dev tmpfs            1023744       0   1023744   0% /dev/shm tmpfs            1023744    9112   1014632   1% /run tmpfs            1023744       0   1023744   0% /sys/fs/cgroup /dev/sda1         508580  122100    386480  25% /boot tmpfs             204752       0    204752   0% /run/user/0 /dev/sdb1        1038336   32992   1005344   4% /mnt/data2 
[root@gjy ~]# vim /etc/fstab [root@gjy ~]# tail -1 /etc/fstab /dev/sdb1               /data1            xfs     defaults        0 0
umount /dev/sdb2
df
mount -r  /dev/sdb2
mount -a /dev/sdb2
[root@gjy ~]# dd if=/dev/zero of=/data2/test.txt bs=10M count=50 50+0 records in 50+0 records out 524288000 bytes (524 MB) copied, 6.00042 s, 87.4 MB/s [root@gjy ~]# ll /data2 total 512000 -rw-r--r--. 1 root root 524288000 Jul 16 19:43 test.txt 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!