如果是云服务器要先把数据盘挂载在ECS实例上,相当于先把硬盘与主机连接在一起
查看主机上连接数据盘的设备号
[root@wangxinshuo /]# fdisk -l
##################第一块是系统盘,设备号是vda########################
Disk /dev/vda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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: 0x00051937
Device Boot Start End Blocks Id System
/dev/vda1 * 1 5222 41942016 83 Linux
##################第二块是待挂载的数据盘########################
Disk /dev/vdc: 21.5 GB, 21474836480 bytes
16 heads, 63 sectors/track, 41610 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
进入格式化数据盘步骤
[root@wangxinshuo /]# fdisk /dev/vdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklab el
Building a new DOS disklabel with disk identifier 0xfc2af4e6.
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)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
###################键入“m”获取帮助#############
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
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)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
############此处需要知道磁道号,也可以直接键入Enter来执行默认##########
First cylinder (1-41610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-41610, default 41610):
Using default value 41610
##################笔者失误,此处应该键入“w”而非“q”#################
Command (m for help): q
进入建立文件格式步骤
[root@wangxinshuo /]# mkfs -t ext4 /dev/vdc
############ ext4是Linux的文件格式 ###############
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242880 blocks
262144 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
160 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
执行挂载步骤,挂载在相应的文件下
[root@wangxinshuo /]# mount /dev/vdc /media
查看挂载情况
[root@wangxinshuo media]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 40G 3.2G 35G 9% /
tmpfs 947M 0 947M 0% /dev/shm
/dev/vdc 20G 44M 19G 1% /media
关于磁盘分区等方面知识,可以参考我的另一篇文章:Linux分区与磁盘