在linux下对U盘进行格式化及分区

时间:2022-04-19 08:11:04

注意:

fat16和fat32直接在windows下右键就可以了。

ext2需要在linux进行格式化,步骤如下


1.首先sudo  sfdisk  -c  /dev/sdb   1   83将整个分区ID改成83

2.然后

sudo fdisk -l查看分区情况

sudo fdisk /dev/sdb1

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   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
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)


Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p

Partition number (1-4): 1

First cylinder (1-1017, default 1): 回车
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1017, default 1017): 回车
Using default value 1017

Command (m for help): p


Disk /dev/sdc1: 4007 MB, 4007076864 bytes
124 heads, 62 sectors/track, 1017 cylinders
Units = cylinders of 7688 * 512 = 3936256 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6e9dbf3d


     Device Boot      Start         End      Blocks   Id  System
/dev/sdc1p1               1        1017     3909317   83  Linux


Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 83

Command (m for help): w

2.此时分区便建立好了,但是必须格式化才能用。

mkfs.ext2 /dev/sdb1

mkfs.ext2 之后 ,整个sdb1都会变成83的ID,

此时sudo fdisk -l显示如下 

 Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1018     3913161   83 LINUX