All of lore.kernel.org
 help / color / mirror / Atom feed
* [dm-crypt] LUKS on a jffs2 partition
@ 2014-07-17 22:42 Joe Dougherty
  2014-07-18 11:35   ` Milan Broz
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Dougherty @ 2014-07-17 22:42 UTC (permalink / raw)
  To: dm-crypt

[-- Attachment #1: Type: text/plain, Size: 1245 bytes --]

I have a small embedded device with a raw nand flash using jffs2 filesystem. I want to create a luks container on one of the jffs2 partitions. Everything seems to work fine until I try to mount the file system and I receive the error shown below.  Here are the commands I used to set this up:

    cryptsetup luksFormat /dev/mtdblock4 --cipher=aes-cbc-essiv:sha256

    cryptsetup luksOpen /dev/mtdblock4 efs
At this point I can perform luksDump and all looks OK and the /dev/mapper/efs exists. So I continue to create filesystem:

    mkfs.jffs2  -p -l --eraseblock=0x20000 --no-cleanmarkers --pagesize=0x800 -r ./userdata -o /dev/mapper/efs

Now the mount fails:
    mount -o loud -t jffs2 /dev/mapper/efs /mnt
    MTD: Attempt to mount non-MTD device "/dev/mapper/efs"
    mount: mounting /dev/mapper/efs on /mnt failed: Invalid argument


I have used similar commands successfully for non-jffs2 filesystems. Is this possible with jffs2? Any help appreciated.

Here's some additional version info:

cryptsetup --version
cryptsetup 1.6.2

dmsetup --version
Library version:   1.02.76 (2012-08-07)
Driver version:    4.20.0

uname -a
Linux m-1138 3.0.15+m-1138+gecbbdf0 #1 Tue Jul 8 08:57:12 MST 2014 armv7l GNU/Linux

[-- Attachment #2: Type: text/html, Size: 5559 bytes --]

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

* Re: [dm-crypt] LUKS on a jffs2 partition
@ 2014-07-18 11:35   ` Milan Broz
  0 siblings, 0 replies; 5+ messages in thread
From: Milan Broz @ 2014-07-18 11:35 UTC (permalink / raw)
  To: Joe Dougherty, dm-crypt; +Cc: device-mapper development

On 07/18/2014 12:42 AM, Joe Dougherty wrote:
> I have a small embedded device with a raw nand flash using jffs2
> filesystem. I want to create a luks container on one of the jffs2
> partitions. Everything seems to work fine until I try to mount the
> file system and I receive the error shown below. Here are the
> commands I used to set this up:
>     cryptsetup luksFormat /dev/mtdblock4 --cipher=aes-cbc-essiv:sha256
>     cryptsetup luksOpen /dev/mtdblock4 efs
> At this point I can perform luksDump and all looks OK and the /dev/mapper/efs exists. So I continue to create filesystem:
>     mkfs.jffs2  -p -l --eraseblock=0x20000 --no-cleanmarkers --pagesize=0x800 -r ./userdata -o /dev/mapper/efs
> Now the mount fails:
>     mount -o loud -t jffs2 /dev/mapper/efs /mnt
>     MTD: Attempt to mount non-MTD device "/dev/mapper/efs"
>     mount: mounting /dev/mapper/efs on /mnt failed: Invalid argument
> 
> I have used similar commands successfully for non-jffs2 filesystems. Is this possible with jffs2? Any help appreciated.
> Here's some additional version info:
> cryptsetup --version
> cryptsetup 1.6.2
> dmsetup --version
> Library version:   1.02.76 (2012-08-07)
> Driver version:    4.20.0
> uname -a
> Linux m-1138 3.0.15+m-1138+gecbbdf0 #1 Tue Jul 8 08:57:12 MST 2014 armv7l GNU/Linux

As you already found, there is a similar bug report
https://code.google.com/p/cryptsetup/issues/detail?id=203

In this case it is almost for sure kernel bug, so maybe reporting it
to appropriate kernel list (perhaps jffs related) would be better.
(Adding dm-devel, maybe someone could help as well.)

