f2fs学习笔记 - f2fs基础实验环境搭建

1.前言

本文主要记录如何搭建f2fs的环境,用于f2fs文件系统的学习。我们选用了f2fs第一个补丁提交前的内核版本:linux3.7.0。然后通过提取出f2fs的最小补丁来学习f2fs文件系统,这个最小补丁主要涵盖了f2fs作者的前18个patch

Arch: arm
kenrel: kernel 3.7.0
busybox: busybox-1.24.2
gcc: gcc-linaro-arm-linux-gnueabihf-4.7-2013.04-20130415_linux
注:经试验其它版本会导致内核启动时报错,NOTE:gcc版本的选择一般要与内核版本时间相近,推荐使用linaro的版本

2. 基本环境准备

提取f2fs的前18个patch

3f6a0150291b (HEAD -> f2fs_branch) f2fs: update the f2fs document
8377ab02b6a3 f2fs: update Kconfig and Makefile
1c2b6e049f10 f2fs: move proc files to debugfs
f23f0a2f65b5 f2fs: add recovery routines for roll-forward
a9b5553371e4 f2fs: add garbage collection functions
f029047fa7ed f2fs: add xattr and acl functionalities
1f9b35c9b066 f2fs: add core directory operations
3bf7b8e98675 f2fs: add inode operations for special inodes
64c43f6109f7 f2fs: add core inode operations
6b8a900a84a2 f2fs: add address space operations for data
2350d1455a41 f2fs: add file operations
4e4c95127944 f2fs: add segment operations
0ac2640ab9af f2fs: add node operations
0a507cbdc259 f2fs: add checkpoint operations
b3862b18fe88 f2fs: add super block operations
c9e70d0dae5e f2fs: add superblock and major in-memory structure
778d9a9c8a2c f2fs: add on-disk layout
868dfc32edd0 f2fs: add document

根文件系统及qemu环境搭建

下载f2fs tools

git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs-tools.git

回退到与初始f2fs patch匹配的版本

git reset --hard 050e8712a60c7d982a7be8c076fb72452364dae4 

commit 050e8712a60c7d982a7be8c076fb72452364dae4 (HEAD -> master)
Author: Jaegeuk Kim <jaegeuk.kim@samsung.com>
Date:   Thu Oct 17 15:15:54 2013 +0900

    README: add description how to cross-compile
    
    This patch adds description for the cross-compilation.
    
    Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>

编译f2fs tools的host版本:

sudo apt-get install libtool
sudo apt-get install uuid-dev

autoreconf --install
chmod a+x configure
./configure
make
sudo make install

编译f2fs tools的arm版本

1. Add the below line into mkfs/Makefile.am:
 mkfs_f2fs_LDFLAGS = -all-static
 
2. Add the below line into fsck/Makefile.am:
 fsck_f2fs_LDFLAGS = -all-static

3.sudo LDFLAGS=--static ./configure --host=arm-none-linux-gnueabi --target=arm-none-linux-gnueabi

4.make

3. 配置内核

  1. 开启如下内核选项:
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_LOOP_MIN_COUNT=8

CONFIG_FS_POSIX_ACL=y
CONFIG_F2FS_FS=m
CONFIG_F2FS_STAT_FS=y
CONFIG_F2FS_FS_XATTR=y
CONFIG_F2FS_FS_POSIX_ACL=y
  1. 给内核打上下载好的补丁

4. 编译内核

make zImage dtbs moduels
编译时会报如下的WARNING:

WARNING: modpost: missing MODULE_LICENSE() in fs/f2fs/f2fs.o

如果不修复此 warning,在insmode f2fs.ko时会提示undefined symbol错误
修复方法:
在fs/f2fs/super.c中加入:

MODULE_LICENSE("GPL");

5. 制作f2fs文件系统镜像

dd if=/dev/zero of=~/qemu/out/f2fs.img bs=1M count=128
sudo mkfs.f2fs -l myf2fs f2fs.img

insmod f2fs.ko

mount -t f2fs f2fs.img /mnt -o loop

猜你喜欢

转载自blog.csdn.net/jasonactions/article/details/121388947