阿里云服务器 数据盘分区、格式化和挂载

阿里云云服务器在购买时,包括了包含操作系统的系统盘和用于存储数据的数据盘。下面以Linux为例,介绍数据盘的分区、格式化和挂载操作。以下所有操作都需要用户使用root账号登录以后执行。需要注意的是,执行这些操作将删除数据盘上已有数据,所以需要在操作之前对已有数据进行备份。

阿里云服务器 数据盘分区、格式化和挂载
 

首先,阿里云云服务器的数据盘设备名称在Linux系统下面为“/dev/xvdb”,我们使用fdisk命令在这个设备上创建一个占用全部存储空间的分区“/dev/xvdb1”。具体命令执行如下。
1 [root@AY120613085656f1f8377 ~]# /sbin/fdisk /dev/xvdb
2 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
3 Building a new DOS disklabel with disk identifier 0xf94abc7e.
4 Changes will remain in memory only, until you decide to write them.
5 After that, of course, the previous content won’t be recoverable.
6
7 Warning: invalid flag 0×0000 of partition table 4 will be corrected by w(rite)
8
9 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’).
10
11 Command (m for help): p
12
13 Disk /dev/xvdb: 42.9 GB, 42949672960 bytes
14 255 heads, 63 sectors/track, 5221 cylinders
15 Units = cylinders of 16065 * 512 = 8225280 bytes
16 Sector size (logical/physical): 512 bytes / 512 bytes
17 I/O size (minimum/optimal): 512 bytes / 512 bytes
18 Disk identifier: 0xf94abc7e
19
20 Device Boot Start End Blocks Id System
21
22 Command (m for help): n
23 Command action
24 e extended
25 p primary partition (1-4)
26 p
27 Partition number (1-4): 1
28 First cylinder (1-5221, default 1):
29 Using default value 1
30 Last cylinder, +cylinders or +size{K,M,G} (1-5221, default 5221):
31 Using default value 5221
32
33 Command (m for help): p
34
35 Disk /dev/xvdb: 42.9 GB, 42949672960 bytes
36 255 heads, 63 sectors/track, 5221 cylinders
37 Units = cylinders of 16065 * 512 = 8225280 bytes
38 Sector size (logical/physical): 512 bytes / 512 bytes
39 I/O size (minimum/optimal): 512 bytes / 512 bytes
40 Disk identifier: 0xf94abc7e
41
42 Device Boot Start End Blocks Id System
43 /dev/xvdb1 1 5221 41937651 83 Linux
44
45 Command (m for help): w
46 The partition table has been altered!
47
48 Calling ioctl() to re-read partition table.
49 Syncing disks.
50 [root@AY120613085656f1f8377 ~]#

接下来是创建文件系统,在下面的例子中,使用mkfs.ext4来创建EXT4类型的文件系统。
1 [root@AY120613085656f1f8377 ~]# mkfs.ext4 /dev/xvdb1
2 mke2fs 1.41.12 (17-May-2010)
3 Filesystem label=
4 OS type: Linux
5 Block size=4096 (log=2)
6 Fragment size=4096 (log=2)
7 Stride=0 blocks, Stripe width=0 blocks
8 2621440 inodes, 10484412 blocks
9 524220 blocks (5.00%) reserved for the super user
10 First data block=0
11 Maximum filesystem blocks=4294967296
12 320 block groups
13 32768 blocks per group, 32768 fragments per group
14 8192 inodes per group
15 Superblock backups stored on blocks:
16 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
17 4096000, 7962624
18
19 Writing inode tables: done
20 Creating journal (32768 blocks): done
21 Writing superblocks and filesystem accounting information: done
22
23 This filesystem will be automatically checked every 36 mounts or
24 180 days, whichever comes first. Use tune2fs -c or -i to override.

最后,将新创建的文件系统挂载到“/data”目录下,具体操作使用mount命令。
1 [root@AY120613085656f1f8377 ~]# mkdir /data
2 [root@AY120613085656f1f8377 ~]# mount /dev/xvdb1 /data/
3
4 [root@AY120613085656f1f8377 ~]# mount
5 /dev/xvda1 on / type xfs (rw)
6 proc on /proc type proc (rw)
7 sysfs on /sys type sysfs (rw)
8 devpts on /dev/pts type devpts (rw,gid=5,mode=620)
9 tmpfs on /dev/shm type tmpfs (rw)
10 none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
11 /dev/xvdb1 on /data type ext4 (rw)

可以看到“/dev/xvdb1”被成功挂载到“/data”目录下。

该日志由 aliyun 于2013年07月21日发表在 经验分享 分类下, 你可以发表评论,并在保留原文地址及作者的情况下引用到你的网站或博客。

转载请注明:阿里云服务器 数据盘分区、格式化和挂载

关键词:阿里云服务器
分享到:

阿里云服务器 数据盘分区、格式化和挂载:等您发表观点呢!

发表评论


快捷键:Ctrl+Enter