Milan

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

* Re: LUKS on a jffs2 partition
@ 2014-07-18 11:35   ` Milan Broz
  0 siblings, 0 replies; 5+ messages in thread
From: Milan Broz @ 2014-07-18 11:35 UTC (permalink / raw)
  To: Joe Dougherty, dm-crypt-4q3lyFh4P1g; +Cc: device-mapper development

On 07/18/2014 12:42 AM, Joe Dougherty wrote:
> I have a small embedded device with a raw nand flash using jffs2
> filesystem. I want to create a luks container on one of the jffs2
> partitions. Everything seems to work fine until I try to mount the
> file system and I receive the error shown below. Here are the
> commands I used to set this up:
>     cryptsetup luksFormat /dev/mtdblock4 --cipher=aes-cbc-essiv:sha256
>     cryptsetup luksOpen /dev/mtdblock4 efs
> At this point I can perform luksDump and all looks OK and the /dev/mapper/efs exists. So I continue to create filesystem:
>     mkfs.jffs2  -p -l --eraseblock=0x20000 --no-cleanmarkers --pagesize=0x800 -r ./userdata -o /dev/mapper/efs
> Now the mount fails:
>     mount -o loud -t jffs2 /dev/mapper/efs /mnt
>     MTD: Attempt to mount non-MTD device "/dev/mapper/efs"
>     mount: mounting /dev/mapper/efs on /mnt failed: Invalid argument
> 
> I have used similar commands successfully for non-jffs2 filesystems. Is this possible with jffs2? Any help appreciated.
> Here's some additional version info:
> cryptsetup --version
> cryptsetup 1.6.2
> dmsetup --version
> Library version:   1.02.76 (2012-08-07)
> Driver version:    4.20.0
> uname -a
> Linux m-1138 3.0.15+m-1138+gecbbdf0 #1 Tue Jul 8 08:57:12 MST 2014 armv7l GNU/Linux

As you already found, there is a similar bug report
https://code.google.com/p/cryptsetup/issues/detail?id=203

In this case it is almost for sure kernel bug, so maybe reporting it
to appropriate kernel list (perhaps jffs related) would be better.
(Adding dm-devel, maybe someone could help as well.)

Milan
_______________________________________________
dm-crypt mailing list
dm-crypt-4q3lyFh4P1g@public.gmane.org
http://www.saout.de/mailman/listinfo/dm-crypt

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

* Re: [dm-crypt] LUKS on a jffs2 partition
@ 2014-08-01  9:26     ` Milan Broz
  0 siblings, 0 replies; 5+ messages in thread
From: Milan Broz @ 2014-08-01  9:26 UTC (permalink / raw)
  To: Joe Dougherty, dm-crypt; +Cc: device-mapper development

On 07/18/2014 01:35 PM, Milan Broz wrote:
> On 07/18/2014 12:42 AM, Joe Dougherty wrote:
>> I have a small embedded device with a raw nand flash using jffs2
>> filesystem. I want to create a luks container on one of the jffs2
>> partitions. Everything seems to work fine until I try to mount the
>> file system and I receive the error shown below. Here are the
>> commands I used to set this up:
>>     cryptsetup luksFormat /dev/mtdblock4 --cipher=aes-cbc-essiv:sha256
>>     cryptsetup luksOpen /dev/mtdblock4 efs
>> At this point I can perform luksDump and all looks OK and the /dev/mapper/efs exists. So I continue to create filesystem:
>>     mkfs.jffs2  -p -l --eraseblock=0x20000 --no-cleanmarkers --pagesize=0x800 -r ./userdata -o /dev/mapper/efs
>> Now the mount fails:
>>     mount -o loud -t jffs2 /dev/mapper/efs /mnt
>>     MTD: Attempt to mount non-MTD device "/dev/mapper/efs"
>>     mount: mounting /dev/mapper/efs on /mnt failed: Invalid argument

Interesting nobody from embedded world replied here to the obvious problem
which lies in confusion between MTD (memory technology device) and block devices :)

So how (I understand) it works and what is the workaround for these cases:

