Chinaunix首页 | 论坛 | 博客
  • 博客访问: 207501
  • 博文数量: 93
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 978
  • 用 户 组: 普通用户
  • 注册时间: 2014-11-10 15:46
个人简介

青春无悔

文章分类

全部博文(93)

文章存档

2015年(16)

2014年(77)

我的朋友

分类: LINUX

2015-04-24 16:59:39

1.命令行


  1. sudo fdisk -l  
查看你的设备的符号,显示结果通常如下:



  1. Disk /dev/sda: 500.1 GB, 500107862016 bytes  
  2. 255 heads, 63 sectors/track, 60801 cylinders  
  3. Units = cylinders of 16065 * 512 = 8225280 bytes  
  4. Sector size (logical/physical): 512 bytes / 512 bytes  
  5. I/O size (minimum/optimal): 512 bytes / 512 bytes  
  6. Disk identifier: 0x000c4c5b  
  7.   
  8.    Device Boot      Start         End      Blocks   Id  System  
  9. /dev/sda1   *           1       60065   482466816   83  Linux  
  10. /dev/sda2           60065       60802     5917697    5  Extended  
  11. /dev/sda5           60065       60802     5917696   82  Linux swap / Solaris  
  12.   
  13. Disk /dev/sdb: 1954 MB, 1954545664 bytes  
  14. 255 heads, 63 sectors/track, 237 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: 0x00069760  
找到你的设备的盘符,我的是 /dev/sdb



  1. sudo umount /dev/sdb  
  1. sudo fdisk /dev/sdb  
在终端显示内容如下:



  1. Command (m for help):  
输入m得到帮助信息:



  1. Command action  
  2.    a   toggle a bootable flag  
  3.    b   edit bsd disklabel  
  4.    c   toggle the dos compatibility flag  
  5.    d   delete a partition  
  6.    l   list known partition types  
  7.    m   print this menu  
  8.    n   add a new partition  
  9.    o   create a new empty DOS partition table  
  10.    p   print the partition table  
  11.    q   quit without saving changes  
  12.    s   create a new empty Sun disklabel  
  13.    t   change a partition's system id  
  14.    u   change display/entry units  
  15.    v   verify the partition table  
  16.    w   write table to disk and exit  
  17.    x   extra functionality (experts only)  
开始分区


如果你的设备已经有分区,先删除你的分区:


  1. Command (m for help): d 删除命令  
  2. Partition number (1-4): 1 删除地几个分区  
  1. 如果有多个分区,接着执行命令d,输入分区号  
创建新分区:



  1. Command (m for help): n   创建分区命令  
  2. Command action  
  3.    e   extended  
  4.    p   primary partition (1-4)  
  5. p                          选择分区的类型 e:扩展分区 p:主分区  
  6. Partition number (1-4): 1  分区号 1:第一个分区  
  7. First cylinder (1-237, default 1): 1  
  8. Last cylinder, +cylinders or +size{K,M,G} (1-237, default 237): +512M 分区的大小  
创建第二个分区:同上



  1. Command (m for help): n  
  2. Command action  
  3.    e   extended  
  4.    p   primary partition (1-4)  
  5. p  
  6. Partition number (1-4): 2  
  7. First cylinder (67-237, default 67):   
  8. Using default value 67  
  9. Last cylinder, +cylinders or +size{K,M,G} (67-237, default 237): +512M   
把第一个分区做为FAT32d 分区:



  1. Command (m for help): t 改变分区的id  
  2. Partition number (1-4): 1 改变第一个分区  
  3. Hex code (type L to list codes): c 变为dos兼容的格式  
  4. Changed system type of partition 1 to c (W95 FAT32 (LBA))  
查看分区情况:



  1. Command (m for help): p  
  2.   
  3. Disk /dev/sdb: 1954 MB, 1954545664 bytes  
  4. 255 heads, 63 sectors/track, 237 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: 0x00069760  
  9.   
  10.    Device Boot      Start         End      Blocks   Id  System  
  11. /dev/sdb1               1          66      530113+   c  W95 FAT32 (LBA)  
  12. /dev/sdb2              67         132      530145   83  Linux  

保存写入上面的内容:



  1. Command (m for help): w  
  2. The partition table has been altered!  
  3.   
  4. Calling ioctl() to re-read partition table.  
  5.   
  6. WARNING: Re-reading the partition table failed with error 16: Device or resource busy.  
  7. The kernel still uses the old table. The new table will be used at  
  8. the next reboot or after you run partprobe(8) or kpartx(8)  
  9.   
  10. WARNING: If you have created or modified any DOS 6.x  
  11. partitions, please see the fdisk manual page for additional  
  12. information.  
  13. Syncing disks.  



格式化分区:


  1. sudo mkfs.vfat -F 32 -n boot /dev/sdb1 //boot是为分区起的名字,就是在硬盘上显示的名字 格式化位fat32格式 第一个分区<pre name="code" class="html">sudo mkfs.ext3 -L linux_fs /dev/sdb2 // linux_fs 是第二个分区的名字,格式化位 ext3格式pre><br>  
  2. <p>p>  
  3. <pre>pre>  
  4. OK,Over。  
  5. <p>p>  
  6. <p><br>  
  7. p>  


阅读(729) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~