zoukankan      html  css  js  c++  java
  • centos虚拟机挂载新磁盘

    确认新挂载的磁盘

    [root@share-redis ~]# fdisk -l

    Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000e05e5

    Device Boot Start End Blocks Id System
    /dev/sda1 * 2048 4196351 2097152 83 Linux
    /dev/sda2 4196352 88082431 41943040 83 Linux
    /dev/sda3 88082432 104466431 8192000 82 Linux swap / Solaris

    Disk /dev/sdb: 214.7 GB, 214748364800 bytes, 419430400 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

    在新挂载的磁盘上创建主分区

    [root@share-redis ~]# fdisk /dev/sdb
    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 0xe8f92863.

    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):
    First sector (2048-419430399, default 2048):
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399):
    Using default value 419430399
    Partition 1 of type Linux and of size 200 GiB is set

    Command (m for help): w
    The partition table has been altered!

    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@share-redis ~]# partprobe /dev/sdb

    对新创建的分区进行格式化

    [root@share-redis ~]# fdisk -l

    Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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: 0x000e05e5

    Device Boot Start End Blocks Id System
    /dev/sda1 * 2048 4196351 2097152 83 Linux
    /dev/sda2 4196352 88082431 41943040 83 Linux
    /dev/sda3 88082432 104466431 8192000 82 Linux swap / Solaris

    Disk /dev/sdb: 214.7 GB, 214748364800 bytes, 419430400 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: 0xe8f92863

    Device Boot Start End Blocks Id System
    /dev/sdb1 2048 419430399 209714176 83 Linux

    [root@share-redis ~]# mkfs.ext4 /dev/sdb1
    mke2fs 1.42.9 (28-Dec-2013)
    Filesystem label=
    OS type: Linux
    Block size=4096 (log=2)
    Fragment size=4096 (log=2)
    Stride=0 blocks, Stripe width=0 blocks
    13107200 inodes, 52428544 blocks
    2621427 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=2199912448
    1600 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, 2654208,
    4096000, 7962624, 11239424, 20480000, 23887872

    Allocating group tables: done
    Writing inode tables: done
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done

    建立新目录,挂载到刚创建的新分区上

    [root@share-redis ~]# mkdir /data
    [root@share-redis ~]# mount /dev/sdb1 /data

    确认分区和目录的状态和大小

    [root@share-redis ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda2 40G 3.6G 34G 10% /
    devtmpfs 7.8G 0 7.8G 0% /dev
    tmpfs 7.8G 0 7.8G 0% /dev/shm
    tmpfs 7.8G 9.9M 7.8G 1% /run
    tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
    /dev/sda1 2.0G 147M 1.7G 8% /boot
    tmpfs 1.6G 12K 1.6G 1% /run/user/42
    tmpfs 1.6G 0 1.6G 0% /run/user/0
    /dev/sdb1 197G 61M 187G 1% /data

    修改启动项,启动时自动挂载

    [root@share-redis ~]# echo "/dev/sdb1 /data ext4 defaults 0 0" >> /etc/fstab

    重启服务器

    [root@share-mysql ~]# reboot

    再次确认分区和目录

    [root@share-redis ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/sda2 40G 3.6G 34G 10% /
    devtmpfs 7.8G 0 7.8G 0% /dev
    tmpfs 7.8G 0 7.8G 0% /dev/shm
    tmpfs 7.8G 10M 7.8G 1% /run
    tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
    /dev/sdb1 197G 61M 187G 1% /data
    /dev/sda1 2.0G 147M 1.7G 8% /boot
    tmpfs 1.6G 8.0K 1.6G 1% /run/user/42
    tmpfs 1.6G 0 1.6G 0% /run/user/0

    操作完毕!

  • 相关阅读:
    天下第一 (spfa判断环)
    网络的可靠性 (最小生成树)
    星际之门(一) (快幂+最小生成树)
    吝啬的国度 建图+深搜
    表达式求值 第九届河南省省赛
    Apple Tree (树形结构变为线性结构+树状数组)
    士兵杀敌(五)(线段树??)
    动物统计加强版
    Supermarket
    生活的烦恼
  • 原文地址:https://www.cnblogs.com/lavezhang/p/12401012.html
Copyright © 2011-2022 走看看