MyTetra Share
Делитесь знаниями!
Время создания: 08.11.2018 09:24
Текстовые метки: ubuntu partition gpt mbr parted
Раздел: Ubuntu
Запись: Velonski/mytetra-database/master/base/1541651076ig88iu4snb/text.html на raw.githubusercontent.com

Introduction


This article is dedicated to documenting methods of imaging partitions. Typically when one looks for information on the internet for free and open source drive imaging solutions, they find information on partition imaging, described in a way to suggest this is drive imaging, but it is not. Drive imaging is imaging the entire drive (not just one partition if the drive has multiple partitions), for an easy backup, and restoration of an entire drive (all partitions, where the partitions reside on the disk, etc.).


Gathering drive partition information for restoration


If the intention of performing a partition clone, is to either restore that partition to another drive, or to the same drive after changing the filesystem structure, one would want to gather the filesystem metadata. Otherwise, feel free to skip this section.


GPT formatted drive

These instructions assume your drive is partitioned in the GPT format. For more this, please see the UEFI specification here.


Obtain information on flags, labels, sector size, partition table, and filesystem type:


sudo parted /dev/sda print

Model: ATA SanDisk SDSSDP12 (scsi)

Disk /dev/sda: 126GB

Sector size (logical/physical): 512B/512B

Partition Table: msdos

Disk Flags:


Number Start End Size Type File system Flags

1 1049kB 109GB 109GB primary ext4 boot

2 109GB 126GB 17.1GB extended

5 109GB 126GB 17.1GB logical linux-swap(v1)


Next, one will need where the disk sectors start and end, and disk label:


sudo fdisk -l

Disk /dev/sda: 117.4 GiB, 126035288064 bytes, 246162672 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: 0xc57a55d6


Device Boot Start End Sectors Size Id Type

/dev/sda1 * 2048 212768767 212766720 101.5G 83 Linux

/dev/sda2 212770814 246161407 33390594 15.9G 5 Exten

/dev/sda5 212770816 246161407 33390592 15.9G 82 Linux

Next, check sector alignment value of original disk:


sudo gdisk /dev/sda

x

d

Partitions will begin on 2048-sector boundaries.

With this information, one may then restore a partition to one that has the exact same drive metadata.


MBR formatted drive


This is common for a Windows partition (ex. Windows 8.1 with one main partition, and one boot partition).


sudo parted /dev/sda print

Model: ATA Samsung SSD 850 (scsi)

Disk /dev/sda: 250GB

Sector size (logical/physical): 512B/512B

Partition Table: msdos


Number Start End Size Type File system Flags

1 1049kB 368MB 367MB primary ntfs boot

2 368MB 225GB 225GB primary ntfs


sudo fdisk -l


Disk /dev/sda: 250.1 GB, 250059350016 bytes

255 heads, 63 sectors/track, 30401 cylinders, total 488397168 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: 0x99218dc1


Device Boot Start End Blocks Id System

/dev/sda1 * 2048 718847 358400 7 HPFS/NTFS/exFAT

/dev/sda2 718848 439554047 219417600 7 HPFS/NTFS/exFAT


sudo sgdisk -D /dev/sda


***************************************************************

Found invalid GPT and valid MBR; converting MBR to GPT format

in memory.

***************************************************************


2048


Clone a partition with partclone


partclone provides utilities to save and restore just the used blocks on a partition. Partclone supports ext2, ext3, ext4, hfs+, reiserfs, reiser4, btrfs, vmfs3, vmfs5, xfs, jfs, ufs, ntfs, fat(12/16/32), and exfat.


An example of cloning an NTFS drive:


partclone.ntfs -c -d -s /dev/sda1 -o sda1.img

Restore an MBR formatted partition


sudo parted /dev/sda

mklabel

msdos

sudo fdisk /dev/sda

n

p

1

2048

718847

n

p

2

718848

439554047

a

1

i

0x99218dc1

t

1

7

t

2

7

w

sudo partclone.restore -d -s sda1.img -o /dev/sda1

sudo partclone.restore -d -s sda2.img -o /dev/sda2


Windows caveat


While this restoration method will work for Windows 8.1, Windows may temporarily prevent one from using BitLocker. One may fix this issue by booting into the Windows Recovery Environment and executing in a command prompt: }}} bootrec /fixboot }}} For more on this, please see here.

 
MyTetra Share v.0.59
Яндекс индекс цитирования