• GPT转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 write them.
    Be careful before using the write command.
    
    
    Command (m for help): p
    Disk /dev/sdb: 465.7 GiB, 500074283008 bytes, 976707584 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
    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
     1      1049kB  126GB  126GB  ntfs         Basic data partition  msftdata
     2      126GB   252GB  126GB  ntfs         Basic data partition  msftdata
     3      252GB   377GB  126GB  ntfs         Basic data partition  msftdata
     4      377GB   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 for hyang0: 
    Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 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
    Disklabel type: dos
    Disk identifier: 0xcf138318
    
    Device     Boot Start       End   Sectors   Size Id Type
    /dev/sda1  *     2048 468862127 468860080 223.6G 83 Linux
    ➜  ~ sudo fdisk /dev/sda
    
    Welcome to fdisk (util-linux 2.30.1).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    
    Command (m for help): p
    Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 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
    Disklabel type: dos
    Disk identifier: 0xcf138318
    
    Device     Boot Start       End   Sectors   Size Id Type
    /dev/sda1  *     2048 468862127 468860080 223.6G 83 Linux
    
    Command (m for help): d
    Selected partition 1
    Partition 1 has been deleted.
    
    Command (m for help): p
    Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 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
    Disklabel type: dos
    Disk identifier: 0xcf138318
    
    Command (m for help): n
    Partition type
       p   primary (0 primary, 0 extended, 4 free)
       e   extended (container for logical 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.6 GiB.
    Partition #1 contains a ext4 signature.
    
    Do you want to remove the signature? [Y]es/[N]o: N
    
    Command (m for help): p
    
    Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 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
    Disklabel type: dos
    Disk identifier: 0xcf138318
    
    Device     Boot Start       End   Sectors   Size Id Type
    /dev/sda1        2048 468862127 468860080 223.6G 83 Linux
    
    Command (m for help): 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 free unpartitioned 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 file
       O   dump disk layout to sfdisk script file
    
      Save & Exit
       w   write table 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 for help): t
    Selected partition 1
    Hex 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     85  Linux 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          88  Linux plaintext de  Dell Utility   
     8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt         
     9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          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) 53  OnTrack 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
    12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f1  SpeedStor      
    14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f4  SpeedStor      
    16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      f2  DOS secondary  
    17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fb  VMware VMFS    
    18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fc  VMware VMKCORE 
    1b  Hidden W95 FAT3 70  DiskSecure 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 80  Old Minix       be  Solaris boot    ff  BBT            
    Hex code (type L to list all codes): 7
    Changed type of partition 'Linux' to 'HPFS/NTFS/exFAT'.
    
    Command (m for help): p
    Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 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
    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 for help): q
    
    ➜  ~ 

    fdisk 命令简介

    Command (m for help): 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 free unpartitioned 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
  • 相关阅读:
    django+xadmin在线教育平台(十七)
    django+xadmin在线教育平台(十六)
    白盒测试法:逻辑覆盖与路径覆盖
    与其放在电脑里占内存,还不如拿出来帮助一群小白白之html篇之十三
    与其放在电脑里占内存,还不如拿出来帮助一群小白白之html篇之十二
    与其放在电脑里占内存,还不如拿出来帮助一群小白白之html篇之十一
    与其放在电脑里占内存,还不如拿出来帮助一群小白白之html篇之十
    与其放在电脑里占内存,还不如拿出来帮助一群小白白之html篇之九
    与其放在电脑里占内存,还不如拿出来帮助一群小白白之html篇之八
    与其放在电脑里占内存,还不如拿出来帮助一群小白白之html篇之七
  • 原文地址:https://www.cnblogs.com/hyang0/p/8072359.html
Copyright © 2020-2023  润新知