GPT转MBR

摘要:
我问是不是在win7上打的开,但在单位的windowsxp上打不开?把盘拿来一看,的确是这个问题。应该是在win7上分的GTP分区,windowsxp不识别。目标:将GPT分区转为MBR步骤:先查看当前盘的分区:~sudofdisk/dev/sdbWelcometofdisk.Changeswillremaininmemoryonly,untilyoudecidetowritethem.Becarefulbeforeusingthewritecommand.Command:pDisk/dev/sdb:465.7GiB,500074283008bytes,976707584sectorsUnits:sectorsof1*512=512bytesSectorsize:512bytes/512bytesI/Osize:512bytes/512bytesDisklabeltype:gptDiskidentifier:ED2D2D22-4506-436C-9D95-9AF27790A8B1DeviceStartEndSectorsSizeType/dev/sdb12048245762047245760000117.2GMicrosoftbasicdata/dev/sdb2245762048491522047245760000117.2GMicrosoftbasicdata/dev/sdb3491522048737282047245760000117.2GMicrosoftbasicdata/dev/sdb4737282048976703487239421440114.2GMicrosoftbasicdatafdisk显示Disklabeltype:gpt,即是GPT分区没错。记住分区表的各StartEnd地址,这个是重建分区表的基础。对原分区数据进行备份,可以用rsync将数据同步到其它地方,支持中断续传。数据备份完后,使用parted将盘的分区格式转为msdos,也即MBR格式。
故事背景:

一个朋友说他的移动硬盘在有的电脑有打的开,在有的上面打不开。我问是不是在win7上打的开,但在单位的windows xp上打不开?

把盘拿来一看,的确是这个问题。应该是在win7上分的GTP分区,windows xp不识别。

目标:

将GPT分区转为MBR

步骤:

先查看当前盘的分区:

➜  ~ sudo fdisk /dev/sdb

Welcome to fdisk (util-linux 2.30.1).
Changes will remain in memory only, until you decide to writethem.
Be careful before using the writecommand.


Command (m forhelp): p
Disk /dev/sdb: 465.7 GiB, 500074283008 bytes, 976707584sectors
Units: sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disklabel type: gpt
Disk identifier: ED2D2D22-4506-436C-9D95-9AF27790A8B1

Device         Start       End   Sectors   Size Type
/dev/sdb1       2048 245762047 245760000 117.2G Microsoft basic data
/dev/sdb2  245762048 491522047 245760000 117.2G Microsoft basic data
/dev/sdb3  491522048 737282047 245760000 117.2G Microsoft basic data
/dev/sdb4  737282048 976703487 239421440 114.2G Microsoft basic data

fdisk显示Disklabel type: gpt,即是GPT分区没错。记住分区表的各Start End地址,这个是重建分区表的基础。

对原分区数据进行备份, 可以用rsync将数据同步到其它地方,支持中断续传。

数据备份完后,使用parted将盘的分区格式转为msdos,也即MBR格式。

(parted) select /dev/sdb                                                  
Using /dev/sdb
(parted) print                                                            
Model: WD Elements 25A2 (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End    Size   File system  Name                  Flags
 11049kB  126GB  126GB  ntfs         Basic data partition  msftdata
 2126GB   252GB  126GB  ntfs         Basic data partition  msftdata
 3252GB   377GB  126GB  ntfs         Basic data partition  msftdata
 4377GB   500GB  123GB  ntfs         Basic data partition  msftdata

(parted) help mklabel                                                     
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition
        table)

    LABEL-TYPE is one of: atari, aix, amiga, bsd, dvh, gpt, mac, msdos,
        pc98, sun, loop
(parted) mklabel msdos                                                    
Warning: The existing disk label on /dev/sdb will be destroyed and all data on
this disk will be lost. Do you want to continue?Yes/No?Yes                                                               
(parted) print                                                            
Model: WD Elements 25A2 (scsi)
Disk /dev/sdb: 500GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start  End  Size  Type  File system  Flags

(parted) quit                                                             
Information: You may need to update /etc/fstab.

下面再使用fdisk对硬盘进行分区,start,end地址与之前保持一致。分完区再将分区类型改为7 HPFS/NTFS/exFAT

由于没有保存操作log,并且朋友的盘也拿走了,这里只做关键点提示,以当前系统盘为例子:

➜  ~ sudo fdisk -l /dev/sda
[sudo] password forhyang0: 
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128sectors
Units: sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disklabel type: dos
Disk identifier: 0xcf138318
Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1  *     2048 468862127 468860080 223.6G 83Linux
➜  ~ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.30.1).
Changes will remain in memory only, until you decide to writethem.
Be careful before using the writecommand.


