How can I find the PTUUID of a partition in a Linux IMG file on macOS
Solution 1:
This answer will omit the path /mnt/hgfs/Downloads/RPi/
given in the OP's question.
The 2021-01-11-raspios-buster-armhf-lite.img
file can be download by selecting the Download
link for "Raspberry Pi OS Lite" on the webpage Operating system images.
The output from the macOS command file 2021-01-11-raspios-buster-armhf-lite.img
is given below.
2021-01-11-raspios-buster-armhf-lite.img: DOS/MBR boot sector; partition 1 : ID=0xc, start-CHS (0x40,0,1), end-CHS (0x3ff,3,32), startsector 8192, 524288 sectors; partition 2 : ID=0x83, start-CHS (0x3ff,3,32), end-CHS (0x3ff,3,32), startsector 532480, 3104768 sectors
This output identifies the file as being an image of a drive using a MBR partitioning scheme. Therefore, the macOS command given below will print the PTUUID
. The same command works with Linux.
od -A n -X -j 440 -N 4 2021-01-11-raspios-buster-armhf-lite.img
The output for macOS is shown below.
e8af6eb2
Linux will produce the same values, but the padded spaces may be different. For example, the output for Ubuntu Linux is shown below.
e8af6eb2
Note: This value is not the
PARTUUID
of a partition on the IMG file given in the OP's question.
The macOS command fdisk 2021-01-11-raspios-buster-armhf-lite.img
does a better job displaying the partition table, as shown below.
Disk: 2021-01-11-raspios-buster-armhf-lite.img geometry: 902/64/63 [3637248 sectors]
Signature: 0xAA55
Starting Ending
#: id cyl hd sec - cyl hd sec [ start - size]
------------------------------------------------------------------------
1: 0C 64 0 1 - 1023 3 32 [ 8192 - 524288] Win95 FAT32L
2: 83 1023 3 32 - 1023 3 32 [ 532480 - 3104768] Linux files*
3: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
4: 00 0 0 0 - 0 0 0 [ 0 - 0] unused
Eventually, the PARTUUID
of both partitions is just the PTUUID
with the partition number appended, as shown below.
e8af6eb2-01
e8af6eb2-02
This can be verified by using Ubuntu Linux. The commands and output is given below.
dma@ubuntu:~$ losetup -f # This shows the next available loop.
/dev/loop0
dma@ubuntu:~$ sudo losetup /dev/loop0 -P 2021-01-11-raspios-buster-armhf-lite.img
dma@ubuntu:~$ sudo blkid /dev/loop0p1
/dev/loop0p1: LABEL_FATBOOT="boot" LABEL="boot" UUID="DC3E-E470" TYPE="vfat" PARTUUID="e8af6eb2-01"
dma@ubuntu:~$ sudo blkid /dev/loop0p2
/dev/loop0p2: LABEL="rootfs" UUID="a7adb26a-8b87-4729-99c8-9f5ac069d51e" TYPE="ext4" PARTUUID="e8af6eb2-02"