Skip to contentSkip to conversation

when would blkid success but not filesystem type?

DISCUSSION Paul Wise 3 participants 6 messages May 21, 2015 – May 26, 2015 1 message not in the archive Util-Linux package

lore
Share & tools
lore

Paul Wise

author
#1 lore raw
In reply to a message not in the archive
Quoted 5 lines · In https://bugs.debian.org/784709 Jérôme Kieffer wrote:

Here is the answer for the 3.16 kernel:

jerome@patagonia:~$ sudo blkid -o value -s TYPE /dev/sdb4
jerome@patagonia:~$ echo $?
0

...

Quoted 2 lines

The output is the same on 3.2, as you can see on attached images.

Anyone know when blkid would return success but not the filesystem type? This is util-linux 2.25.2-6 with Linux 3.16/3.2 and an extended partition.

Signature · 4 lines
bye,
pabs

https://wiki.debian.org/PaulWise
maintainer
#2 lore raw
Quoted 4 lines · Paul Wise
Quoted 2 lines · In https://bugs.debian.org/784709 Jérôme Kieffer wrote:

Here is the answer for the 3.16 kernel:

Quoted 8 lines
Quoted 3 lines
jerome@patagonia:~$ sudo blkid -o value -s TYPE /dev/sdb4
jerome@patagonia:~$ echo $?
0

...

Quoted 2 lines

The output is the same on 3.2, as you can see on attached images.

Anyone know when blkid would return success but not the filesystem type?

The option '-s' does not affect return code, this option controls output filter only. I have improved the description in the man page to make it more obvious.

blkid returns success always when it's possible to gather any information about the device. The important detail is that the recent versions provide also PARTUUID=, so we have information about all (including empty) partitions!

For example (very very old version from e2fsprogs):

    # blkid /dev/sdc1; echo $?
    2

but the current util-linux upstream:

    #blkid /dev/sdc1; echo $?
    /dev/sdc1: PARTUUID="4b6f59ea-01"
    0

And yes, we have PARTUUID also for MBR partitions, the method used to generate the UUID is the same like kernel uses for root= command line option.

Note that my recommendation is to use lsblk, for example:

    # lsblk --noheading --output FSTYPE /dev/sda1
    vfat

it reads info from udev db (libblkid is only fallback here), and it provides better way how to control output.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
author
#4 lore raw
In reply to Paul Wise
Quoted 8 lines · Paul Wise
Quoted 2 lines · On Thu, 21 May 2015 13:07:35 +0200 Karel Zak wrote:

The option '-s' does not affect return code ... we have information about all (including empty) partitions!

Ok, I see. Sounds like the proposed patch is appropriate then.

https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=12;filename=0001-Fix-by-forcing-fs-type-to-not-detected-if-not-named.patch;att=1;bug=784709

Actually the code in question already contains a code path for when blkid returns success but an empty string. Needs more investigation.

Signature · 4 lines
bye,
pabs

https://wiki.debian.org/PaulWise
author
#3 lore raw
In reply to Karel Zak
Quoted 2 lines · On Thu, 21 May 2015 13:07:35 +0200 Karel Zak wrote:

The option '-s' does not affect return code ... we have information about all (including empty) partitions!

Ok, I see. Sounds like the proposed patch is appropriate then.

https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=12;filename=0001-Fix-by-forcing-fs-type-to-not-detected-if-not-named.patch;att=1;bug=784709

Quoted 1 line

Note that my recommendation is to use lsblk, for example:

That has the same issue:

$ sudo lsblk --noheading --output FSTYPE /dev/sda2 ; echo $?

0

I think for our purposes we would need --nodeps too.

Signature · 4 lines
bye,
pabs

https://wiki.debian.org/PaulWise
#5 lore raw

Bug#784709: Info received (when would blkid success but not filesystem type?)

Thank you for the additional information you have supplied regarding this Bug report.

This is an automatically generated reply to let you know your message has been received.

Your message is being forwarded to the package maintainers and other interested parties for their attention; they will reply in due course.

Your message has been sent to the package maintainer(s):
Debian Install System Team <[email protected]>

If you wish to submit further information on this problem, please send it to [email protected].

Please do not send mail to [email protected] unless you wish to report a problem with the Bug-tracking system.

Signature · 3 lines
784709: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=784709
Debian Bug Tracking System
Contact [email protected] with problems
maintainer
#6 lore raw
In reply to Paul Wise
Quoted 9 lines · Paul Wise
Quoted 2 lines · On Thu, 21 May 2015 13:07:35 +0200 Karel Zak wrote:

The option '-s' does not affect return code ... we have information about all (including empty) partitions!

Ok, I see. Sounds like the proposed patch is appropriate then.

https://bugs.debian.org/cgi-bin/bugreport.cgi?msg=12;filename=0001-Fix-by-forcing-fs-type-to-not-detected-if-not-named.patch;att=1;bug=784709

Quoted 7 lines
Quoted 1 line

Note that my recommendation is to use lsblk, for example:

That has the same issue:

$ sudo lsblk --noheading --output FSTYPE /dev/sda2 ; echo $?

0

Why do you want rely on return code? It is not error when FS type is undefined/unknown. All you need is to check result.

  FSTYPE=$(lsblk --nodeps --noheading --output FSTYPE /dev/sda2)
  [ -n "$FSTYPE" ] && echo $FSTYPE
Quoted 1 line

I think for our purposes we would need --nodeps too.

Yes.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com