Page 1 of 1

Partially OT - parted -l equivalent without sudo

Posted: Mon Apr 02, 2018 7:12 pm
by Buck Fankers
Didn't see Off Topic forum, hope this is OK to ask here

I'm looking for equivalent of this command:

Code: Select all

parted -l | grep "Partition Table: "
That does not need sudo.
I wrote a small python script in Manjaro, that i'm now porting here to MX, that check few logs for keywords such as "error', "failed"... and few other things. One of them is to check if OS is properly installed such as that partition table matches bios setting like this: BIOS+msdos or UEFI+gpt

I can check how is BIOS set with:

Code: Select all

test -d /sys/firmware/efi && echo UEFI || echo BIOS
But this one will not return anything unless I run it with sudo:

Code: Select all

parted -l | grep "Partition Table: "
Since it is bad sport to toss around to others code that ask for password, :-) I would rather have non sudo equivalent if it is possible. Anyone happen to knows what could I use instead of <parted -l | grep "Partition Table: ">?

Re: Partially OT - parted -l equivalent without sudo

Posted: Mon Apr 02, 2018 7:25 pm
by dolphin_oracle
I don't know if this will do quite what you want but

Code: Select all

udevadm info /dev/sda |grep ID_PART_TABLE_TYPE
will output a partition table type. you have to call each device though.

Re: Partially OT - parted -l equivalent without sudo

Posted: Mon Apr 02, 2018 8:13 pm
by Buck Fankers
That works, thanks.
Do you happen to know, what exact info it returns on EFI machines?
Maybe:

Code: Select all

ID_PART_TABLE_TYPE=efi
Can't test it, my computers are old ;-)

Re: Partially OT - parted -l equivalent without sudo

Posted: Mon Apr 02, 2018 8:17 pm
by dolphin_oracle
well, efi is not a partition type, so it won't return anything.

what do you actually want to know?

this will tell you the Partition type of each partition

Code: Select all

lsblk -o NAME,LABEL,PARTTYPE
with output like

Code: Select all

NAME   LABEL           PARTTYPE
sda                    
├─sda1 SYSTEM_DRV      c12a7328-f81f-11d2-ba4b-00a0c93ec93b
├─sda2                 e3c9e316-0b5c-4db8-817d-f92df00215ae
├─sda3 Windows7_OS     ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
├─sda4 Lenovo_Recovery ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
├─sda5 rootMX17        44479540-f297-41b2-9af7-d131d5f0458a
├─sda6 datapart        ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
├─sda7                 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f
├─sda8 rootMX17        44479540-f297-41b2-9af7-d131d5f0458a
└─sda9 dataext         0fc63daf-8483-4772-8e79-3d69d8477de4
sr0        



note on my sda1 partition this string

Code: Select all

c12a7328-f81f-11d2-ba4b-00a0c93ec93b
that is the GUID itentifier for ESP partitions, which are the partitions where efi stub files are stored for UEFI booting.

Good reading here: https://en.wikipedia.org/wiki/GUID_Partition_Table

Re: Partially OT - parted -l equivalent without sudo

Posted: Mon Apr 02, 2018 8:30 pm
by Buck Fankers
On Manjaro, if you miss match installations, say you install it msdos + UEFI or BIOS + gpt, one of this combo will (or can) cause a problem. Some users managed to get this wrong and I have a noob script that check few things, check logs for errors, check this combo to see if install is correct. On Debian may not be the same. To check I run these two commands:

Code: Select all

test -d /sys/firmware/efi && echo UEFI || echo BIOS'
parted -l | grep "Partition Table: "
If output is one of these two pairs: BIOS+msdos or UEFI+gpt all is OK, otherwise there can be a problems.

On Manjaro i could run second command without sudo, so i could just put it into script. Here it requires SUDO, because of this I'm looking for alternatives, which you gave me. All I need is to know what it returns on newer, modern systems.

But maybe this whole check is not needed on MX systems anyway? I'm quite fresh in Linux world and me doing something silly is usually a norm ;)

Re: Partially OT - parted -l equivalent without sudo

Posted: Mon Apr 02, 2018 8:50 pm
by dolphin_oracle
gotcha

Re: Partially OT - parted -l equivalent without sudo

Posted: Tue Apr 03, 2018 12:25 am
by asqwerth
Buck Fankers wrote:On Manjaro, if you miss match installations, say you install it msdos + UEFI or BIOS + gpt, one of this combo will (or can) cause a problem. Some users managed to get this wrong...

If output is one of these two pairs: BIOS+msdos or UEFI+gpt all is OK, otherwise there can be a problems. ...
Hmm. My Manjaro install:

1. has the honour of being controlling grub on the MBR of the msdos-formatted /dev/sda (ie, BIOS setting is legacy boot)
2. is itself installed on a partition in gpt-formatted /dev/sdb

I don't recall having problems installing it in 2015.

Re: Partially OT - parted -l equivalent without sudo

Posted: Tue Apr 03, 2018 7:08 am
by Buck Fankers
asqwerth wrote: Hmm. My Manjaro install:
1. has the honour of being controlling grub on the MBR of the msdos-formatted /dev/sda (ie, BIOS setting is legacy boot)
2. is itself installed on a partition in gpt-formatted /dev/sdb
I don't recall having problems installing it in 2015.
Well, I never said, problem is guaranteed :p

Sometimes, when community was troubleshooting someones problem, this occasionally appeared as the culprit and it is generally not advised for beginner members.

Similarly with boot customizer. Occasionally it would cause the problem, although many said, works OK with me. Enough to suggest beginners to stay away from potential problems.

Back to original subject, I don't know if it is the same case for Debian or MX. But that script is just my little project, trying to learn some basic in Linux and working on my first baby steps in Python programming.

Anyone with EFI system could you show me, what is the output of this command:

Code: Select all

udevadm info /dev/sda |grep ID_PART_TABLE_TYPE

Re: Partially OT - parted -l equivalent without sudo

Posted: Tue Apr 03, 2018 7:21 am
by richb

Code: Select all

$ udevadm info /dev/sda |grep ID_PART_TABLE_TYPE
E: ID_PART_TABLE_TYPE=gpt
And for /sdd:

Code: Select all

udevadm info /dev/sdd |grep ID_PART_TABLE_TYPE
E: ID_PART_TABLE_TYPE=dos

Re: Partially OT - parted -l equivalent without sudo

Posted: Tue Apr 03, 2018 7:45 am
by Buck Fankers
richb wrote: E: ID_PART_TABLE_TYPE=gpt
Thank you!
I got the 'dos' on my old system, but could not check the output for gpt/uefi.