The jffs2 (and probably other MTD based filesystems) *requires* MTD device parameter to mount.
 
The /dev/mtdblock* device is created as simulated block device access to underlying MTD device.

Note there is a *hack* in kernel, which allows to mount mtdblock device directly as MTD device,
(it uses underlying device directly - see drivers/mtd/mtdsuper.c for this wonderful magic).

Obviously, if we add another translation layer (dmcrypt or whatever), underlying device
is not an MTD device and this hack fails.

Workaround is to add yet another layer, which simulates new MTD device again on top
of device-mapper stack.

For your example you can do it this way (you need to probably set erase block size
as parameter too):

# modprobe block2mtd block2mtd=/dev/mapper/efs

and the mount newly appeared mtdblock device instead:

# mount -o loud -t jffs2 /dev/mtdblockX /mnt

(I see a lot of kernel warnings here but that's another story.)

Hope this helps.

Milan

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

* Re: LUKS on a jffs2 partition
@ 2014-08-01  9:26     ` Milan Broz
  0 siblings, 0 replies; 5+ messages in thread
From: Milan Broz @ 2014-08-01  9:26 UTC (permalink / raw)
  To: Joe Dougherty, dm-crypt-4q3lyFh4P1g; +Cc: device-mapper development

On 07/18/2014 01:35 PM, Milan Broz wrote:
> On 07/18/2014 12:42 AM, Joe Dougherty wrote:
>> I have a small embedded device with a raw nand flash using jffs2
>> filesystem. I want to create a luks container on one of the jffs2
>> partitions. Everything seems to work fine until I try to mount the
>> file system and I receive the error shown below. Here are the
>> commands I used to set this up:
>>     cryptsetup luksFormat /dev/mtdblock4 --cipher=aes-cbc-essiv:sha256
>>     cryptsetup luksOpen /dev/mtdblock4 efs
>> At this point I can perform luksDump and all looks OK and the /dev/mapper/efs exists. So I continue to create filesystem:
>>     mkfs.jffs2  -p -l --eraseblock=0x20000 --no-cleanmarkers --pagesize=0x800 -r ./userdata -o /dev/mapper/efs
>> Now the mount fails:
>>     mount -o loud -t jffs2 /dev/mapper/efs /mnt
>>     MTD: Attempt to mount non-MTD device "/dev/mapper/efs"
>>     mount: mounting /dev/mapper/efs on /mnt failed: Invalid argument

Interesting nobody from embedded world replied here to the obvious problem
which lies in confusion between MTD (memory technology device) and block devices :)

So how (I understand) it works and what is the workaround for these cases:

The jffs2 (and probably other MTD based filesystems) *requires* MTD device parameter to mount.
 
The /dev/mtdblock* device is created as simulated block device access to underlying MTD device.

Note there is a *hack* in kernel, which allows to mount mtdblock device directly as MTD device,
(it uses underlying device directly - see drivers/mtd/mtdsuper.c for this wonderful magic).

Obviously, if we add another translation layer (dmcrypt or whatever), underlying device
is not an MTD device and this hack fails.

Workaround is to add yet another layer, which simulates new MTD device again on top
of device-mapper stack.

For your example you can do it this way (you need to probably set erase block size
as parameter too):

# modprobe block2mtd block2mtd=/dev/mapper/efs

and the mount newly appeared mtdblock device instead:

# mount -o loud -t jffs2 /dev/mtdblockX /mnt

(I see a lot of kernel warnings here but that's another story.)

Hope this helps.

Milan
_______________________________________________
dm-crypt mailing list
dm-crypt-4q3lyFh4P1g@public.gmane.org
http://www.saout.de/mailman/listinfo/dm-crypt

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

end of thread, other threads:[~2014-08-01  9:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-17 22:42 [dm-crypt] LUKS on a jffs2 partition Joe Dougherty
2014-07-18 11:35 ` Milan Broz
2014-07-18 11:35   ` Milan Broz
2014-08-01  9:26   ` [dm-crypt] " Milan Broz
2014-08-01  9:26     ` Milan Broz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.