zoukankan      html  css  js  c++  java
  • linux中的分区与格式化(五)

    一、分区与格式化的原理
    二、使用linux中的fdisk分区
    三、使用mkfs创建文件系统
    四、硬盘分区的挂载;

    一、分区原理
    1、主分区表(64byte):记录分区的起始与结束柱面、主分区个数。主分区大小有限,不能超过四个主分区
    2、扩展分区:将一个主分区更改成扩展分区,扩展分区支持无限个分区(逻辑分区),逻辑分区的信息写在扩展分区表中。

    二、格式化原理
    也就是创建不同的文件系统,供数据的存储与读取。
    常用的linux分区工具:fdisk,sfdisk,diskdruid

    fdisk一般使用过程
    1、运行命令:#fdisk /dev/hdX
    2、添加/删除/修改分区
    3、重新启动计算机(生效,由内核读取分区表信息的)

    [root@server root]# fdisk /dev/hda

    The number of cylinders for this disk is set to 9729.
    There is nothing wrong with that, but this is larger than 1024,
    and could in certain setups cause problems with:
    1) software that runs at boot time (e.g., old versions of LILO)
    2) booting and partitioning software from other OSs
       (e.g., DOS FDISK, OS/2 FDISK)

    Command (m for help): m
    Command action
       a   toggle a bootable flag
       b   edit bsd disklabel
       c   toggle the dos compatibility flag
       d   delete a partition
       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
       t   change a partition's system id #改变系统编号
       u   change display/entry units
       v   verify the partition table
       w   write table to disk and exit
       x   extra functionality (experts only)

    Command (m for help):


    三、Linux的格式化工具

    mkfs - 支持ext2、ext3(日志)、vfat、msdos、jfs、reiserfs等
    用法1:mkfs -t <fstype> <partition>
    例:#mkfs -t ext3 /dev/hda1
    用法2:mkfs.<fstype> <partition>
    例:#mkfs.vfat /dev/hda2
    mke2fs - 支持ext2/ext3文件系统
    用法:mke2fs [-j] <partition>
    例:#mke2fs -j /dev/hdb2
     
    四、硬盘分区的挂载
    1、挂载命令:#mount  (临时挂载,重启系统无效)
    例:#mount /dev/hda11 /mnt/d2
    2、卸载命令:#umount
    例:umount /dev/hda11
    3、写入/etc/fstab(自动挂载,系统启动时)
    /dev/hda11  /mnt/d2 /ext3 defaults 0 0

    五、使用卷标挂载
    1、添加卷标 —— e2label
    例:#e2label /dev/hda10 test
    2、根据卷标挂载
    例:#mount LABEL=test /mnt/d1
    3、写入/etc/fstab
    LABEL=test /mnt/d1 /ext3 defaults 0 0


    六、ext2/ext3挂载选项
    1、ro/rw ——只读/读写
    2、exec/noexec——允许/不允许可执行
    3、dev/nodev——允许/不允许设备文件
    4、suid,sgid/nosuid/nosgid——允许/不允许suid,sgid文件
    5、atime/noatime——更新/不更新节点的访问时间
    6、async/sync——异步/同步磁盘I/O
    7、user/nouser——允许/不允许普通用户挂载磁盘,用于/etc/fstable文件中的选项

  • 相关阅读:
    【33】避免遮掩继承而来的名称
    调用异步方法
    Python 调用C++
    【37】绝不重新定义继承而来的缺省参数值
    【36】绝不重新定义继承而来的non-virtual方法
    【38】通过复合塑模出Has-A 或根据某物实现出
    【转】C++ function、bind以及lamda表达式
    mongodb
    mongodb
    mongodb
  • 原文地址:https://www.cnblogs.com/jenry/p/404845.html
Copyright © 2011-2022 走看看