kavin

阿里云服务器挂载数据盘

kavin linux 2018-05-07 2165浏览 0

 阿里服务器申请到后,即便申请了数据盘,系统里面也没有自动配置上,看到的只有系统盘20GB,需要手动配置数据盘。


[root@94ip.com]# fdisk -l

Disk /dev/xvda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00078f9c

Device Boot Start End Blocks Id System

/dev/xvda1 * 1 2611 20970496 83 Linux

Disk /dev/xvdb: 322.1 GB, 322122547200 bytes

255 heads, 63 sectors/track, 39162 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

 

可以看到里面有一个300GB的硬盘/dev/xvdb,但是没有其他信息,因为没有格式化。

OK,现在手动格式化这个硬盘。

fdisk /dev/xvdb

fdisk 程序里输入 n, 然后输入 p,在后面分区开头和结尾选择里直接回车格式化位一个分区;

然后输入 p 可看到分区信息,再输入 w 写入分区配置,然后开始显示格式化进度条,结束后就OK了。

 

Command (m for help): p

Disk /dev/xvdb: 322.1 GB, 322122547200 bytes

255 heads, 63 sectors/track, 39162 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x976480a3

Device Boot Start End Blocks Id System

Command (m for help): n

Command action

e extended

p primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-39162, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-39162, default 39162):

Using default value 39162

Command (m for help): p

Disk /dev/xvdb: 322.1 GB, 322122547200 bytes

255 heads, 63 sectors/track, 39162 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x976480a3

Device Boot Start End Blocks Id System

/dev/xvdb1 1 39162 314568733+ 83 Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@94ip.com]# fdisk -l

 

挂载分区到目录:

[root@94ip.com]# mkdir -pv /data

mkdir: created directory `/data'

[root@94ip.com]# mount /dev/xvdb1 /data

 

如果这一步提示错误:

mount: you must specify the filesystem type

那是因为没有格式化分区导致的,重新格式化再mount就OK:

mkfs.ext3 /dev/xvdb1

mount /dev/xvdb1 /data

[root@94ip.com]#

 

将配置写入fstab:

vim /etc/fstab

末尾增加一行:

/dev/xvdb1 /data ext3 defaults 1 1

然后保存退出即可。


继续浏览有关 阿里云 的文章
发表评论