# Need help on using jffs2 on block device

## wilho

Ok!

Seems that jffs2 is only compressing rw filesystem on linux there is. Therefore I've tried a whole day to create jffs2 partition on my HD, I'm going to rdiff-backup onto it when it's ready.

My intention is to make /dev/hdc4 to function with jffs2 filesystem. This is what I've done so far:

```
I have these modules installed:

Symbol: MTD [=m]

Prompt: Memory Technology Device (MTD) support

Defined at drivers/mtd/Kconfig:5

Location:

-> Device Drivers

-> Memory Technology Devices (MTD)
```

AND

```
Prompt: MTD emulation using block device

Defined at drivers/mtd/devices/Kconfig:116

Depends on: MTD

Location:

-> Device Drivers

-> Memory Technology Devices (MTD)

-> Self-contained MTD device drivers
```

AND

```
Symbol: JFFS2_FS [=m]

Prompt: Journalling Flash File System v2 (JFFS2) support

Defined at fs/Kconfig:1052

Depends on: MTD

Location:

-> File systems

-> Miscellaneous filesystems

Selects: CRC32
```

Next thing was:

```

#modprobe blkmtd device=/dev/hdc4

#mknod /dev/mtdblock0 b 22 4

```

I'm not sure about usage of mknod command. It seems that blkmtd needs it with udev, without it there's no /dev/mtdblcok* devices at all. I've checked major and minor number from /usr/src/linux/Documentation/devices.txt, I'm not sure but I think they're all right. This is not crucial, but If mknod's ok, how do I make those changes permanent?

Well, story goes on, 

```
#mkfs.jffs2 -o /dev/mtdblock0
```

everything seems to be OK this far, no error messages, but when I do:

```
#mount -t jffs2 /dev/mtdblock0 /mnt/hdc4

mount: wrong fs type, bad option, bad superblock on /dev/mtdblock0
```

Here's something I've done for troubleshooting:

```
#lsmod |grep mtd     

blkmtd                  8884  0 

mtdcore                 5316  3 jffs2,blkmtd

#lsmod |grep jffs

jffs2                  83248  0 

zlib_deflate           21272  1 jffs2

zlib_inflate           17280  1 jffs2

mtdcore                 5316  3 jffs2,blkmtd
```

```
#cat /proc/mtd

dev:    size   erasesize  name

mtd0: 205b0000 00020000 "blkmtd: /dev/hdc4"

```

and if I do 

```
wc -c /dev/mtdblock0
```

I get out size 542836224 bytes ~ 500MB which seems right - thats about the size as how big the partition should be. And if I do 

```
head -n1 /dev/mtdblock0
```

There's some filenames visible in output in middle of carbage, so it seems that /dev/mtdblock0 is OK.

Whats wrong with this, why can't I mount it? Any clues? I'm desperate  :Neutral: 

----------

## wilho

So, no one got no idea?

----------

## lasa

Have you tried this:

```
mkdir empty

mkfs.jffs2 -l --pad=33554432 --eraseblock=0x4000 -d ./empty | dd of=/dev/hda4
```

where -l is for little endian, --pad is the exact size of your partition in bytes, --eraseblock is the block size of your device (can also be specified in decimal) and -d points to the empty directory? You can of course point out a directory that contain files as well, which will then be included in the file system. A binary of mkfs.jffs2 can be downloaded from this page: http://sourceware.org/jffs2/ or emerged through sys-fs/mtd. 

Regards, 

-lasa-

----------

