• linux-磁盘应用


    目录

    一、磁盘内容简述

    1、一些基本概念

    2、分区简述

    3、常见文件系统

    4、linux硬盘文件

    二、对linux系统进行分区

    1、用fdisk进行分区

    2、用parted进行分区


    一、磁盘内容简述

    1、一些基本概念

    - 扇区大小:512Btyes,0.5KB

    - 磁盘最小存储单位:扇区,sector,大小是0.5kb

    - 操作系统文件存取的最小单位是块,是多个连续的扇区,是八个连续的扇区,最小的块单位,0.5*8,磁盘的block,最小是4kb

    - 1Byte = 8bit

    - 微软操作系统(DOS、WINDOWS等)中磁盘文件存储管理的最小单位叫做“簇”,一个文件通常存放在一个或多个簇里,但至少要单独占据一个“簇”。 也就是说两个文件不能存放在同一个簇中。簇(CLUST)的本意就是“一群”、“一组”,即一组扇区(一个磁道可以分割成若干个大小相等的圆弧,叫扇区)的意思。因为扇区的单位太小,因此把它捆在一起,组成一个更大的单位更方便进行灵活管理。簇的大小通常是可以变化的,是由操作系统在所谓“(高级)格式化”时规定的,因此管理也更加灵活。

    - 簇是windows 的概念,在linux系统中称为block,在linux文件系统中多个连续的扇区,被称为block,块的概念,也是在系统中被认为是最小的存储单位,一个block只能存储一个文件单位,文件大小只能是block的整数倍。

    2、分区简述

    MGR分区

    主分区引导记录

    master boot是主引导分区记录

    这里规定了只能由四个主分区引导其他逻辑分区

    扇区总共是512字节

    MBR :446字节

    分区表 :64字节

    结束标志:2字节

    gpt分区表

    现在大多的硬盘分区表,都是gpt分区表了

    优点:

    - gpt分区容量理论没有限制

    - 主分区个数没有限制

    - 自带磁盘保护机制

    3、常见文件系统

    • fat16、fat32,最早的windows文件系统,缺点是单个文件不能超过2GB
    • NTFS文件系统,支持文件加密,常用日志形式的文件系统,突破了单个文件4GB的大小限制
    • exfat 文件系统,新式文件系统,单个文件支持16gb大小,能够在windows和linux,macos中同时识别

    4、linux硬盘文件

    linux 一切皆文件,磁盘设备在系统中也以文件的形式展示


    二、对linux系统进行分区

    1、用fdisk进行分区

    我们对我们的系统进行分区

    先添加一块磁盘

    没有添加磁盘里面有一块安装镜像的磁盘

    添加硬盘

    我们加一块默认20GB的硬盘

    我们重启系统之后才可以看到这块硬盘

    lsblk

    我们直接对sdb这块硬盘进行分区

    fdisk /dev/sdb

    我们创建一个新的主分区

    1. Partition type:
    2. p primary (0 primary, 0 extended, 4 free)
    3. e extended
    4. Select (default p): p
    5. Partition number (1-4, default 1): 1

    设置开始扇区和结束扇区

    我们按p可以查看已经创建好的分区

    这里可以看到我们创建的这个1GB的主分区

    接着我们分别创建一个,2GB的主分区,一个3GB的主分区,一个4GB的主分区

    1. Command (m for help): n
    2. Partition type:
    3. p primary (1 primary, 0 extended, 3 free)
    4. e extended
    5. Select (default p): p
    6. Partition number (2-4, default 2): 2^H
    7. Partition number (2-4, default 2): 2
    8. First sector (1955840-41943039, default 1955840):
    9. Using default value 1955840
    10. Last sector, +sectors or +size{K,M,G} (1955840-41943039, default 41943039): +2GB
    11. Partition 2 of type Linux and of size 1.9 GiB is set
    1. Command (m for help): n
    2. Partition type:
    3. p primary (2 primary, 0 extended, 2 free)
    4. e extended
    5. Select (default p):
    6. Using default response p
    7. Partition number (3,4, default 3):
    8. First sector (5861376-41943039, default 5861376):
    9. Using default value 5861376
    10. Last sector, +sectors or +size{K,M,G} (5861376-41943039, default 41943039): +#^H
    11. Unsupported suffix: ''.
    12. Supported: 10^N: KB (KiloByte), MB (MegaByte), GB (GigaByte)
    13. 2^N: K (KibiByte), M (MebiByte), G (GibiByte)
    14. Last sector, +sectors or +size{K,M,G} (5861376-41943039, default 41943039): +3GB
    15. Partition 3 of type Linux and of size 2.8 GiB is set

    吧剩下的分区全部给扩展分区

    1. Command (m for help): n
    2. Partition type:
    3. p primary (3 primary, 0 extended, 1 free)
    4. e extended
    5. Select (default e): e
    6. Selected partition 4
    7. First sector (11720704-41943039, default 11720704):
    8. Using default value 11720704
    9. Last sector, +sectors or +size{K,M,G} (11720704-41943039, default 41943039):
    10. Using default value 41943039
    11. Partition 4 of type Extended and of size 14.4 GiB is set

    这下我们就可以继续创建逻辑分区了

    1. Command (m for help): n
    2. All primary partitions are in use
    3. Adding logical partition 5
    4. First sector (11722752-41943039, default 11722752):
    5. Using default value 11722752
    6. Last sector, +sectors or +size{K,M,G} (11722752-41943039, default 41943039): +2GB
    7. Partition 5 of type Linux and of size 1.9 GiB is set
    1. Command (m for help): n
    2. All primary partitions are in use
    3. Adding logical partition 6
    4. First sector (15630336-41943039, default 15630336):
    5. Using default value 15630336
    6. Last sector, +sectors or +size{K,M,G} (15630336-41943039, default 41943039): +4GB
    7. Partition 6 of type Linux and of size 3.7 GiB is set

    可以看出这里都是根据扩展分区创建的逻辑分区

    2、用parted进行分区

    用fdisk的前提:小于2TB的磁盘都可以使用fdisk分区,但是大于2TB的磁盘,只能用parted命令分区,且转换磁盘为GPT格式。

    我们再添加一块虚拟硬盘

    重启之后就可以看到了

    给sdc分区

    parted /dev/sdc

    把这个硬盘分区格式设置为gpt

    mklabel gpt

    创建一个主分区一GB

    mkpart primary 0 1GB

    fdisk -l


  • 相关阅读:
    JVM 核心技术 - 知识点整理
    【golang】error parsing regexp: invalid or unsupported Perl syntax (正则表达式校验密码)
    机器学习第10天:集成学习
    ArcGIS10.4.1属性表导出为乱码解决方法(亲测有效)
    51单片机-LED实验二
    GaussDB数据库SQL系列:DROP & TRUNCATE & DELETE
    聊聊如何获取PreparedStatement的参数
    408专业课130+|我的备考经验和复盘
    大数据中间件——Kafka
    22-数据结构-内部排序-选择排序
  • 原文地址:https://blog.csdn.net/bmxch/article/details/134101955