CentOS云服务器数据盘分区和格式化

1. 查看数据盘信息

登录CentOS云服务器后,可以使用“fdisk -l”命令查看数据盘相关信息。 使用“df –h”命令,无法看到未分区和格式化的数据盘,只能看到已挂载的。

 

[root@VM_75_6_centos tlbb]# fdisk -l

Disk /dev/vda: 8589 MB, 8589901824 bytes
255 heads, 63 sectors/track, 1044 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: 0xcd6e8236

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1        1044     8385898+  83  Linux

Disk /dev/vdb: 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

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

Disk /dev/vdc: 2147 MB, 2147483648 bytes
16 heads, 63 sectors/track, 4161 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

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

可以看到 vdb vdc 这两个盘并未进行分区。
2.数据盘分区

执行以下命令,对数据盘进行分区。 然后输入 n p 1 两次enter wq。分区已然形成

fdisk /dev/vdb
[root@VM_75_6_centos tlbb]# fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xf9140b26.
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').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
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

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

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

再fdisk -l一下。

Disk /dev/vdb: 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: 0xf9140b26

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1               1       41610    20971408+  83  Linux

然后进行格式化文件系统。

[root@VM_75_6_centos tlbb]# mkfs.ext3 /dev/vdb1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1310720 inodes, 5242852 blocks
262142 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
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

正在写入inode表: 完成                            
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

最后,将此分区挂在到/home目录下

mount /dev/vdb1 /home

用df -h看一下分区信息。

[root@VM_75_6_centos tlbb]# df -h
文件系统              容量  已用  可用 已用%% 挂载点
/dev/vda1             7.9G  1.9G  5.7G  25% /
/dev/vdb1              20G  173M   19G   1% /home

大功告成。

posted on 2014-07-21 18:58  DieAngel  阅读(865)  评论(0编辑  收藏  举报

导航