年年有"余"

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 2629|回复: 0

[CentOS] CentOS 磁盘挂载(Linux磁盘挂载)

[复制链接]
  • TA的每日心情
    奋斗
    2022-12-13 21:26
  • 签到天数: 371 天

    [LV.9]以坛为家II

    发表于 2015-6-19 17:05:51 | 显示全部楼层 |阅读模式
    1、 查看新磁盘信息

    [root@Crayfish ~]# fdisk -l

    Disk /dev/xvda: 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00060953

        Device Boot      Start         End      Blocks   Id  System
    /dev/xvda1   *           1        2611    20970496   83  Linux

    Disk /dev/xvdb: 21.5 GB, 21474836480 bytes
    255 heads, 63 sectors/track, 2610 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x00000000

    2、硬盘分区

    2.1、进入fdisk模式
    [root@Crayfish ~]# fdisk /dev/xvdb
    Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
    Building a new DOS disklabel with disk identifier 0xc233737d.
    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 to
             switch off the mode (command 'c') and change display units to
             sectors (command 'u').

    2.2、输入n进行分区
    Command (m for help): n
    Command action
       e   extended
       p   primary partition (1-4)


    2.3、选择分区类型,p为主分区,linux上主分区最多能有4个;e为扩展分区,扩展分区 linux上扩展分区只能有1个,扩展分区创建后不能直接使用,还要在扩展分区上创建逻辑分区。这里选择p
    p

    2.4、选择分区个数,最多可以分4个区,这里就只分一个了。
    Partition number (1-4): 1

    2.5、设置柱面,这里选择默认值就可以
    First cylinder (1-2610, default 1):
    Using default value 1


    2.6、设置柱面,这里选择默认值就可以
    Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):
    Using default value 2610

    2.7、输入w,写入分区表,进行分区
    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@Crayfish ~]#

    3、格式化分区
    如果创建的是主分区
    [root@Crayfish ~]# mkfs -t ext3  
    /dev/xvdb

    4、挂载硬盘

    4.1、创建挂载点
    在根目录下创建storage目录
    [root@Crayfish ~]#mkdir /storage

    4.2、将/dev/sdb1挂载到/storage下
    [root@Crayfish ~]#mount /dev/xvdb  /storage

    5、设置开机启动自动挂载

    新创建的分区不能开机自动挂载,每次重启机器都要手动挂载。
    设置开机自动挂载需要修改/etc/fstab文件
    [root@Crayfish ~]#vi /etc/fstab
    在文件的最后增加一行
    /dev/sdb5 /storage ext3 defaults 1 2
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    手机版|小黑屋|Archiver|iOS开发笔记 ( 湘ICP备14010846号 )

    GMT+8, 2024-4-19 23:57 , Processed in 0.047886 second(s), 22 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2021, Tencent Cloud.

    快速回复 返回顶部 返回列表