zoukankan      html  css  js  c++  java
  • Centos挂载和分区

    1. 首先,要在云服务商控制台上将买的盘挂载到实例上。
    2. 运行fdisk -l命令查看实例上的数据盘。
       说明 执行命令后,如果不存在/dev/vdb,表示您的实例没有数据盘。确认数据盘是否已挂载。
       
    3. 依次运行以下命令,创建一个分区。
      1. 运行fdisk -u /dev/vdb命令分区数据盘。
      2. 输入p查看数据盘的分区情况。
        本示例中,数据盘没有分区。
      3. 输入n创建一个新分区。
      4. 输入p选择分区类型为主分区。
        说明 创建一个单分区数据盘可以只创建主分区。如果要创建四个以上分区,您应该至少选择一次e(extended),创建至少一个扩展分区。
      5. 输入分区编号并按回车键。
        本示例中,仅创建一个分区,输入1
      6. 输入第一个可用的扇区编号,按回车键采用默认值2048。
      7. 输入最后一个扇区编号。
        本示例中,仅创建一个分区,按回车键采用默认值。
      8. 输入p查看该数据盘的规划分区情况。
      9. 输入w开始分区,并在完成分区后退出。  
    [root@ecshost~ ]# fdisk -u /dev/vdb
    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.
    Device does not contain a recognized partition table
    Building a new DOS disklabel with disk identifier 0x3e60020e.
    
    Command (m for help): p
    Disk /dev/vdb: 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: 0x3e60020e
    Device Boot Start End Blocks Id System
    
    Command (m for help): n
    Partition type:
    p primary (0 primary, 0 extended, 4 free)
    e extended
    Select (default p): p
    Partition number (1-4, default 1): 1
    First sector (2048-41943039, default 2048):
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):
    Using default value 41943039
    Partition 1 of type Linux and of size 20 GiB is set
    
    Command (m for help): p
    
    Disk /dev/vdb: 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: 0x3e60020e
    Device Boot Start End Blocks Id System
    /dev/vdb1 2048 41943039 20970496 83 Linux
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.

       4. 运行fdisk -lu /dev/vdb命令查看新分区。

      如果出现/dev/vdb1的相关信息,表示新分区已创建完成。
    [root@ecshost~ ]# fdisk -lu /dev/vdb
    
    Disk /dev/vdb: 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: 0x3e60020e
    
    Device Boot Start End Blocks Id System
    /dev/vdb1 2048 41943039 20970496 83 Linux

            5.在新分区上创建一个文件系统。

        根据您的需求运行以下任一命令,创建一个ext4文件系统。
    [root@ecshost~ ]# mkfs -t ext4 /dev/vdb1
    
    mke2fs 1.43.5 (04-Aug-2017)
    Creating filesystem with 5242624 4k blocks and 1310720 inodes
    Filesystem UUID: 884e1a06-1481-43d6-b1a3-8bccaa03****
    Superblock backups stored on blocks:
            32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
            4096000
    
    Allocating group tables: done
    Writing inode tables: done
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done

          6》向/etc/fstab写入新分区信息,启动开机自动挂载分区。

      echo "/dev/vdb1  /var/www   ext4  defaults  0   1” >> /etc/fstab

    第一字段:分区设备文件名或UUID(硬盘通用唯一识别码 可通过dumpe2fs 分区设备文件名 查看)
    第二字段:挂载点
    第三字段:文件系统名称
    第四字段:挂载参数
    第五字段:指定分区是否被dump备份,0代表不备份,1代表每天备份,2代表不定期备份
    第六字段:指定分区是否被fsck检测,0代表不检测,其它数字代表检测的优先级,1的优先级比2高

        7>运行cat /etc/fstab命令查看/etc/fstab中的新分区信息。

       8> 运行mount /dev/vdb1 /var/www命令挂载文件系统。然后用df -h查看。

       9》重启服务器查看自动加载情况

    参考:https://help.aliyun.com/document_detail/25426.html

  • 相关阅读:
    Rational Rose 2003 逆向工程转换C++ / VC++ 6.0源代码成UML类图
    用VC实现特定编辑框上对回车键响应
    22.职责链模式
    21.策略模式
    20.状态模式
    19.解释器模式
    18.备忘录模式
    17.中介者模式
    16.观察者模式
    15.迭代器模式
  • 原文地址:https://www.cnblogs.com/huhu1020387597/p/13559104.html
Copyright © 2011-2022 走看看