阿里云CentOS 7.5添加新磁盘

由于之前阿里云服务器空间快满了,需要新增一块磁盘,现将操作步骤记录如下:

  1. 登陆阿里云,创建一块云盘,创建成功后,“云盘状态” 为“使用中”:

    阿里云CentOS 7.5添加新磁盘_第1张图片

  2. 登陆CentOS系统,运行 fdisk -l

    [root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# fdisk -l
    ...
    磁盘 /dev/vdb:107.4 GB, 107374182400 字节,209715200 个扇区
    ...
    
  3. 找到对应的磁盘字符节点

    /dev/vdb
    
  4. 使用fdisk命令对磁盘进行分区

    [root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# fdisk /dev/vdb
    ...
    命令操作
       a   toggle a bootable flag
       b   edit bsd disklabel
       c   toggle the dos compatibility flag
       d   delete a partition
       g   create a new empty GPT partition table
       G   create an IRIX (SGI) partition table
       l   list known partition types
       m   print this menu
       n   add a new partition
       o   create a new empty DOS partition table
       p   print the partition table
       q   quit without saving changes
       s   create a new empty Sun disklabel
       t   change a partition's system id
       u   change display/entry units
       v   verify the partition table
       w   write table to disk and exit
       x   extra functionality (experts only)
    命令(输入 m 获取帮助):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-209715200, defaujlt 2048):
    Using default value 2048
    Last sector, +sector or +size {K,M,G} (2048-209715200, default 209715200):
    Partition 1 of type Linux and of size 100GB is set
    
    Command (m for help): p
    ...
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    Syncing disks.
    [root@iZ8vb2zp3hb2pskrfnjcrbZ ~]#
    
  5. 分区完成后,使用 fdisk -l 查看

    [root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# fdisk -l
    ...
    
    磁盘 /dev/vdb:107.4 GB, 107374182400 字节,209715200 个扇区
    Units = 扇区 of 1 * 512 = 512 bytes
    扇区大小(逻辑/物理):512 字节 / 512 字节
    I/O 大小(最小/最佳):512 字节 / 512 字节
    磁盘标签类型:dos
    磁盘标识符:0xc452f54a
    
       设备 Boot      Start         End      Blocks   Id  System
    /dev/vdb1            2048   209715199   104856576   83  Linuxs
    
  6. 格式化 分区

    [root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# mkfs.ext4 /dev/vdb1
    
  7. 挂载磁盘,修改分区表,开机后自动挂载到指定目录

    [root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# mkdir /data
    [root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# vi /etc/fstab
    
    # /etc/fstab
    # Created by anaconda on Thu Nov 29 03:34:10 2018
    #
    # 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=b98386f1-e6a8-44e3-9ce1-a50e59d9a170 /                       ext4    defaults        1 1
    # 添加/dev/vdb1
    /dev/vdb1       /data    ext4    defaults        1       1
    

    也可以手动挂载分区

    [root@iZ8vb2zp3hb2pskrfnjcrbZ ~]# mount /dev/vdb1 /data
    

你可能感兴趣的:(Linux)