From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nm45-vm7.bullet.mail.bf1.yahoo.com (nm45-vm7.bullet.mail.bf1.yahoo.com [216.109.115.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.server123.net (Postfix) with ESMTPS for ; Fri, 18 Jul 2014 00:42:22 +0200 (CEST) Message-ID: <1405636940.30842.YahooMailNeo@web140602.mail.bf1.yahoo.com> Date: Thu, 17 Jul 2014 15:42:20 -0700 From: Joe Dougherty Reply-To: Joe Dougherty MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="-118416272-1616380590-1405636940=:30842" Subject: [dm-crypt] LUKS on a jffs2 partition List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "dm-crypt@saout.de" ---118416272-1616380590-1405636940=:30842 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable 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. Everyth= ing seems to work fine until I try to mount the file system and I receive t= he error shown below.=A0 Here are the commands I used to set this up:=0A=0A= =A0=A0=A0 cryptsetup luksFormat /dev/mtdblock4 --cipher=3Daes-cbc-essiv:sha= 256=0A=0A=A0=A0=A0 cryptsetup luksOpen /dev/mtdblock4 efs=0AAt this point I= can perform luksDump and all looks OK and the /dev/mapper/efs exists. So I= continue to create filesystem:=0A=0A=A0=A0=A0 mkfs.jffs2=A0 -p -l --eraseb= lock=3D0x20000 --no-cleanmarkers --pagesize=3D0x800 -r ./userdata -o /dev/m= apper/efs=0A=0ANow the mount fails:=0A=A0=A0=A0 mount -o loud -t jffs2 /dev= /mapper/efs /mnt=0A=A0=A0=A0 MTD: Attempt to mount non-MTD device "/dev/map= per/efs"=0A=A0=A0=A0 mount: mounting /dev/mapper/efs on /mnt failed: Invali= d argument=0A=0A=0AI have used similar commands successfully for non-jffs2 = filesystems. Is this possible with jffs2? Any help appreciated.=0A=0AHere's= some additional version info:=0A=0Acryptsetup --version=0Acryptsetup 1.6.2= =0A=0Admsetup --version=0ALibrary version:=A0=A0 1.02.76 (2012-08-07)=0ADri= ver version:=A0=A0=A0 4.20.0=0A=0Auname -a=0ALinux m-1138 3.0.15+m-1138+gec= bbdf0 #1 Tue Jul 8 08:57:12 MST 2014 armv7l GNU/Linux ---118416272-1616380590-1405636940=:30842 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
I have a small embedded device wit= h a raw nand flash using jffs2 filesystem. I want to create a luks containe= r 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 a= re the commands I used to set this up:

    cryptsetup luksFormat= /dev/mtdblock4 --cipher=3Daes-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=3D0x20000 --no-cleanmarkers --pagesize=3D0x800 -r ./use= rdata -o /dev/mapper/efs
Now the mount fails:
=
    mount -o loud -t jffs2 /dev/mapper/efs /mn= t
    <= /span>MTD: Attempt to mount non-MTD device "/dev/mapper/efs"
    mount: mou= nting /dev/mapper/efs on /mnt failed: Invalid argument

I have used similar commands su= ccessfully for non-jffs2 filesystems. Is this possible with jffs2? Any help= appreciated.
Here's some a= dditional version info:
cryptsetup --version
cryptsetup 1.6.2
dmsetup --version
Libr= ary version:   1.02.76 (2012-08-07)
Driv= er version:    4.20.0
uname -a
Linux m-1138 3.0.15+m-1138+gec= bbdf0 #1 Tue Jul 8 08:57:12 MST 2014 armv7l GNU/Linux

=
---118416272-1616380590-1405636940=:30842-- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-x233.google.com (mail-wi0-x233.google.com [IPv6:2a00:1450:400c:c05::233]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mail.server123.net (Postfix) with ESMTPS for ; Fri, 18 Jul 2014 13:35:23 +0200 (CEST) Received: by mail-wi0-f179.google.com with SMTP id f8so681940wiw.0 for ; Fri, 18 Jul 2014 04:35:22 -0700 (PDT) Message-ID: <53C90676.2060501@gmail.com> Date: Fri, 18 Jul 2014 13:35:18 +0200 From: Milan Broz MIME-Version: 1.0 References: <1405636940.30842.YahooMailNeo@web140602.mail.bf1.yahoo.com> In-Reply-To: <1405636940.30842.YahooMailNeo@web140602.mail.bf1.yahoo.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dm-crypt] LUKS on a jffs2 partition List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Joe Dougherty , "dm-crypt@saout.de" 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-x232.google.com (mail-wi0-x232.google.com [IPv6:2a00:1450:400c:c05::232]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mail.server123.net (Postfix) with ESMTPS for ; Fri, 1 Aug 2014 11:26:08 +0200 (CEST) Received: by mail-wi0-f178.google.com with SMTP id hi2so1000127wib.11 for ; Fri, 01 Aug 2014 02:26:07 -0700 (PDT) Message-ID: <53DB5D2B.5020507@gmail.com> Date: Fri, 01 Aug 2014 11:26:03 +0200 From: Milan Broz MIME-Version: 1.0 References: <1405636940.30842.YahooMailNeo@web140602.mail.bf1.yahoo.com> <53C90676.2060501@gmail.com> In-Reply-To: <53C90676.2060501@gmail.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dm-crypt] LUKS on a jffs2 partition List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Joe Dougherty , "dm-crypt@saout.de" 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