본문 바로가기

Job Notes/Linux & Android

망고보드에 FUSE & NAND Filesystem 실행하기

Fuse 홈페이지나 기타 Fuse를 설명한 곳에서는 PC 또는 Build 환경에서 사용하거나 ntfs를 사용하는 것을 설명한 곳이 대부분이었다.
이제 프로젝트를 시작하며 처음 리눅스를 접하면서 이들에서 부족한 부분들을 설명한다.

0. 환경
Mango 보드를 RFS로 부팅
0.1 Target
   - 보드 : Mango64
   - Kernel : 2.6.29
0.2 Build
   - OS : Ubuntu 8.04
   - Kernel : 2.6.27-11-generic
0.3 Cross Compiler
   - 4.2.2-eabi

1. Fuse 모듈이 포함된 커널 만들기
1.1 menuconfig에서 FUSE 선택하여 zImage 만듦

1.2 만들어진 zImage를 tftp 부트(/tftpboot)에 복사

2. Fuse 컴파일
2.1 Fuse 최신 소스 다운로드

2.2 소스 컴파일 (참조 : http://www.aesop.or.kr/?document_srl=18024)
1) 아래와 같이 입력
# mkdir out // 보드용 파일들이 만들어질 위치.
#./configure --host=arm-linux --prefix=$(pwd)/out --enable-kernel-module --disable-mtab

--build=build-type
    the type of system on which the package is being configured and compiled (rarely needed); 
--host=host-type
    the type of system on which the package will run; 
--target=target-type
    the type of system for which any compiler tools in the package will produce code.
 
build : 현재 플랫폼,
host  : 설치될 플랫폼
target : 실행될 플랫폼
그 후 kernel 폴더 안으로 가서 Makefile을 열고 11번째 줄에서 아래를 수정한다.

// kernel/Makefile 수정 전
fusemoduledir = /lib/modules/2.6.13-h1940-aesop2440/kernel/fs/fuse

// kernel/Makefile 수정 후
fusemoduledir = ../out

이제 다시 상위 폴더로 간다.
# cd ..

그리고 아래와 같이 실행한다.

# make
# make install

2) 이 후 out 폴더 안을 가 보면 bin 과 lib include 폴더, 그리고 libfuse* 파일들이 만들어져 있는 것을 확인한다.

3. Cross-compile 환경 구성
만들어진 "/bin", "/lib", "/include" 폴더들을 Cross-compile 디렉토리(/usr/local/arm/4.2.2-eabi, /usr/local/arm/4.2.2-eabi/usr)에 복사함
- 이부분은 위 2.2 과정에서 ./out 폴더 대신 /usr/local/arm/4.2.2-eabi를 지정해줘도 됨.

4. 실행할 파일시스템 컴파일
[work] $ arm-linux-gcc -o my_filesystem my_fs.c -lfuse

5. 보드에 올리기
5.1 2.2 과정에서 만들어진 "/bin" 폴더의 파일들을 보드의 "/bin"와 "/usr/bin" 안에 복사한다.
5.2 2.2 과정에서 만들어진 "/lib" 폴더의 파일들을 보드의 "/lib"와 "/usr/lib" 안에 복사한다.
5.3 fuse 확인
1과정에서 커널에 fuse모듈을 포함시켰기 때문에 기본적으로 올라가 있슴.
modprobe fuse에서 에러 발생 시
1)  /etc/ld.so.conf 에 /lib 또는 /usr/lib 가 있는지 확인
2) fusermount이 실행
"fusermount: mount failed: Operation not permitted" 에러 발생 시
-> chmod 4755 /usr/bin/fusermount
3) "fuse: device not found, try 'modprobe fuse' first" 에러 발생 시
-> mknod /dev/fuse c 10 229
-> chmod o+rw /dev/fuse

6. 파일시스템 마운트
./my_filesystem   /마운트포인트
라이브러리 경로가 제대로 안 되어 있을 시
LD_LIBRARY_PATH=/usr/local/lib   ./my_filesystem   /마운트포인트

7. 파일시스템 언마운트
umount /마운트포인트
또는
fusermount -u /마운트포인트

참조:
Filesystem in Userspace 홈페이지 (http://fuse.sourceforge.net/)