Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer System Laboratory

Similar presentations


Presentation on theme: "Computer System Laboratory"— Presentation transcript:

1 Computer System Laboratory
Lab6 Root Filesystem

2 Experimental Goal Understand the basic process of root filesystem building Lab6 2019/4/9

3 Environment Host System Build System Target System Software
Windows XP/Ubuntu 8.04 Build System Ubuntu 8.04 Target System XScale PXA270 Software BusyBox source code Compiled toolchain mkfs.jffs2 & genext2fs utility Misc. You can download all the source codes from RSWiki CSL Course Software Lab6 2019/4/9

4 Introduction to Root Filesystem
A file system is a method of storing and organizing computer files and their data A root filesystem is the file system that is contained on the same partition on which the root directory is located The exact contents of the root filesystem will vary according to the computer, but they will include the files that are necessary for booting the system It is the filesystem on which all the other filesystems are mounted as the system is booted up ~ from The Linux Information Project Lab6 2019/4/9

5 PXA270 Lab6 2019/4/9

6 Basic Root Filesystem Structure
Root filesystem follows FHS (Filesystem Hierarchy Standard) FHS has the guideline of your filesystem Lab6 2019/4/9

7 Types of File Systems Some well-known file systems
Windows : FAT, NTFS Mac OS X : HFS Plus, UFS Linux : ex*, XFS, JFS, ReiserFS We will use JFFS2 & ext2 in this lab ext2 (The second extended filesystem) A non-journaling file system Writable JFFS2 (Journaling Flash File System Version 2) A journaling file system Writable, compressed, power-down-reliable file system Lab6 2019/4/9

8 Create Root Filesystem Skeleton
Step1 : create a folder for placing root filesystem content % mkdir $HOME/<root filesystem folder’s name> Step2 : create the essential directories % cd <root filesystem folder’s path> % mkdir etc lib var proc mnt dev tmp Lab6 2019/4/9

9 Compiled Toolchain Installation
Step1 : extract binary files % tar –jxvf cross tar.bz2 Step2 : move files to specified location % mkdir /usr/local/arm % sudo mv ./ /usr/local/arm Step3 : append installation directory to PATH % … Test % arm-linux-gcc -v Lab6 2019/4/9

10 Build BusyBox BusyBox contains a collection of stripped-down Unix utilities into a single executable Why BusyBox? You don’t have to configure and build the sources of each utility Step1 : extract source code % tar –zxvf busybox-1.00.tar.gz Step2 : copy header from kernel source % cd busybox-1.00 % cp –R <creator mt-linux path>/pxa270/linux/include/linux \ include % wget tware/version.h % cp version.h include/linux Lab6 2019/4/9

11 Build BusyBox (Cont.) Step3 : configure BusyBox
% make menuconfig Build Options  [*] Build BusyBox as a static binary (no shared libs) [*] Do you want to build BusyBox with a Cross Compiler? (arm-linux-) Cross Compiler prefix Networking Utilities  [ ] route Step4 : compile BusyBox % make -j4 Step5 : install BusyBox % make -j4 install Step6 : move files to your root filesystem folder % mv _install/* <root filesystem folder’s path> Lab6 2019/4/9

12 Create Essential Device Files
Device files allow user programs to access hardware devices on the system through the kernel The kernel just relies on device file’s type and major number to find which driver manages this device Lab6 2019/4/9

13 Create Essential Device Files (Cont.)
The official source of information for device major and minor numbers can be found in Documentation/devices.txt under the kernel source We use a script to create device files % wget tware/mknod.sh % cp mknod.sh <root filesystem folder’s path>/dev % cd <root filesystem folder’s path>/dev % sudo sh mknod.sh % rm mknod.sh Lab6 2019/4/9

14 Misc. Add configuration file used by first user-space program (i.e. /sbin/init) % wget tware/inittab % cp inittab <root filesystem folder’s path>/etc inittab describes which processes are started during bootup The entry syntax of inittab id : runlevels : action : process sysinit : execute the process during system boot askfirst : prompt “Please press Enter to activate this console.” before execution Some other actions: respawn, ctrlaltdel ::sysinit:/etc/rcS ::askfirst:/bin/sh Lab6 2019/4/9

15 Misc. (Cont.) Add system initialization script Change their permission
% wget tware/rcS % cp rcS <root filesystem folder’s path>/etc Change their permission % cd <root filesystem folder’s path>/etc % chmod 777 inittab rcS Please refer to the website below for more information Lab6 2019/4/9

16 Create the Root Filesystem Image
Make a JFFS2 file system image % ./mkfs.jffs2 -v -e 0x pad=0xf r \ <root filesystem folder’s path> -o rootfs.jffs2 Make a ext2 file system image % ./genext2fs -b d <root filesystem folder’s path> \ -e 0 rootfs.ext2 Now you can write rootfs image to board Tip If you choose ext2 file system format, you need to change U-Boot bootargs environment variable $ setenv bootargs root=/dev/mtdblock3 rw rootfstype=ext2 console=ttyS0,9600n8 mem=64M ip= : : : ::et h0:off ether=12:34:56:78:90:ab) Lab6 2019/4/9

17 Change File System Image Size
The size of root filesystem is determined by Linux kernel (in arch/arm/mach-pxa/mach-creator-pxa270.c) Then the corresponding option is required to set % ./mkfs.jffs2 -v -e 0x pad=0xf r \ <root filesystem folder’s path> -o rootfs.jffs2 % ./genext2fs -b d <root filesystem folder’s path> \ -e 0 rootfs.ext2 static struct mtd_partition creator_pxa270_partitions[] = { name: "Filesystem", size: x00f00000, /* 15M for rootfs */ } Lab6 2019/4/9

18 Exercise Refer to previous page, increase the size of the root filesystem to 20Mbytes You can use “df -h” command in Linux shell to check The tftp client utility is not built by default, please add tftp client utility to BusyBox Lab6 2019/4/9


Download ppt "Computer System Laboratory"

Similar presentations


Ads by Google