热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

Linux下使用fdisk命令将高容量SD卡(SDHC)格成两个分区

刚买了一个4G的TF卡,居然在我的智能山寨机coolo818上不能使用,因为coolo818最大支持2G的卡。于是,就想把高容量的SD卡格成两个2G的盘片来用。在Fedora8下,将一张4G的TF卡(MicroSD),格成两个2G的分区,一个主分区,一个逻辑分区。ps:SD卡有TF卡(现在通称MicroSD),SD卡,MiniSD卡,SDHC等多种,长的不一样;除此之外,还有一种MM

刚买了一个4G的TF卡,居然在我的智能山寨机coolo818上不能使用,因为coolo818最大支持2G的卡。于是,就想把高容量的SD卡格成两个2G的盘片来用。

在 Fedora 8下,将一张4G的TF卡(MicroSD),格成两个2G的分区,一个主分区,一个逻辑分区。

ps:SD卡有TF卡(现在通称MicroSD),SD卡,MiniSD卡,SDHC等多种,长的不一样;除此之外,还有一种MMC卡。

指令:fdisk
用途:观察硬盘之实体使用情形与分割硬盘用。
使用方法:
      一、在 console 上输入 fdisk -l /dev/sdb ,观察硬盘之实体使用情形。
      二、在 console 上输入 fdisk /dev/sdb,可进入分割硬盘模式。
        1. 输入 m 显示所有命令列示。
        2. 输入 p 显示硬盘分割情形。
        3. 输入 a 设定硬盘启动区。
        4. 输入 n 设定新的硬盘分割区。  
           4.1. 输入 e 硬盘为[延伸]分割区(extend)。
         4.2. 输入 p 硬盘为[主要]分割区(primary)。
        5. 输入 t 改变硬盘分割区属性。
        6. 输入 d 删除硬盘分割区属性。
        7. 输入 q 结束不存入硬盘分割区属性。
        8. 输入 w 结束并写入硬盘分割区属性。

[root@localhost ~]# fdisk /dev/sdb      #插入读卡器,在我电脑上显示是sdb,以下黑字为键入部分

The number of cylinders for this disk is set to 189513.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): m       #help
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): p                  #查看
Disk /dev/sdb: 4075 MB, 4075290624 bytes
7 heads, 6 sectors/track, 189513 cylinders
Units = cylinders of 42 * 512 = 21504 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id System
/dev/sdb1               1       93007     1953144    c W95 FAT32 (LBA)
/dev/sdb2           93008      189513     2026626    f W95 Ext'd (LBA)
/dev/sdb5           93008      189513     2026623    c W95 FAT32 (LBA)
Command (m for help): d
Partition number (1-5): 1 #删除1分区,因为之前我已经分成两个区了,所以现在演示时显示有两个分区,总之,先删掉

Command (m for help): d
Partition number (1-5): 2 #删除2分区

Command (m for help): d
No partition is defined yet!

Command (m for help): p

Disk /dev/sdb: 4075 MB, 4075290624 bytes
7 heads, 6 sectors/track, 189513 cylinders
Units = cylinders of 42 * 512 = 21504 bytes
Disk identifier: 0x00000000

#以上为删除原有的分区

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): 1
First cylinder (1-189513, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-189513, default 189513): +2048M

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

