1、# fdisk -l 查看当前磁盘信息,就会发现最下面显示新加入的硬盘不是有效分区,如下: 1 2 3 4 5 6 7 8 [root@localhost /] # fdisk -l Disk /dev/xvdb : 429.5 GB, 429496729600 bytes 255 heads, 63 sectors /track ,

1、# fdisk -l 查看当前磁盘信息,就会发现最下面显示新加入的硬盘不是有效分区,如下:    
  1. [root@localhost /]# fdisk -l 
  2.  
  3. Disk /dev/xvdb: 429.5 GB, 429496729600 bytes 
  4. 255 heads, 63 sectors/track, 52216 cylinders 
  5. Units = cylinders of 16065 * 512 = 8225280 bytes 
  6. Sector size (logical/physical): 512 bytes / 512 bytes 
  7. I/O size (minimum/optimal): 512 bytes / 512 bytes 
  8. Disk identifier: 0x00000000 
2、# fdisk /dev/xvdb 对新硬盘分区,并根据提示进一步操作:  
  1. [root@localhost /]# 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 0x7f095069. 
  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 0x0000 of partition table 4 will be corrected by w(rite) 
  8.  
  9. WARNING: DOS-compatible mode is deprecated. It's strongly recommended to 
  10.          switch off the mode (command 'c') and change display units to 
  11.          sectors (command 'u'). 
  12.  
  13. Command (m for help): n 输入n进行分区 
  14. Command action 
  15. e extended 
  16. p primary partition (1-4) 
  17. p 输入p为主分区,e为逻辑分区 
  18. Partition number (1-4): 1 (由于是新盘我们输入1来分第一个主分区,共可以分4个主分区) 
  19. First cylinder (1-52216, default 1): 1 (选择该分区的起始磁盘数,如无特殊需求强烈建议选择默认,也就是1来分区(可直接按回车)) 
  20.  
  21. Last cylinder or +size or +sizeM or +sizeK (1-52216, default 52216): 
  22. 定义该分区的大小,如果按默认(按回车)即是使用全部可用存储额,如分一个1G的空间,输入+1024m 
  23. Using default value 52216 
  24.  
  25. Command (m for help): w 写入分区 
  26. The partition table has been altered! 
  27.  
  28. Calling ioctl() to re-read partition table. 
  29. Syncing disks. 
3、# fdisk -l 可以找到我们刚才分的一个分区,内容如下:  
  1. [root@localhost /]#  
  2. fdisk -l 
  3.  
  4. Disk /dev/xvdb: 429.5 GB, 429496729600 bytes 
  5. 255 heads, 63 sectors/track, 52216 cylinders 
  6. Units = cylinders of 16065 * 512 = 8225280 bytes 
  7. Sector size (logical/physical): 512 bytes / 512 bytes 
  8. I/O size (minimum/optimal): 512 bytes / 512 bytes 
  9. Disk identifier: 0x90b7ee49 
  10.  
  11.     Device Boot      Start         End      Blocks   Id  System 
  12. /dev/xvdb1               1       52216   419424988+  83  Linux 
4、# mkfs -t ext4 -c /dev/xvdb1 对分区使用ext3格式化,-c参数要先检测磁盘坏道 ...... 5、# mkdir /data2 新建挂载目录 ...... 6、# mount -t ext4 /dev/xvdb1 /data2 挂载新硬盘 ...... 7、# df -l 查看分区大小是否和我们预定的一样 ...... 8、最后也是很容易漏掉的一步 [/shell] echo "/dev/xvdb1 /data2 ext4 defaults 0 0" >> /etc/fstab [/shell] 如果忘了将这个写入配置文件的话,服务器如果重启,硬盘将不会自动挂载,将找不到挂载的文件夹。 这时候要再一直mount 挂载一遍。。。
注:相关教程知识阅读请移步到服务器教程频道。
转载请说明出处
知优网 » centos 6.4 fdisk分区、格式化、挂载新硬盘(fdisk硬盘分区步骤)

发表评论

您需要后才能发表评论