zoukankan      html  css  js  c++  java
  • CentOS7 自动挂载磁盘

    1、查看磁盘信息(/dev/sdb为新增磁盘容量10G)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    # fdisk -l
     
    Disk /dev/sda: 32.2 GB, 32212254720 bytes, 62914560 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: 0x000a44f5
     
    Device Boot Start End Blocks Id System
    /dev/sda1 * 2048 2099199 1048576 83 Linux
    /dev/sda2 2099200 62914559 30407680 8e Linux LVM
     
    Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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 /dev/mapper/centos-root: 29.0 GB, 28982640640 bytes, 56606720 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 /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 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

    2、格式化新增磁盘(/dev/sdb)

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    # mkfs.ext4 /dev/sdb
    mke2fs 1.42.9 (28-Dec-2013)
    /dev/sdb is entire device, not just one partition!
    Proceed anyway? (y,n) y
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    655360 inodes, 2621440 blocks
    131072 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=2151677952
    80 block groups
    32768 blocks per group, 32768 fragments per group
    8192 inodes per group
    Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
     
    Allocating group tables: done
    Writing inode tables: done
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information:
    done

    3、创建磁盘挂载目录并手动挂载

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    # mkdir /data
    # mount /dev/sdb /data
    # df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/centos-root 27G 2.5G 25G 10% /
    devtmpfs 990M 0 990M 0% /dev
    tmpfs 1001M 0 1001M 0% /dev/shm
    tmpfs 1001M 8.6M 992M 1% /run
    tmpfs 1001M 0 1001M 0% /sys/fs/cgroup
    /dev/sda1 1014M 125M 890M 13% /boot
    tmpfs 201M 0 201M 0% /run/user/0
    /dev/sdb 9.8G 37M 9.2G 1% /data

    4、设置开机自动挂载,查看磁盘UUID信息

    1
    2
    3
    4
    5
    6
    7
    # blkid
    /dev/sda1: UUID="18931213-eba9-473f-97e8-40dfce8a5b13" TYPE="xfs"
    /dev/sda2: UUID="gOZr1z-paNd-sA8t-H1zM-3mB7-SgWw-s2mAY2" TYPE="LVM2_member"
    /dev/sr0: UUID="2017-09-06-10-51-00-00" LABEL="CentOS 7 x86_64" TYPE="iso9660" PTTYPE="dos"
    /dev/sdb: UUID="f495dd82-2924-4af4-9262-d4a71f1156e3" TYPE="ext4"
    /dev/mapper/centos-root: UUID="923f04fc-3873-4b15-bbd8-9432ba3d7ea5" TYPE="xfs"
    /dev/mapper/centos-swap: UUID="5de5f520-90b4-4016-8f32-b90d784b2ad2" TYPE="swap"

    5、增加自动挂载磁盘信息, 修改(vim /etc/fstab)配置文件:

    1
    2
    添加以下信息
    UUID=f495dd82-2924-4af4-9262-d4a71f1156e3 /data ext4 defaults 0 0

    6、执行下面命令测试是否可以挂载成功

    1
    mount -a

    7、重启服务器测试

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    # df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/centos-root 27G 2.5G 25G 10% /
    devtmpfs 990M 0 990M 0% /dev
    tmpfs 1001M 0 1001M 0% /dev/shm
    tmpfs 1001M 8.6M 992M 1% /run
    tmpfs 1001M 0 1001M 0% /sys/fs/cgroup
    /dev/sdb 9.8G 37M 9.2G 1% /data
    /dev/sda1 1014M 125M 890M 13% /boot
    tmpfs 201M 0 201M 0% /run/user/0
  • 相关阅读:
    用stetho通过网页访问手机数据库
    Python学习笔记(一)
    Linux学习笔记(四)Linux常用命令
    Linux学习笔记(三)Shell命令机制
    Linux学习笔记(一)
    Linux学习笔记(五)Linux应用程序的安装和卸载
    Linux学习笔记(二)Shell教程
    Linux学习笔记(六)Linux服务程序的安装和卸载
    前端模块总结
    div+css命名规范
  • 原文地址:https://www.cnblogs.com/liuys635/p/12788028.html
Copyright © 2011-2022 走看看