0 Empty           1e Hidden W95 FAT1 80 Old Minix       be Solaris boot  
1 FAT12           24 NEC DOS         81 Minix / old Lin bf Solaris       
2 XENIX root      39 Plan 9          82 Linux swap / So c1 DRDOS/sec (FAT-
3 XENIX usr       3c PartitionMagic 83 Linux           c4 DRDOS/sec (FAT-
4 FAT16 <32M      40 Venix 80286     84 OS/2 hidden C: c6 DRDOS/sec (FAT-
5 Extended        41 PPC PReP Boot   85 Linux extended c7 Syrinx        
6 FAT16           42 SFS             86 NTFS volume set da Non-FS data   
7 HPFS/NTFS       4d QNX4.x          87 NTFS volume set db CP/M / CTOS / .
8 AIX             4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility  
9 AIX bootable    4f QNX4.x 3rd part 8e Linux LVM       df BootIt        
a OS/2 Boot Manag 50 OnTrack DM      93 Amoeba          e1 DOS access    
b W95 FAT32       51 OnTrack DM6 Aux 94 Amoeba BBT      e3 DOS R/O       
c W95 FAT32 (LBA) 52 CP/M            9f BSD/OS          e4 SpeedStor     
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs       
f W95 Ext'd (LBA) 54 OnTrackDM6      a5 FreeBSD         ee EFI GPT       
10 OPUS            55 EZ-Drive        a6 OpenBSD         ef EFI (FAT-12/16/
11 Hidden FAT12    56 Golden Bow      a7 NeXTSTEP        f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk     a8 Darwin UFS      f1 SpeedStor     
14 Hidden FAT16 <3 61 SpeedStor       a9 NetBSD          f4 SpeedStor     
16 Hidden FAT16    63 GNU HURD or Sys ab Darwin boot     f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs         fd Linux raid auto
18 AST SmartSleep 65 Novell Netware b8 BSDI swap       fe LANstep       
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid ff BBT           
1c Hidden W95 FAT3 75 PC/IX     
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-189513, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-189513, default 189513): +2048M

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

0 Empty           1e Hidden W95 FAT1 80 Old Minix       be Solaris boot  
1 FAT12           24 NEC DOS         81 Minix / old Lin bf Solaris       
2 XENIX root      39 Plan 9          82 Linux swap / So c1 DRDOS/sec (FAT-
3 XENIX usr       3c PartitionMagic 83 Linux           c4 DRDOS/sec (FAT-
4 FAT16 <32M      40 Venix 80286     84 OS/2 hidden C: c6 DRDOS/sec (FAT-
5 Extended        41 PPC PReP Boot   85 Linux extended c7 Syrinx        
6 FAT16           42 SFS             86 NTFS volume set da Non-FS data   
7 HPFS/NTFS       4d QNX4.x          87 NTFS volume set db CP/M / CTOS / .
8 AIX             4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility  
9 AIX bootable    4f QNX4.x 3rd part 8e Linux LVM       df BootIt        
a OS/2 Boot Manag 50 OnTrack DM      93 Amoeba          e1 DOS access    
b W95 FAT32       51 OnTrack DM6 Aux 94 Amoeba BBT      e3 DOS R/O       
c W95 FAT32 (LBA) 52 CP/M            9f BSD/OS          e4 SpeedStor     
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs       
f W95 Ext'd (LBA) 54 OnTrackDM6      a5 FreeBSD         ee EFI GPT       
10 OPUS            55 EZ-Drive        a6 OpenBSD         ef EFI (FAT-12/16/
11 Hidden FAT12    56 Golden Bow      a7 NeXTSTEP        f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk     a8 Darwin UFS      f1 SpeedStor     
14 Hidden FAT16 <3 61 SpeedStor       a9 NetBSD          f4 SpeedStor     
16 Hidden FAT16    63 GNU HURD or Sys ab Darwin boot     f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs         fd Linux raid auto
18 AST SmartSleep 65 Novell Netware b8 BSDI swap       fe LANstep       
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid ff BBT           
1c Hidden W95 FAT3 75 PC/IX   

Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))

#以上为建2G的主分区,W95 FAT32 (LBA)类型

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
e
Partition number (1-4): 2
First cylinder (95240-189513, default 95240):
Using default value 95240
Last cylinder or +size or +sizeM or +sizeK (95240-189513, default 189513):
Using default value 189513

Command (m for help): t
Partition number (1-5): 2
Hex code (type L to list codes): f
Changed system type of partition 2 to f (W95 Ext'd (LBA))

#以上为创建扩展分区,类型为W95 Ext'd (LBA)

Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (95240-189513, default 95240):
Using default value 95240
Last cylinder or +size or +sizeM or +sizeK (95240-189513, default 189513):
Using default value 189513

Command (m for help): t
Partition number (1-5): 5
Hex code (type L to list codes): c
Changed system type of partition 5 to c (W95 FAT32 (LBA))

#以上为创建逻辑驱动器在扩展分区上,类型为W95 FAT32 (LBA)

Command (m for help): p

Disk /dev/sdb: 4075 MB, 4075290624 bytes
7 heads, 6 sectors/track, 189513 cylinders
Units = cylinders of 42 * 512 = 21504 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id System
/dev/sdb1               1       95239     2000016    c W95 FAT32 (LBA)
/dev/sdb2           95240      189513     1979754    f W95 Ext'd (LBA)
/dev/sdb5           95240      189513     1979751    c W95 FAT32 (LBA)

Command (m for help): w   #保存
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
[root@localhost ~]# find /dev/sdb*
/dev/sdb
/dev/sdb1
/dev/sdb2
/dev/sdb5
mkfs.vfat: /dev/sdb1 contains a mounted file system.
[root@localhost ~]# mkfs.vfat /dev/sdb1
mkfs.vfat 2.11 (12 Mar 2005)
[root@localhost ~]# mkfs.vfat /dev/sdb5   
mkfs.vfat 2.11 (12 Mar 2005)
[root@localhost ~]# cd /mnt
[root@localhost mnt]# mkdir sd1 sd5
[root@localhost mnt]# mount /dev/sdb1 sd1
[root@localhost mnt]# mount /dev/sdb5 sd5     

----------------------------------------------------------

#一下是两个2G的分区合并成一个4G的,方法类似,不在累述。

[root@localhost ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 189513.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

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): p

Disk /dev/sdb: 4075 MB, 4075290624 bytes
7 heads, 6 sectors/track, 189513 cylinders
Units = cylinders of 42 * 512 = 21504 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id System
/dev/sdb1               1       95239     2000016    c W95 FAT32 (LBA)
/dev/sdb2           95240      189513     1979754    f W95 Ext'd (LBA)
/dev/sdb5           95240      189513     1979751    c W95 FAT32 (LBA)

Command (m for help): d
Partition number (1-5): 1

Command (m for help): d
Partition number (1-5): 2

Command (m for help): d
No partition is defined yet!

Command (m for help): p

Disk /dev/sdb: 4075 MB, 4075290624 bytes
7 heads, 6 sectors/track, 189513 cylinders
Units = cylinders of 42 * 512 = 21504 bytes
Disk identifier: 0x00000000

   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): 1
First cylinder (1-189513, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-189513, default 189513):
Using default value 189513

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): c
Changed system type of partition 1 to c (W95 FAT32 (LBA))

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.
[root@localhost ~]# mkfs.vfat /dev/sdb1
mkfs.vfat 2.11 (12 Mar 2005)


推荐阅读
  • 在Docker中,将主机目录挂载到容器中作为volume使用时,常常会遇到文件权限问题。这是因为容器内外的UID不同所导致的。本文介绍了解决这个问题的方法,包括使用gosu和suexec工具以及在Dockerfile中配置volume的权限。通过这些方法,可以避免在使用Docker时出现无写权限的情况。 ... [详细]
  • 学习SLAM的女生,很酷
    本文介绍了学习SLAM的女生的故事,她们选择SLAM作为研究方向,面临各种学习挑战,但坚持不懈,最终获得成功。文章鼓励未来想走科研道路的女生勇敢追求自己的梦想,同时提到了一位正在英国攻读硕士学位的女生与SLAM结缘的经历。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • vue使用
    关键词: ... [详细]
  • 生成式对抗网络模型综述摘要生成式对抗网络模型(GAN)是基于深度学习的一种强大的生成模型,可以应用于计算机视觉、自然语言处理、半监督学习等重要领域。生成式对抗网络 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 本文介绍了在rhel5.5操作系统下搭建网关+LAMP+postfix+dhcp的步骤和配置方法。通过配置dhcp自动分配ip、实现外网访问公司网站、内网收发邮件、内网上网以及SNAT转换等功能。详细介绍了安装dhcp和配置相关文件的步骤,并提供了相关的命令和配置示例。 ... [详细]
  • 本文介绍了brain的意思、读音、翻译、用法、发音、词组、同反义词等内容,以及脑新东方在线英语词典的相关信息。还包括了brain的词汇搭配、形容词和名词的用法,以及与brain相关的短语和词组。此外,还介绍了与brain相关的医学术语和智囊团等相关内容。 ... [详细]
  • 云原生边缘计算之KubeEdge简介及功能特点
    本文介绍了云原生边缘计算中的KubeEdge系统,该系统是一个开源系统,用于将容器化应用程序编排功能扩展到Edge的主机。它基于Kubernetes构建,并为网络应用程序提供基础架构支持。同时,KubeEdge具有离线模式、基于Kubernetes的节点、群集、应用程序和设备管理、资源优化等特点。此外,KubeEdge还支持跨平台工作,在私有、公共和混合云中都可以运行。同时,KubeEdge还提供数据管理和数据分析管道引擎的支持。最后,本文还介绍了KubeEdge系统生成证书的方法。 ... [详细]
  • Echarts图表重复加载、axis重复多次请求问题解决记录
    文章目录1.需求描述2.问题描述正常状态:问题状态:3.解决方法1.需求描述使用Echats实现了一个中国地图:通过选择查询周期&#x ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • IhaveconfiguredanactionforaremotenotificationwhenitarrivestomyiOsapp.Iwanttwodiff ... [详细]
  • Python字典推导式及循环列表生成字典方法
    本文介绍了Python中使用字典推导式和循环列表生成字典的方法,包括通过循环列表生成相应的字典,并给出了执行结果。详细讲解了代码实现过程。 ... [详细]
  • 本文讨论了在Windows 8上安装gvim中插件时出现的错误加载问题。作者将EasyMotion插件放在了正确的位置,但加载时却出现了错误。作者提供了下载链接和之前放置插件的位置,并列出了出现的错误信息。 ... [详细]
  • CSS3选择器的使用方法详解,提高Web开发效率和精准度
    本文详细介绍了CSS3新增的选择器方法,包括属性选择器的使用。通过CSS3选择器,可以提高Web开发的效率和精准度,使得查找元素更加方便和快捷。同时,本文还对属性选择器的各种用法进行了详细解释,并给出了相应的代码示例。通过学习本文,读者可以更好地掌握CSS3选择器的使用方法,提升自己的Web开发能力。 ... [详细]
author-avatar
书友53537817
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有