TF/sd卡分区成fat32和ext4分区

partx -d /dev/sdb  #因为内核中存在部分未调整磁盘的信息,故先将所有信息清零
partx -a /dev/sdb  #添加调整后的磁盘分区信息
partx -s /dev/sdb  #显示磁盘分区信息

lsblk命令:列出所有可用块设备的信息,而且还能显示他们之间的依赖关系,但是它不会列出RAM盘的信息。块设备有硬盘,闪存盘,CD-ROM等等。
补充一点:lsblk和df的区别:
lsblk 查看的是block device,也就是逻辑磁盘的大小
df 查看的是file system,也就是文件系统层的磁盘大小,并且已挂载
lsblk -f


NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
sr0                                                      
sdc                                                      
├─sdc2                                                   
└─sdc1 vfat   boot  9B9B-BC66                            /media/dong/boot
sda                                                      
├─sda2                                                   
├─sda5 swap         9943f6a9-38e2-4cc1-a1da-5fd9dc7b1643 [SWAP]
└─sda1 ext4         07df7b61-8fcb-4d41-9fac-044fbd9ef0bd /

root@vincent:/# fdisk -l


Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000d63d3


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    19531775     9764864   82  Linux swap / Solaris
/dev/sda2   *    19531776   214843391    97655808   83  Linux
/dev/sda3       214843392  1953523711   869340160   83  Linux


Disk /dev/sdb: 1007 MB, 1007681536 bytes
9 heads, 8 sectors/track, 27335 cylinders, total 1968128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000


   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1             253     1968127      983937+   b  W95 FAT32



//注意,如果sd卡分区已经mount到系统了,应该先umount:umount   /media/***,不然后续操作会出现问题


root@vincent:/# fdisk /dev/sdb               //注意此处不是sdb1,而是sdb,sdb1是sdb的第一个分区,当前这个sdb卡只有一个分区


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): o
Building a new DOS disklabel with disk identifier 0xc0238ad2.
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)
Command (m for help): p


Disk /dev/sdb: 1007 MB, 1007681536 bytes
9 heads, 8 sectors/track, 27335 cylinders, total 1968128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc0238ad2


   Device Boot      Start         End      Blocks   Id  System


Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4, default 1): 1
First sector (2048-1968127, default 2048):    //此处直接回车即可
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-1968127, default 1968127): +256M


Command (m for help): p


Disk /dev/sdb: 1007 MB, 1007681536 bytes
9 heads, 8 sectors/track, 27335 cylinders, total 1968128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc0238ad2


   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      526335      262144   83  Linux


Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4, default 2):        //此处直接回车即可
Using default value 2
First sector (526336-1968127, default 526336):        //此处直接回车即可
Using default value 526336
Last sector, +sectors or +size{K,M,G} (526336-1968127, default 1968127):      //此处直接回车即可
Using default value 1968127


Command (m for help): w                       //必须输入“w”上面的分区才会保存下来        
The partition table has been altered!


Calling ioctl() to re-read partition table.
Syncing disks.
root@vincent:/# fdisk -l


Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000d63d3


   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    19531775     9764864   82  Linux swap / Solaris
/dev/sda2   *    19531776   214843391    97655808   83  Linux
/dev/sda3       214843392  1953523711   869340160   83  Linux


Disk /dev/sdb: 1007 MB, 1007681536 bytes
31 heads, 62 sectors/track, 1024 cylinders, total 1968128 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf3878a60


   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048      526335      262144   83  Linux
/dev/sdb2          526336     1968127      720896   83  Linux
root@vincent:/file# mkfs.vfat  -F  32  -n  boot   /dev/sdb1           //fat32分区,boot是分区的名字
mkfs.vfat 3.0.9 (31 Jan 2010)
root@vincent:/file# mkfs.ext3  -L  system   /dev/sdb2               //ext3分区,system是分区的名字
mke2fs 1.41.14 (22-Dec-2010)
Filesystem label=system
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
45120 inodes, 180224 blocks
9011 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=184549376
6 block groups
32768 blocks per group, 32768 fragments per group
7520 inodes per group
Superblock backups stored on blocks: 
32768, 98304, 163840


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


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



拔掉SD卡,重新插上,就可以检测到一个boot和system两个分区
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值