linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Determine if a given fs is a btrfs fs
@ 2010-10-24 20:24 Felix Blanke
  2010-10-24 21:32 ` Jérôme Poulin
  0 siblings, 1 reply; 5+ messages in thread
From: Felix Blanke @ 2010-10-24 20:24 UTC (permalink / raw)
  To: linux-btrfs

Hi,

I've some btrfs fs which are encrypted with loopaes.

I decrypt them in a script during bootup. Now I want to determine if the decrypted fs
is a btrfs fs. If not I missspelled the password and I can handle that error in my
script.


Thanks for any help!


Felix

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Determine if a given fs is a btrfs fs
  2010-10-24 20:24 Determine if a given fs is a btrfs fs Felix Blanke
@ 2010-10-24 21:32 ` Jérôme Poulin
  2010-10-25 11:31   ` Jérôme Poulin
  0 siblings, 1 reply; 5+ messages in thread
From: Jérôme Poulin @ 2010-10-24 21:32 UTC (permalink / raw)
  To: Felix Blanke; +Cc: linux-btrfs

Here are some cues...
p4 jerome # file -s /dev/mapper/vgP4RAID5-openwrt
/dev/mapper/vgP4RAID5-openwrt: symbolic link to `../dm-22'
p4 jerome # file -s /dev/dm-22
/dev/dm-22: BTRFS Filesystem (label "p4-openwrt", sectorsize 4096,
nodesize 4096, leafsize 4096)
p4 jerome # btrfs device scan /dev/dm-22
Scanning for Btrfs filesystems in '/dev/dm-22'
p4 jerome # echo $?
0
p4 jerome # btrfs device scan /dev/sda
Scanning for Btrfs filesystems in '/dev/sda'
ERROR: unable to scan the device '/dev/sda'
p4 jerome # echo $?
11
p4 jerome # blkid | grep btrfs
/dev/mapper/vgP4RAID5-openwrt: LABEL=3D"p4-openwrt"
UUID=3D"9a68f4cc-4bda-4cdb-9726-481b340f742c"
UUID_SUB=3D"37bfc8b8-c8aa-415e-bbb3-cbb50cca2ab7" TYPE=3D"btrfs"
p4 jerome #


On Sun, Oct 24, 2010 at 4:24 PM, Felix Blanke <felixblanke@gmail.com> w=
rote:
> Hi,
>
> I've some btrfs fs which are encrypted with loopaes.
>
> I decrypt them in a script during bootup. Now I want to determine if =
the decrypted fs
> is a btrfs fs. If not I missspelled the password and I can handle tha=
t error in my
> script.
>
>
> Thanks for any help!
>
>
> Felix
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs=
" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at =A0http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Determine if a given fs is a btrfs fs
  2010-10-24 21:32 ` Jérôme Poulin
@ 2010-10-25 11:31   ` Jérôme Poulin
  2010-10-25 13:29     ` C Anthony Risinger
  0 siblings, 1 reply; 5+ messages in thread
From: Jérôme Poulin @ 2010-10-25 11:31 UTC (permalink / raw)
  To: linux-btrfs

On Sun, Oct 24, 2010 at 5:32 PM, J=E9r=F4me Poulin <jeromepoulin@gmail.=
com> wrote:
=2E..
> p4 jerome # btrfs device scan /dev/dm-22
> Scanning for Btrfs filesystems in '/dev/dm-22'
> p4 jerome # echo $?
> 0
This is OK.

> p4 jerome # btrfs device scan /dev/sda
> Scanning for Btrfs filesystems in '/dev/sda'
> ERROR: unable to scan the device '/dev/sda'
> p4 jerome # echo $?
> 11
=2E..
But isn't that error misleading, btrfs scan was succesfully able to
scan /dev/sda, but, it doesn't contain btrfs, right?
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Determine if a given fs is a btrfs fs
  2010-10-25 11:31   ` Jérôme Poulin
@ 2010-10-25 13:29     ` C Anthony Risinger
  2010-10-25 19:27       ` Felix Blanke
  0 siblings, 1 reply; 5+ messages in thread
