阿里 ECS 挂载云盘

查看云盘

# fdisk -l

Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectors

Device     Boot Start      End  Sectors Size Id Type
/dev/vda1  *     2048 83884031 83881984  40G 83 Linux

Disk /dev/vdb: 200 GiB, 214748364800 bytes, 419430400 sectors

分区

# fdisk /dev/vdb

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-419430399, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-419430399, default 419430399):

Created a new partition 1 of type 'Linux' and of size 200 GiB.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

格式化

# mkfs.ext4 /dev/vdb1
mke2fs 1.42.13 (17-May-2015)
Found a dos partition table in /dev/vdb1
Proceed anyway? (y,n) y
Creating filesystem with 52428544 4k blocks and 13107200 inodes
Filesystem UUID: 8a6c75c7-3bea-4d6c-8bcf-8a638db536e0
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

配置重启时自动挂载

# echo /dev/vdb1 /home ext4 defaults 0 0 >> /etc/fstab

或者

# blkid
dev/vda1: UUID="f5954a19-b069-42e4-a6ca-3a1cd06d0735" TYPE="ext4" 
/dev/vdb1: UUID="de51db0c-dead-44d0-8425-6ee34fdfb754" TYPE="ext4"
# echo de51db0c-dead-44d0-8425-6ee34fdfb754 /home ext4 defaults 0 0 >> /etc/fstab

手动挂载

mount /dev/vdb1 /mnt/home

查看

df -h