阿里云Ecs挂载云盘

来源:互联网 发布:php短信轰炸机 编辑:程序博客网 时间:2024/06/10 09:36

转载请注明出处 http://www.paraller.com 原文排版地址 点击获取更好阅读体验

先购买一个云盘 500G大小

查看硬盘情况fdisk -l

查看是否有一个 /dev/xvdb 或者 数据盘大小与你要挂载一致的硬盘

```Disk /dev/xvda: 107.4 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000da36d

Device Boot      Start         End      Blocks   Id  System

/dev/xvda1 * 2048 209713151 104855552 83 Linux

Disk /dev/xvdb: 214.7 GB, 214748364800 bytes //重点255 heads, 63 sectors/track, 26108 cylinders, total 419430400 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x00000000

Disk /dev/xvdb doesn't contain a valid partition table

```

执行分区

fdisk /dev/xvdb ;对数据盘进行分区;根据提示,依次输入“n”,“p”“1”,两次回车,“wq”,分区就开始了,很快就会完成。

```Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelBuilding a new DOS disklabel with disk identifier 0x5c273d61.Changes will remain in memory only, until you decide to write them.After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): nPartition type: p primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): pPartition number (1-4, default 1): 1First sector (2048-419430399, default 2048):Using default value 2048Last sector, sectors or size{K,M,G} (2048-419430399, default 419430399):Using default value 419430399

Command (m for help): wqThe partition table has been altered!

Calling ioctl() to re-read partition table.Syncing disks.```

查看硬盘信息

fdisk -l 查看新的分区。新分区 xvdb1 已经创建好。如下面示例中的/dev/xvdb1

```Disk /dev/xvda: 107.4 GB, 107374182400 bytes255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000da36d

Device Boot      Start         End      Blocks   Id  System

/dev/xvda1 * 2048 209713151 104855552 83 Linux

Disk /dev/xvdb: 214.7 GB, 214748364800 bytes86 heads, 25 sectors/track, 195083 cylinders, total 419430400 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x5c273d61

Device Boot      Start         End      Blocks   Id  System

/dev/xvdb1 2048 419430399 209714176 83 Linux```

有两种情况,

  • 你这个数据盘是新购买的,以前没有用过(没有存储过数据),那么就要对其进行格式化,使用 mkfs.ext3 /dev/xvdb1命令。
  • 第二种,如果你之前就有数据盘,只是你把系统盘重置了,需要将数据盘再次挂载到重置后的系统上,那么就不要对其格式化(跳过此步骤),直接执行后面的步骤挂载就可以了。

```mke2fs 1.42.9 (4-Feb-2014)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks13107200 inodes, 52428544 blocks2621427 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=42949672961600 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: doneWriting inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done```

挂载到 /mnt

前提是你已经创建了这个目录(创建目录的命令是mkdir)。以下命令写入新分区信息

echo '/dev/xvdb1 /mnt ext3 defaults 0 0'

原创粉丝点击