TransWikia.com

what is the meaning of the "diag" flag reported by gparted

Ask Ubuntu Asked by 4dummies on January 10, 2021

I’m using gparted on a dual-boot system, and a partition that I think is used by Windows shows up with the "diag" flag, in spite of it being listed as an ext4 format. Not readable, however, so the partition signature may be corrupt. So I’m just confused.

I’d like to know what the flag means to gparted, and where it is in the MBR or perhaps the partition signature, and how I could see that same flag in the output of lsblk or some other command-line utility (I want to recognize it in a bash script). Right now it’s just an enigma.

2 Answers

Thanks to @PonJar. I'm collecting our conversation into another answer.

"diag" is reported by gparted. The same flag is reported as "msftres" by parted, and the partitions are reported as "Microsoft Recovery Partition" in Windows 10's Disk Management. It may be that the flag has other uses, but for my purposes, this means that the partition is for the benefit of Windows. It appears that Microsoft does not bother with a filesystem signature for these partitions, so I can't make any inferences about the presence of data or its format.

For scripting, I've decided to use "parted /dev/<drive name> print" and filter the line(s) of interest. For example, for partition 3, I might use

if parted /dev/sda print | 
    sed -e "1,/Number/"d" | 
    grep -e "^ *3 " | 
    fgrep msftres >/dev/null
then
    DIAG=1
else
    DIAG=0
fi

Correct answer by 4dummies on January 10, 2021

The parted manual is helpful for this question. It says;

‘DIAG’

(MS-DOS) - Enable this to indicate that a partition can be used as a diagnostics / recovery partition.

The full document is here https://www.gnu.org/software/parted/manual/html_node/set.html

You should be able to output flags with

lsblk -o NAME,PARTFLAGS

However this doesn’t seem to work for all partition types. Add any other required fields after PARTFLAGS. You can list all available fields with lsblk -h

Edited 3 October to correct typo and add:

Looks like you can get better flag information that may help using parted:

sudo parted -l

It should be possible to process the output of this to get the flags you need.

Answered by PonJar on January 10, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP