Ubuntu下格式化并分区u盘

转自:http://blog.csdn.net/android_learn/article/details/6893313


1.命令行

[plain]  view plain copy print ?
  1. sudo fdisk -l  
查看你的设备的符号,显示结果通常如下:

[plain]  view plain copy print ?
  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

[html]  view plain copy print ?
  1. sudo umount /dev/sdb  
[html]  view plain copy print ?
  1. sudo fdisk /dev/sdb  
在终端显示内容如下:

[html]  view plain copy print ?
  1. Command (m for help):  
输入m得到帮助信息:

[html]  view plain copy print ?
  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)  
开始分区

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

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

[html]  view plain copy print ?
  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 分区的大小  
创建第二个分区:同上

[html]  view plain copy print ?
  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 分区:

[html]  view plain copy print ?
  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))  
查看分区情况:

[html]  view plain copy print ?
  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  

保存写入上面的内容:

[html]  view plain copy print ?
  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.  


格式化分区:
sudo mkfs.vfat -F 32 -n boot /dev/sdb1 //boot是为分区起的名字,就是在硬盘上显示的名字 格式化位fat32格式 第一个分区

sudo mkfs.ext3 -L linux_fs /dev/sdb2 // linux_fs 是第二个分区的名字,格式化位 ext3格式

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Ubuntu系统中,如果你需要格式化U盘或硬盘为NTFS格式,你可以使用ntfs-3g工具。通常情况下,这个工具已经在系统中自带了。如果没有的话,你可以通过执行命令"sudo apt-get install ntfs-3g"来安装它。\[1\] 另外,如果你想在Ubuntu系统中使用命令行模式对硬盘进行操作,你可以参考《鸟哥的Linux私房菜》一书中的详细说明。这本书可以帮助你理解一些不明白的知识点,并提供了对硬盘进行操作的指导。\[2\] 需要注意的是,使用fdisk命令对整块磁盘进行分区操作时,不需要在磁盘名称后面加上数字。例如,使用命令"sudo fdisk /dev/sdb"来对sdb磁盘进行分区操作。\[3\] 总结起来,如果你想在Ubuntu系统中格式化U盘或硬盘为NTFS格式,你可以使用ntfs-3g工具,并参考《鸟哥的Linux私房菜》一书中的说明来进行操作。同时,使用fdisk命令对整块磁盘进行分区时,不需要在磁盘名称后面加上数字。 #### 引用[.reference_title] - *1* [ubuntuU盘硬盘格式化(NTFS,FAT12,FAT16,FAT32,EXT4,EXT3,EXT2)](https://blog.csdn.net/xiaoqu001/article/details/78706822)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [Ubuntu命令行模式对硬盘进行分区格式化](https://blog.csdn.net/b150461/article/details/105325282)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值