From: C Anthony Risinger @ 2010-10-25 13:29 UTC (permalink / raw)
  To: Jérôme Poulin; +Cc: linux-btrfs

On Mon, Oct 25, 2010 at 6:31 AM, J=E9r=F4me Poulin <jeromepoulin@gmail.=
com> wrote:
> On Sun, Oct 24, 2010 at 5:32 PM, J=E9r=F4me Poulin <jeromepoulin@gmai=
l.com> wrote:
> ...
>> p4 jerome # btrfs device scan /dev/dm-22
>> Scanning for Btrfs filesystems in '/dev/dm-22'
>> p4 jerome # echo $?
>> 0
> This is OK.
>
>> p4 jerome # btrfs device scan /dev/sda
>> Scanning for Btrfs filesystems in '/dev/sda'
>> ERROR: unable to scan the device '/dev/sda'
>> p4 jerome # echo $?
>> 11
> ...
> But isn't that error misleading, btrfs scan was succesfully able to
> scan /dev/sda, but, it doesn't contain btrfs, right?

imo, the best way is:

# root must be btrfs else silent return
[ "$(blkid -s TYPE -o value ${root})" =3D btrfs ] || return 0

at least that the way i do it in my initramfs hook; seems to be reliabl=
e.

C Anthony
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Determine if a given fs is a btrfs fs
  2010-10-25 13:29     ` C Anthony Risinger
@ 2010-10-25 19:27       ` Felix Blanke
  0 siblings, 0 replies; 5+ messages in thread
From: Felix Blanke @ 2010-10-25 19:27 UTC (permalink / raw)
  To: C Anthony Risinger; +Cc: Jérôme Poulin, linux-btrfs

Hi,

that was a good hint, thanks a lot!

The best at that solution is that it works for all filesystems: Just te=
st if the
output of $type (type=3D`blkid -s TYPE -o value $loopdev`) is empty (''=
), then it is no
filesystem and the loopaes password was wrong or the device/fs is broke=
n.



=46elix


On 25. October 2010 - 08:29, C Anthony Risinger wrote:
> Date:	Mon, 25 Oct 2010 08:29:58 -0500
> From: C Anthony Risinger <anthony@extof.me>
> To: J=E9r=F4me Poulin <jeromepoulin@gmail.com>
> Cc: linux-btrfs <linux-btrfs@vger.kernel.org>
> Subject: Re: Determine if a given fs is a btrfs fs
>=20
> On Mon, Oct 25, 2010 at 6:31 AM, J=E9r=F4me Poulin <jeromepoulin@gmai=
l.com> wrote:
> > On Sun, Oct 24, 2010 at 5:32 PM, J=E9r=F4me Poulin <jeromepoulin@gm=
ail.com> wrote:
> > ...
> >> p4 jerome # btrfs device scan /dev/dm-22
> >> Scanning for Btrfs filesystems in '/dev/dm-22'
> >> p4 jerome # echo $?
> >> 0
> > This is OK.
> >
> >> p4 jerome # btrfs device scan /dev/sda
> >> Scanning for Btrfs filesystems in '/dev/sda'
> >> ERROR: unable to scan the device '/dev/sda'
> >> p4 jerome # echo $?
> >> 11
> > ...
> > But isn't that error misleading, btrfs scan was succesfully able to
> > scan /dev/sda, but, it doesn't contain btrfs, right?
>=20
> imo, the best way is:
>=20
> # root must be btrfs else silent return
> [ "$(blkid -s TYPE -o value ${root})" =3D btrfs ] || return 0
>=20
> at least that the way i do it in my initramfs hook; seems to be relia=
ble.
>=20
> C Anthony
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs=
" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
---end quoted text---
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" =
in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-10-25 19:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-24 20:24 Determine if a given fs is a btrfs fs Felix Blanke
2010-10-24 21:32 ` Jérôme Poulin
2010-10-25 11:31   ` Jérôme Poulin
2010-10-25 13:29     ` C Anthony Risinger
2010-10-25 19:27       ` Felix Blanke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).