• 云主机如何挂在磁盘


    1、查看硬盘信息,看看是否需要分区
    
    [root@host-10-1-1-68 ~]# fdisk -l
    
    Disk /dev/vda: 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: 0x000ba41f
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *        2048     2099199     1048576   83  Linux
    /dev/vda2         2099200    41943039    19921920   8e  Linux LVM
    
    Disk /dev/mapper/centos-root: 18.2 GB, 18249416704 bytes, 35643392 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
    
    
    Disk /dev/vdb: 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
    
    
    2、对硬盘进行分区操作,  没有输入的直接回车
    
    [root@host-10-1-1-68 ~]# fdisk /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 0xc4d5568d.
    
    Command (m for help): p
    
    Disk /dev/vdb: 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: 0xc4d5568d
    
       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): 
    First sector (2048-104857599, default 2048): 
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): 
    Using default value 104857599
    Partition 1 of type Linux and of size 50 GiB is set
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.
    
    
    查看新的分区
    [root@host-10-1-1-68 ~]# fdisk -l


    3、分区好的盘格式化
    
    [root@host-10-1-1-68 ~]# mkfs.ext4 /dev/vdb
    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
    3276800 inodes, 13107200 blocks
    655360 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=2162163712
    400 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
    
    Allocating group tables: done                            
    Writing inode tables: done                            
    Creating journal (32768 blocks): done
    Writing superblocks and filesystem accounting information: done 
    
    4、挂在分区
    
    [root@host-10-1-1-68 ~]# mkdir /var/lib/docker/
    [root@host-10-1-1-68 ~]# mount /dev/vdb /var/lib/docker/
    [root@host-10-1-1-68 ~]# cd /var/lib/docker/
    [root@host-10-1-1-68 docker]# ls
    lost+found
    [root@host-10-1-1-68 docker]# touch q.sh
    [root@host-10-1-1-68 docker]# vi q.sh 
    [root@host-10-1-1-68 docker]# 
    [root@host-10-1-1-68 docker]# ls
    lost+found  q.sh
    [root@host-10-1-1-68 docker]# cat q.sh 
    iiii
    [root@host-10-1-1-68 docker]# rm -rf q.sh 
    [root@host-10-1-1-68 docker]# cd
    [root@host-10-1-1-68 ~]# 
    [root@host-10-1-1-68 ~]# 
    [root@host-10-1-1-68 ~]# umount /dev/vdb
    [root@host-10-1-1-68 ~]# vi /etc/fstab
    /dev/mapper/centos-root /                       xfs     defaults        0 0
    UUID=4cda1b18-f3f4-4031-bd45-71768526a9f8 /boot                   xfs     defaults        0 0
    /dev/mapper/centos-swap swap                    swap    defaults        0 0
    /dev/mapper/centos-swap swap                    swap    defaults        0 0
    /dev/vdb     /var/lib/docker/                   ext4    defaults        0 0
    
    
    [root@host-10-1-1-68 ~]# reboot
    [root@host-10-1-1-68 ~]# df
    Filesystem              1K-blocks   Used Available Use% Mounted on
    /dev/mapper/centos-root  17811456 999188  16812268   6% /
    devtmpfs                  3994028      0   3994028   0% /dev
    tmpfs                     4005084      0   4005084   0% /dev/shm
    tmpfs                     4005084  16724   3988360   1% /run
    tmpfs                     4005084      0   4005084   0% /sys/fs/cgroup
    /dev/vdb                 51474912  53272  48783816   1% /var/lib/docker
    /dev/vda1                 1038336 145676    892660  15% /boot
    tmpfs                      801020      0    801020   0% /run/user/0
    
    
    
    5、磁盘繁忙解决
    
    切换到别的目录再卸载即可
  • 相关阅读:
    桥接模式(从多个角度对实现进行分类)
    单例模式
    组合模式(解决 树形 ,局部与整体关系)
    备忘录模式
    适配器模式
    状态模式
    StartUML建模及生成java实体代码
    JPA删除接口报错 : org.hibernate.LazyInitializationException: failed to lazily initialize a collection, could not initialize proxy
    idea创建的gradle项目没有src目录怎么办?
    idea spring源码 gradle编译失败问题
  • 原文地址:https://www.cnblogs.com/effortsing/p/10012534.html
Copyright © 2020-2023  润新知