0

Hello everybody out there using Linux,

Cloning disk using dd usually works fine for me, but I ran into troubles when cloning a 2 TB disk to a 4 TB one: the dos label would need to be changed to a gpt one to support enlarging to the new size. Is it possible to change that after having cloned the disk with dd?

4
  • what do you mean with dos label? Do you by any chance refer to mbr?
    – LPChip
    Nov 26, 2021 at 9:29
  • 1
    If you're asking before cloning then creating (GPT) partitions first (of equal or larger sizes) and cloning partition by partition is probably a good idea (the filesystems will need to be expanded separately). If you're asking after the cloning then please edit and post the output of fdisk -l /dev/sdX, where sdX is the 4 TB disk. Which case is it? Nov 26, 2021 at 9:37
  • @LPChip fdisk reports Disklabel type: dos for DOS partition table in MBR, Disklabel type: gpt for GPT. I interpret the question according to these. Nov 26, 2021 at 9:43
  • 1
    There is a similar question here that I answered: superuser.com/questions/1688340/…
    – r2d3
    Nov 26, 2021 at 17:03

1 Answer 1

1

Yes, after cloning the disk, you can use gdisk to perform in-place conversion of the DOS/MBR label to a GPT one. (There is no specific menu command for that – the label will be automatically converted to GPT as soon as you use w to write it.)

(For scripts, the same thing can be done non-interactively using sgdisk --mbrtogpt.)


Alternatively, first create a GPT label on the new disk, create all partitions of the exact sizes needed (using fdisk, sfdisk, gdisk, or whatever tool you prefer), and clone the individual partitions using dd one by one.

This method has advantages – e.g. when cloning a partition with NTFS filesystem, you can instead use ntfsclone which skips empty areas making the process faster.

One possible way to clone the partition layout from a MBR disk to a GPT disk is:

sfdisk --dump /dev/OLD | sed "s/^label:.*/label: gpt/; /^label-id:/d" | sfdisk /dev/NEW

(Don't bother cloning the BIOS boot sector manually, as most likely you'll need to install a new GPT-aware boot sector anyway.)

2
  • The command sudo sgdisk --mbrtogpt /dev/sdb ran without an error message, but I can't boot the disk. Nov 26, 2021 at 18:13
  • Yeah, because the bootloader that's currently on the disk is expecting the original MBR layout. At minimum, if you want to convert BIOS-MBR to BIOS-GPT, you'll have to reinstall GRUB to that disk. regardless of the conversion method that was used. (If you also want to convert it from BIOS-style to UEFI, or if you need to convert BIOS to UEFI because it contains Windows, that's a whole another topic -- and one that already has several threads posted about.) Nov 26, 2021 at 18:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .