Last modified on 16 January 2020, at 09:59

Linux Mint: Disk image

Revision as of 09:59, 16 January 2020 by Denis (Talk | contribs)

Instructions for disk image preparation:

  • Obtain Linux workstation PC. Any recent Linux distribution is ok
  • Open the terminal and print current partitions
$ cat /proc/partitions
  • Attach the disk you are going to clone to the workstation PC with some suitable adapter (for example M.2 SATA SSD to USB 3.0 adapter)
  • Print detected partitions again
$ cat /proc/partitions
8       80 30932992 sdf
8       81  2929664 sdf1
8       82    97280 sdf2
8       83    97280 sdf3
8       84   488448 sdf4

In the example above attached disk named /dev/sdf and it has 4 partitions: /dev/sdf1, /dev/sdf2, /dev/sdf3, /dev/sdf4

  • Open the terminal and save disk layout using fdisk and blkid tools:
$ echo -e "O\nfdisk.layout\nq\n" | sudo fdisk /dev/sdf

# review fdisk.layout file
$ cat fdisk.layout
label: dos
label-id: 0x5a0ae517
device: /dev/sdf
unit: sectors

/dev/sdf1 : start=        2048, size=     5859328, type=83
/dev/sdf2 : start=     5861376, size=      194560, type=ef
/dev/sdf3 : start=     6055936, size=      194560, type=4
/dev/sdf4 : start=     6250496, size=      976896, type=83

$ sudo blkid /dev/sdf* -s UUID -s TYPE > blkid.layout

# review blkid.layout file
$ cat blkid.layout
/dev/sdf1: UUID="34b4205b-d2b9-4e50-9ea1-c559fdab97d3" TYPE="ext4"
/dev/sdf2: UUID="52DE-F66C" TYPE="vfat"
/dev/sdf4: UUID="025c89f7-eb46-424b-883b-23f7f0771b27" TYPE="ext4"
  • Ensure disk partitions are unmounted (on some systems they can be mounted automatically)
$ sudo umount /dev/sdf*
  • Save filesystem from each disk partition using partclone tool and compress using lz4 tool.

Partclone tool supports ext2/3/4, ntfs, fat and many other filesystem types, you can clone disks with Linux or Windows installations Install required cloning software: "liblz4-tool" and "partclone"

# for distributions based on Ubuntu/Debian
$ sudo apt update
$ sudo apt install liblz4-tool partclone

In the example above according to blkid.layout:

/dev/sdf1 and /dev/sdf3 have "ext4" filesystem
/dev/sdf2 has "vfat" filesystem
/dev/sdf3 has no filesystem

According to the example need to save 3 partitions:

$ sudo partclone.ext4 -c -s /dev/sdf1 | lz4 > part1.ext4.partclone.lz4
$ sudo partclone.vfat -c -s /dev/sdf2 | lz4 > part2.vfat.partclone.lz4
$ sudo partclone.ext4 -c -s /dev/sdf4 | lz4 > part4.ext4.partclone.lz4
  • Calculate md5 for files you've prepared
$ md5sum *.layout part*.partclone.lz4 > md5sum
  • Send us the fdisk.layout, blkid.layout, part*.partclone.lz4 files and the md5 file