Forum Discussion
Altera_Forum
Honored Contributor
21 years agojffs2 filesystem image
Hello,
Can someone tell me how to create and use a jffs2 filesystem image ? I have correctly partitionned my flash, and I can mount it (in /home for now). I would like to use it for things like /etc, but for this I need to create an image of my system. I have downloaded mkfs.jffs2 from www.psyent.com (as read in another thread) and I have generated an image from a directory (mkfs.jffs2 -pad=0x1A00000 -d etc -o jffs2.img). I am using an AMD S29GL256M flash with 64K erase blocks size, and the size of the partition I want to mount is 0x1A00000. But now, what can I do with the jffs2.img ? I have read that I should copy it somewhere before mounting it (dd if=jffs2.img of=/dev/mtdblock1), but it doesn't seem to work, i.e. there is nothing in the filesystem, and it is not writeable. Anyway it seems normal since /dev/mtdblock1 is on a romfs, so I cannot copy anything on it with dd ! I am obviously missing something here... Can somebody help me ? Thanks Regards pod11 Replies
- Altera_Forum
Honored Contributor
Well, actually it WAS the good way, it work...
Now, can someone tell me if it is possible to mount a jffs2 filesystem as / partition ? Is there a special option to put in the kernel to achieve that ? Thanks again pod - Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by cetic@Jun 29 2005, 05:24 PM is there a special option to put in the kernel to achieve that ? --- Quote End --- compile jffs2 in the kernel and not as a module mostly does the trick (it recognises the format), but I have never tried this myself on Nios2. - Altera_Forum
Honored Contributor
Hi pod,
> I have downloaded mkfs.jffs2 from www.psyent.com It's best to build/use this under linux. Otherwise, the file permissions may not be correct (for executables ... the execute bits will not be set). Or, you can just modify the code and set the execute bits for the time being. I also recommend that you use the --dev-table option to populate /dev -- it's alot easier than suid root everytime you need to create a device inode just for the fss. And leaving bogus device inodes in a user directory is begging for trouble ;-) > if it is possible to mount a jffs2 filesystem as / partition ? Is there a > special option to put in the kernel to achieve that ? No, but you should use the root kernel parameter to point to the appropriate block device in the kernel command line. E.g.: root = /dev/mtdblock0 Regards, --Scott - Altera_Forum
Honored Contributor
You'll also need to enable JFFS2 file support within the kernel and pass the
rootfstype=jffs2 argument to the kernel via the boot commandline... - Altera_Forum
Honored Contributor
Thanks for the help.
Could you tell me what is the syntax for a device table file ? Regards pod - Altera_Forum
Honored Contributor
Hi pod,
Here's the format. For more details see mkfs.jffs2.c.
The '#' starts a comment line ... but it must be the first character of the line. Regards, --Scott/* device table entries take the form of: <path> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count> /dev/mem c 640 0 0 1 1 0 0 - type can be one of: f A regular file d Directory c Character special device file b Block special device file p Fifo (named pipe) I don't bother with symlinks (permissions are irrelevant), hard links (special cases of regular files), or sockets (why bother). Regular files must exist in the target root directory. If a char, block, fifo, or directory does not exist, it will be created. */ - Altera_Forum
Honored Contributor
Sorry ... I forgot about the <start> <inc> <count> fields:
These are used to define a series of character or block device inodes with the same major number. Basically, it goes like this count: the number of minor devices to create (if > 0) start: the start index (added to minor) inc: the increment
Regards, --Scottif (count > 0) for (i = start; i < count; i++) rdev = MKDEV(major, minor + (i * increment - start)); - Altera_Forum
Honored Contributor
Thanks, it works great, I can mount a jffs2 partition as rootfs at boot time.
The only thing is that boot is much slower, is it proportionnal with the jffs2 partition size (mine is about 30MB) ? Is there a way to shorten boot time ? Thanks again pod - Altera_Forum
Honored Contributor
--- Quote Start --- originally posted by cetic@Jun 30 2005, 01:59 PM the only thing is that boot is much slower, is it proportionnal with the jffs2 partition size (mine is about 30mb) ? is there a way to shorten boot time ? --- Quote End --- I would think that this is mainly due to access to flash being slow: larger sizes, larger read times and incread boot time. However, I never used such a large rootfs, ours are mainly somewhere between 750kB and 2MB (cramfs). http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/huh.gif After boot, it runs from memory. I would think that the usage size would me more important than the partition sizes themselves. I would remove the crud as much as possible. Maybe I'll have a look at the boot times here from flash: the 2.6.12 has a nice feature that prints the timestamps in the kmesgs. - Altera_Forum
Honored Contributor
Hi All,
> ours are mainly somewhere between 750kB and 2MB (cramfs) I'm very fond of cramfs ... it works quite well, generally yields better compression than jffs2, and the images are easier to work with. Although the tools I've used don't support the 'devtable' feature found in mkfs.jffs2. pod, you might want to consider partitioning your flash. Make the root small & perhaps read-only. Then mount jffs2 for read-write access and all the "extra stuff" under /usr. Regards, --Scott