对已有 JFFs2文件系统的修改

how to modify jffs2 filesystem

  1. install tool
apt-install mtd-tools
  1. create mtd device
sudo modprobe -v mtd jffs2
//create /dev/mtd0 memsize=50m,erase_size=256KiB
sudo modprobe -v mtdram total_size=50000 erase_size=256
mtdinfo /dev/mtd0 // check mtd 
sudo modprobe -v mtdblock// create /dev/mtdblock0 which is used to mount 
  • you can use modprobe -r xxx to remove xxx dev,
  • note that :must to use the same erase_size with jffs2 image,or the file which mounted bellow will different with src file in image
  1. erase mtd0
sudo flash_eraseall /dev/mtd0
  1. load fs into mtd device and mount it
sudo dd if=fs.jffs2 of=/dev/mtd0 //or flashcp -v fs.jffs2 /dev/mtd0
sudo mkdir fsmount
sudo mount -t jffs2 /dev/mtdblock0 fsmount
cd fsmount// now you can modify what you want
  1. recreate jffs2 filesystem again(note -e args)
sudo mkfs.jffs2 -d fsmount -o fs_new.jffs2 -e 256KiB --pad=0x1000000 -l
sudo sumtool -e 256KiB -p -l -i fs_new.jffs2 -o fs_new.jffs2.sum // add summary to fs if u need

你可能感兴趣的:(linux,linux-fs)