• 阿里云CentOS数据盘挂载


    1. df -h 

    [root@iZuf66gcq71y5hlfv02w6aZ ~]# yum install -y parted
    
    [root@iZuf66gcq71y5hlfv02w6aZ ~]# yum install -y e2fsprogs

     其中:

    • /dev/vdb1:已创建好文件系统的数据盘分区,您需要根据实际情况修改对应的分区名称。
    • /mnt:挂载(mount)的目录节点,您需要根据实际情况修改。 /mnt不能改成/ 这样就会和vda抢占根目录,这样的话会直接导致服务器崩溃,因为数据都在vda1那里
    • ext4:分区的文件系统类型,您需要根据创建的文件系统类型修改。
    [root@iZuf66gcq71y5hlfv02w6aZ ~]# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    devtmpfs        3.9G     0  3.9G   0% /dev
    tmpfs           3.9G     0  3.9G   0% /dev/shm
    tmpfs           3.9G  652K  3.9G   1% /run
    tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
    /dev/vda1        40G  3.4G   35G   9% /
    tmpfs           783M     0  783M   0% /run/user/0
    [root@iZuf66gcq71y5hlfv02w6aZ ~]# fdisk -l
    
    Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 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: 0x000c7bcb
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vda1   *        2048    83886046    41941999+  83  Linux
    
    Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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@iZuf66gcq71y5hlfv02w6aZ ~]# 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 0x5181edbf.
    
    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-209715199, default 2048): 
    Using default value 2048
    Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): 
    Using default value 209715199
    Partition 1 of type Linux and of size 100 GiB is set
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@iZuf66gcq71y5hlfv02w6aZ ~]# fdisk -lu /dev/vdb
    
    Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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: 0x5181edbf
    
       Device Boot      Start         End      Blocks   Id  System
    /dev/vdb1            2048   209715199   104856576   83  Linux
    [root@iZuf66gcq71y5hlfv02w6aZ ~]# mkfs -t ext4 /dev/vdb1
    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
    6553600 inodes, 26214144 blocks
    1310707 blocks (5.00%) reserved for the super user
    First data block=0
    Maximum filesystem blocks=2174746624
    800 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@iZuf66gcq71y5hlfv02w6aZ ~]# mkfs -t xfs /dev/vdb1
    mkfs.xfs: /dev/vdb1 appears to contain an existing filesystem (ext4).
    mkfs.xfs: Use the -f option to force overwrite.
    [root@iZuf66gcq71y5hlfv02w6aZ ~]# cp /etc/fstab /etc/fstab.bak
    [root@iZuf66gcq71y5hlfv02w6aZ ~]# echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` /opt ext4 defaults 0 0 >> /etc/fstab
    [root@iZuf66gcq71y5hlfv02w6aZ ~]# cat /etc/fstab
    
    #
    # /etc/fstab
    # Created by anaconda on Tue Feb  8 06:52:06 2022
    #
    # Accessible filesystems, by reference, are maintained under '/dev/disk'
    # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
    #
    UUID=42616xxxxxxxxxxxxxxxxxxxxxxxxxd9e935 /                       ext4    defaults        1 1
    UUID=5d371xxxxxxxxxxxxxxxxxxxxxxxxxx12055 /mnt ext4 defaults 0 0
    [root@iZuf66gcq71y5hlfv02w6aZ ~]# mount -a
    [root@iZuf66gcq71y5hlfv02w6aZ ~]# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    devtmpfs        3.9G     0  3.9G   0% /dev
    tmpfs           3.9G     0  3.9G   0% /dev/shm
    tmpfs           3.9G  692K  3.9G   1% /run
    tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
    /dev/vda1        40G  3.4G   35G   9% /
    tmpfs           783M     0  783M   0% /run/user/0
    /dev/vdb1        99G   61M   94G   1% /mnt
    [root@iZuf66gcq71y5hlfv02w6aZ ~]# 
     [root@iZuf66gcq71y5hlfv02w6aZ ~]# mount -o remount,rw /

    不执行 mount -o remount,rw / 可能会报   【Unable to create tempDir. java.io.tmpdir is set to /tmp

    https://help.aliyun.com/document_detail/25426.html#section-wq3-ius-0f0

  • 相关阅读:
    EasyHook库系列使用教程之四钩子的启动与停止
    inputclean插件的使用方法
    机器学习(十三)——机器学习中的矩阵方法(3)病态矩阵、协同过滤的ALS算法(1)
    <LeetCode OJ> 204. Count Primes
    leetcode 235: Lowest Common Ancestor of a Binary Search Tree
    数据结构经常使用算法
    调侃物联网开源框架,我们什么时候也来开源一个?
    字符编码简单介绍
    PriorityQueue ,ArrayList , 数组排序
    从struts2.1开始Convention零配置
  • 原文地址:https://www.cnblogs.com/vipsoft/p/16077227.html
Copyright © 2020-2023  润新知