프로젝트 2 Root Filesystem 단국대학교 컴퓨터학과 2009 백승재 baeksj@dankook.ac.kr http://embedded.dankook.ac.kr/~baeksj
Ramdisk 에대한이해 강의목표 Root filesystem 의구조이해 Root filesystem 제작과정이해 Ramdisk 기반 root filesystem 제작
3 RAMdisk? Host 의 file system loopback device 란 : 파일하나를마치디바이스처럼취급할수있게해준다. 즉파일한개를마치하나의디스크처럼인식시켜준다. 이이미지가마치하나의디바이스처럼취급되어마운트될수있게해준다. mount 될이미지 mount 될디렉토리 Target board 에서사용될 file system HDD가없는 Embedded System에서 RAM 상에디스크처럼쓸수있도록구축한공간
4 RAMdisk 수정 RAMdisk 에추가할임의의파일을복사
5 압축전에반드시마운트를해제 수정된새로운 RAMdisk 확인
6 수정된 RAMdisk 로부팅확인
7 Root filesystem 1 image file 내부에 file system 구조를만들어서 loop back device 로 mount 하여일반 file system 과같이사용하는파일을말한다. Image file 내부에 root filesystem 을만 든다. dd if=/dev/zero of=ramdisk bs=1k count=16384 image file mke2fs ramdisk image file mount mkdir mnt && mount -t ext2 ramdisk ram_point o loop mkdir bin dev etc lib mnt proc root sbin tmp usr var
8 Root filesystem 2 /dev device file device file /etc /bin /sbin busybox cross /lib module
9 Root filesystem 3 /var /var/log umount ram_point gzip -9 ramdisk kernel ramdisk image
10 램디스크제작 디스크에루트파일시스템을만들기위한임시파일을만든다. 블록의크기만들어질파일의크기 O 으로채운다. 출력될장소
11 생성된이미지에파일시스템을만들어준다. 즉 ramdisk 에파일시스템을만들어준다. 만들어진이미지를확인할수있다.
12 mount 될디렉토리를만들어준다. 이디렉토리에서루트파일시스템을구성할것이다. Mount 된디렉토리에가서내용을확인해보면디폴트로생성된것을확인할수있다.
13 루트파일시스템의구성을만들어준다. 리눅스의디렉토리의구조와유사하게생성됨을볼수있다.
/dev (1/5) 14 /dev device device file. device file host /dev host device file mknod. Rebis kernel device device file. ( ) console fb3 flh1 mixer null ram3 tty1 tty7 ttys0 dsp fb4 flh2 mtdblock0 ptmx random tty2 tty8 ttys1 fb fb5 flh3 mtdblock1 pts root tty3 ttyp0 ttysa0 fb0 fb6 initctl mtdblock2 ram0 ts tty4 ttyp1 ttysa1 fb1 fb7 kmem mtdblock3 ram1 tty tty5 ttyp2 ttysa2 fb2 flh0 mem mtdblock4 ram2 tty0 tty6 ttyp3 urandom zero
/dev (2/5) 15 /dev cp -dpr /dev/audio./mnt/dev cp -dpr /dev/dsp./mnt/dev cp -dpr /dev/fb./mnt/dev cp -dpr /dev/fb[0-7]./mnt/dev cp -dpr /dev/hda./mnt/dev cp -dpr /dev/hda[0-8]./mnt/dev 1 cp -dpr /dev/initctl./mnt/dev cp -dpr /dev/input./mnt/dev cp -dpr /dev/ircomm[0-1]./mnt/dev cp -dpr /dev/irnet./mnt/dev cp -dpr /dev/kmem./mnt/dev cp -dpr /dev/log./mnt/dev cp -dpr /dev/mem./mnt/dev cp -dpr /dev/mixer./mnt/dev cp -dpr /dev/mouse./mnt/dev cp -dpr /dev/null./mnt/dev cp -dpr /dev/pts./mnt/dev cp -dpr /dev/ram[0-3]./mnt/dev cp -dpr /dev/random./mnt/dev cp -dpr /dev/rtc./mnt/dev cp dpr uid, gid,,
/dev (3/5) 16 cp -dpr /dev/tty./mnt/dev cp -dpr /dev/tty[0-8]./mnt/dev cp -dpr /dev/ttyp[0-3]./mnt/dev cp -dpr /dev/ttys[0-1]./mnt/dev cp -dpr /dev/ttysa[0-2]./mnt/dev cp -dpr /dev/urandom./mnt/dev cp -dpr /dev/video./mnt/dev cp -dpr /dev/zero./mnt/dev 2 mknod./mnt/dev/flh0 b 60 0 mknod./mnt/dev/flh1 b 60 1 mknod./mnt/dev/flh2 b 60 2 mknod./mnt/dev/flh3 b 60 3 mknod./mnt/dev/keypad c 251 0 mknod./mnt/dev/mmcda b 241 0 mknod./mnt/dev/mmcda1 b 241 1 mknod./mnt/dev/mmcda2 b 241 2 mknod./mnt/dev/mmcda3 b 241 3 mknod./mnt/dev/mmcda4 b 241 4 mknod./mnt/dev/mtd3 c 90 6 mknod./mnt/dev/mtdblock0 b 31 0 mknod./mnt/dev/mtdblock1 b 31 1
/dev (4/5) 17 mknod./mnt/dev/mtdblock2 b 31 2 mknod./mnt/dev/mtdblock3 b 31 3 mknod./mnt/dev/mtdblock4 b 31 4 mknod./mnt/dev/ptmx c 5 2 mknod./mnt/dev/ts c 11 0 ln -s ram0./mnt/dev/root ln -s ttys0./mnt/dev/console root filesystem ram disk ttys0 3
/dev (5/5) 18 /dev shell script
/etc (1/5) 19 /etc. host /etc script target board.. /etc fstab : mount inittab : init ( busybox init ) rc.d/* : system script passwd : shadow : group : system group modules : module loding : network shell
/etc (2/5) 20 /etc TARGETDIR=./mnt/etc for FILES in `cat etcfiles.txt`; do cp -rf /etc/$files $TARGETDIR; done; echo "bin" > $TARGETDIR/ftpusers echo "" > $TARGETDIR/hosts.equiv echo "" > $TARGETDIR/modules 1 127.0.0.1" > $TARGETDIR/networks echo "localnet echo "GMT" > $TARGETDIR/timezone ln -s /proc/mounts $TARGETDIR/mtab etcfiles.txt host /etc
/etc (3/5) 21 etcfiles.txt file fstab group host.conf hosts hosts.allow hosts.deny inittab inputrc ioctl.save issue issue.net ld.so.cache localtime motd nsswitch.conf 2 passwd pcmcia profile protocols rc.d resolv.conf rpc services shadow
/etc (4/5) 22 /etc
/etc (5/5) 23. fstab script network embedded system. /etc/fstab
/lib (1/3) 24 kernel module arm-linux-gcc lib module kernel module. module system system. ld-2.2.3.so libdb.so.2 libnsl.so.1 libtermcap.so.2 ld-linux.so.2 libdb.so.3 libnss_dns-2.2.3.so libtermcap.so. 2.0.8 libc-2.2.3.so libdl-2.2.3.so libnss_dns.so.2 libutil-2.2.3.so libc.so.6 libdl.so.2 libnss_files-2.2.3.so libutil.so.1 libcrypt-2.2.3.so libm-2.2.3.so libnss_files.so.2 libcrypt.so.1 libm.so.6 libresolv-2.2.3.so libdb-2.1.3.so libnsl-2.2.3.so libresolv.so.2
/lib (2/3) 25 script (mklib.sh) libfiles.txt. strip binary symbol string
/lib (3/3) 26
/var (1/2) 27 sub log file login init /var log file. /var log file. mkdir -p./mnt/var/adm./mnt/var/lock/subsys./mnt/var/lib./mnt/var/log \./mnt/var/run./mnt/var/spool/cron/crontabs./mnt/var/tmp touch./mnt/var/log/dmesg touch./mnt/var/log/lastlog touch./mnt/var/log/messages touch./mnt/var/log/wtmp touch./mnt/var/run/runlevel.dir touch./mnt/var/run/utmp
/var (2/2) 28 /var
29 메인시스템응용프로그램 수천개의바이너리명령어를임베디드시스템서어떻게지원할것인가? 완전표준응용프로그램 응용프로그램을하나씩다운받아컴파일하여램디스크에포함 BusyBox 대부분의임베디드시스템서사용 ( 대부분의 Arch 지원 ) 작지만대부분의명령어를지원하며원하는명령어만지원가능 Glibc 나 uclibc 를정적 / 동적링크하여사용가능 TinyLogin 여러로그인유틸리티를모아하나의바이너리파일로만든것 보통 BusyBox 와함께사용 Embutils 많이사용되는명령어프로그램을작게최적화시킨것 ARM, i386, PPC, MIPS 의 4 가지 Arch 지원 정적링크만가능 BusyBox 보다적은명령어지원
30 Busybox 다운받기
압축해제 / 확인 RAMDISK 기능과구조 31
32 파일수정 Red-hat 설정과는다른부분이있기때문에수정필요
33 데비안의경우에는 /etc/ init.d/rcs 에 init 에서처음실행하는스크립트가명시되어있지만 Redhat 에서는 /rc.d/ rc.sysinit 에명시되어있다
34 config BusyBox 의최상위디렉토리 부팅가능한 BusyBox 를만들기위해설정을해줌
35 Root File system 제작 busybox menu 1 General Configuration busybox Build Options build ( cross ) Installation Options install Archival Utilities, Coreutils (ex : ls, cp, cat, ) Console Utilities console Debian Utilities debian
36 Root File system 제작 busybox menu 2 Editors editor (vi, awk, sed, ) Finding Utilities file (find, grep, ) Init Utilities init Login/Password Management Utilities user, group, password (adduser, addgroup, passwd, ) Miscellaneous Utilities (strings, last, ) Linux Module Utilities linux module (insmod, lsmod, rmmod, modprobe) Networking Utilities network server daemon (telnet, netstat, ping, httpd, tarceroute, )
37 Root File system 제작 busybox menu 3 Process Utilities process (ps, kill, top, ) Another Bourne-like Shell shell (ash, msh, ) System Logging Utilities system log daemon Linux System Utilities linux (mount, fdisk, dmesg, ) Debugging Options bebugging symbol Load an Alternate Configuration File loading Save Configuration to an Alternate File
38 Configuration
39 공유라이브러리사용여부설정 CrossCompiler 설정
40 선택을해제한다. Busybox 의 init 은 /etc/inittab 을제대로해석하지못하므로사용하지않도록한다.
41
42
43 Make 수행
44 바이너리파일확인 컴파일해주고나면 busybox 바이너리파일이생성됨을볼수있다.
45 BusyBox Binary File copy 생성된 busybox 를 mount 한디렉토리안의 /bin 디렉토리에복사한다.
46 확인 / 링크확인
47
48 실행파일들을 busybox 에심벌릭링크시켜주면된다.
49
umount root filesystem
51 Booting using New Kernel & New RAMDisk
kernel 설정 kernel Ramdisk 를사용하기위한 kernel 설정