Centos6.5 添加硬盘

1,fdisk命令  查看未分区硬盘

# fdisk -l

Disk /dev/vda: 53.7 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 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: 0x000736d7

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *           1        6528    52427776   83  Linux

Disk /dev/vdb: 107.4 GB, 107374182400 bytes
16 heads, 63 sectors/track, 208050 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

2,fdisk命令新建分区

# 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 0x009bce99.
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-208050, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-208050, default 208050): 
Using default value 208050

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

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

3,格式化分区

# partprobe /dev/vdb
# ls /dev/vdb*
/dev/vdb  /dev/vdb1
# mkfs.ext4 /dev/vdb1
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
6553600 inodes, 26214292 blocks
1310714 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 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, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done                            
Creating journal (32768 blocks): 
done
Writing superblocks and filesystem accounting information: 
done

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

 

4,挂载

# mkdir /data0
# vim /etc/fstab 
/dev/vda1            /                    ext3       noatime,acl,user_xattr 1 1
/dev/vdb1            /data0               ext4       defaults               1 2
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
# mount -a
# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        50G  1.3G   46G   3% /
/dev/vdb1        99G   60M   94G   1% /data0
 

 

 注:fdisk命令详解:

       a   toggle a bootable flag                  // 设置可引导标记  
       b   edit bsd disklabel                      // 编辑bsd磁盘标签  
       c   toggle the dos compatibility flag       // 设置DOS操作系统兼容标记  
       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   // 建立空白DOS分区表  
       p   print the partition table                // 显示分区列表  
       q   quit without saving changes              // 不保存退出  
       s   create a new empty Sun disklabel         // 新建空白SUN磁盘标签  
       t   change a partition's system id           // 改变一个分区的系统ID  
       u   change display/entry units               // 改变显示记录单位  
       v   verify the partition table               // 验证分区表  
       w   write table to disk and exit             // 保存退出  
       x   extra functionality (experts only)       // 附加功能 

 

posted @ 2014-06-06 23:41  wpf926  阅读(59)  评论(0)    收藏  举报