Command (m forhelp): p
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128sectors
Units: sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disklabel type: dos
Disk identifier: 0xcf138318
Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1  *     2048 468862127 468860080 223.6G 83Linux

Command (m forhelp): d
Selected partition 1Partition 1has been deleted.

Command (m forhelp): p
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128sectors
Units: sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disklabel type: dos
Disk identifier: 0xcf138318
Command (m forhelp): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container forlogical partitions)
Select (default p): p
Partition number (1-4, default 1): 
First sector (2048-468862127, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-468862127, default 468862127): 468862127
Created a new partition 1 of type 'Linux' and of size 223.6GiB.
Partition #1contains a ext4 signature.

Do you want to remove the signature? [Y]es/[N]o: N

Command (m forhelp): p

Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128sectors
Units: sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disklabel type: dos
Disk identifier: 0xcf138318
Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1        2048 468862127 468860080 223.6G 83Linux

Command (m forhelp): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list freeunpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu
   u   change display/entry units
   x   extra functionality (experts only)

  Script
   I   load disk layout from sfdisk script fileO   dump disk layout to sfdisk script file
  Save &Exit
   w   writetable to disk and exit
   q   quit without saving changes

  Create a new label
   g   create a new empty GPT partition table
   G   create a new empty SGI (IRIX) partition table
   o   create a new empty DOS partition table
   s   create a new empty Sun partition table


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

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

Command (m forhelp): p
Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128sectors
Units: sectors of 1 * 512 = 512bytes
Sector size (logical/physical): 512 bytes / 512bytes
I/O size (minimum/optimal): 512 bytes / 512bytes
Disklabel type: dos
Disk identifier: 0xcf138318
Device     Boot Start       End   Sectors   Size Id Type
/dev/sda1        2048 468862127 468860080 223.6G  7 HPFS/NTFS/exFAT

Command (m forhelp): q

➜  ~ 
fdisk 命令简介
Command (m forhelp): m

Help:

  DOS (MBR)
   a   toggle a bootable flag
   b   edit nested BSD disklabel
   c   toggle the dos compatibility flag

  Generic
   d   delete a partition
   F   list freeunpartitioned space
   l   list known partition types
   n   add a new partition
   p   print the partition table
   t   change a partition type
   v   verify the partition table
   i   print information about a partition

  Misc
   m   print this menu

免责声明:文章转载自《GPT转MBR》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Qt5+VS2010的安装及使用Android开发系列之全局变量下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

介绍Oracle自带的一些ASM维护工具 (kfod/kfed/amdu)

1.前言 ASM(AutomaticStorageManagement)是Oracle主推的一种面向Oracle的存储解决方式,它是一个管理卷组或者文件系统的软件。眼下已经被RAC环境广泛使用,可是ASM因为其高度的封装性,使得我们非常难知道窥探其内部的原理。ASM假设一旦出现故障,通常都非常难处理。 即便在有非常完备的RMAN备份的情况下,恢复起来都可...

linux磁盘分区,挂载,卸载分区

前言 一个分区代表了一块具体的存储空间,Linux通过挂载的技术将这块空间挂载了一个具体的目录下面。 简单的说就是分区,格式化,挂载 分区:fdisk /dev/sdc 格式化:mkfs -t xfs /dev/sdc1 挂载:mount /dev/sdc1 /newdisk  参考  https://www.cnblogs.com/superlsj/p...

iview table表头自定义筛选

自定义search input: const searchInput = (h, params, that) =>( <span class="search-area"> <span>{params.column.title}</span> <div class="pop-search-w...

kubernetes配置(kubeconfig)对多集群的访问

配置对多集群的访问 本文展示如何使用配置文件来配置对多个集群的访问。 在将集群、用户和上下文定义在一个或多个配置文件中之后,用户可以使用kubectl config use-context命令快速地在集群之间进行切换。 注意:用于配置集群访问的文件有时被称为kubeconfig 文件。 这是一种引用配置文件的通用方式,并不意味着存在一个名为kubecon...

Mysql常用命令操作小结

Mysql操作大全 一、概述     SQL(Structured Query Language)语言的全称是结构化查询语言。数据库管理系统通过SQL语言来管理数据库中的数据。     SQL语言分为三个部分:数据定义语言(Data DefinitionLanguage,简称为DDL)、数据操作语言(DataManipulation Language,简称...

mysql 按天创建分区存储过程

CREATE PROCEDURE `create_partition_by_day`(IN_SCHEMANAME VARCHAR(64), IN_TABLENAME VARCHAR(64)) BEGIN#当前日期存在的分区的个数 DECLARE ROWS_CNT INTUNSIGNED; #目前日期,为当前日期的后一天 DECLAR...