Fork me on GitHub

阿里云ECS服务器挂载磁盘


不要到处宣扬自己的内心,这世上不止你一个人有故事

使用阿里云ECS服务器, 购买的40G高效云盘已经不够用, 所以又购买了一块云盘, 但是仅仅通过控制台操作并不能将磁盘挂载到系统, 接下来记录我的挂载流程; 为了安全起见, 建议先去做一个磁盘快照

  • 检查磁盘现在的情况

    1
    df -h

    结果

    1
    2
    3
    4
    5
    6
    7
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/vda1 40G 35G 3.2G 92% /
    devtmpfs 3.9G 0 3.9G 0% /dev
    tmpfs 3.9G 0 3.9G 0% /dev/shm
    tmpfs 3.9G 632K 3.9G 1% /run
    tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
    tmpfs 783M 0 783M 0% /run/user/0
  • 查看硬盘个数及分区

    1
    fdisk -l

    结果

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    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: 0x0008d73a

    Device Boot Start End Blocks Id System
    /dev/vda1 * 2048 83884031 41940992 83 Linux

    Disk /dev/vdb: 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

    我们可以看到那块20GB的磁盘:/dev/xdb

  • 对这块硬盘进行分区

  • 查看

    1
    fdisk -l

    结果

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    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: 0x0008d73a

    Device Boot Start End Blocks Id System
    /dev/vda1 * 2048 83884031 41940992 83 Linux

    Disk /dev/vdb: 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: 0x7a2b9a92

    Device Boot Start End Blocks Id System
    /dev/vdb1 2048 41943039 20970496 83 Linux
  • 格式化新分区

    1
    mkfs.ext3 /dev/vdb1
  • 创建挂载目录
    建议挂载到mnt目录, 也可以自己创建新的目录

  • 挂载分区到目录

    1
    mount /dev/vdb1 /mnt
  • 查看

    1
    df -h

    结果

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    Filesystem      Size  Used Avail Use% Mounted on
    /dev/vda1 40G 35G 3.1G 92% /
    devtmpfs 3.9G 0 3.9G 0% /dev
    tmpfs 3.9G 0 3.9G 0% /dev/shm
    tmpfs 3.9G 636K 3.9G 1% /run
    tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
    tmpfs 783M 0 783M 0% /run/user/0
    /dev/vdb1 20G 45M 19G 1% /mnt
    ```
    - 设置开机自动挂载
    ```php
    cat /etc/fstab
    #
    # /etc/fstab
    # Created by anaconda on Sun Oct 15 15:19:00 2017
    #
    # 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=eb448abb-3012-4d8d-bcde-94434d586a31 / ext4 defaults 1 1

    修改

    1
    vi /etc/fstab

    结果

    1
    2
    3
    4
    5
    6
    7
    8
    9
    #
    # /etc/fstab
    # Created by anaconda on Sun Oct 15 15:19:00 2017
    #
    # 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=eb448abb-3012-4d8d-bcde-94434d586a31 / ext4 defaults 1 1
    /dev/vdb1 /mnt ext3 defaults 0 0
  • 重启

https://help.aliyun.com/document_detail/25426.html
https://blog.csdn.net/wyzhangchengjin123/article/details/50451065

请我喝一个苹果味的美年达吧,谢谢!