【CHICHI ETUTOR@ARM/MIPS/PPC】FILE SYSTEM 1 _ INTRODUCTION TO File System
1. What is "File System"
- A filesystem is the methods and data structures that an operating system uses to keep track of files on a disk or partition; that is, the way the files are organized on the disk. The word is also used to refer to a partition or disk that is used to store the files or the type of the filesystem.
2. Where it stores
- File systems are based on block device e.g. Hard disks , Flash
- File system is stored on physical devices in partitions
3. File system type
- For Desktops , EXT2 / EXT3 / EXT4 / FAT / NTFS
- For embedded system , YAFFS2 / JFFS2 / CRAMFS / UBIFS
- Pseudo file system , Proc / sysfs
- For HADOOP , HDFS
- For google distributed system , GFS
4. Mounting a File system
- Kernel must have been compiled to support file system type
- have permission/right to access hardware device for mount
- using mount for file system mounting.
5. Root File System
- mounted at the base of the file system hierarchy (FHS), designed as /
- contain programs and utilities to boot system initialize service, load device driver and mount additional file system
6. File System Hierarchy Standard (FHS)
- establishes a minimum baseline of compatibility between Linux distributions and application program
- allows your application software and developer to predict where certain system elements, including file and directories, can be found on the file system
7. Minimal File System
|-- bin
|-- busybox
|-- sh -> busybox
|-- dev
|-- console
|-- etc
|-- init.d
|-- rcS
|-- lib
|-- ld-2.3.2.so
|-- ld-linux.so.2 -> ld-2.3.2.so
|-- libc-2.3.2.so
|-- libc.so.6 -> libc-2.3.2.so
8. Setting Up Root File System
- Step 1: create file system hierarchy
- Step 2: create device files
- All the device files in a Linux root filesystem are located in the /dev directory
- conserved system device node
Name |Descrption |Type |Major |Minor |Permission
mem |Physical memory access |Char |1 |1 |600
null |Null device |Char |1 |3 |666
zero |Null byte source |Char |1 |5 |666
Random |random number generator |Char |1 |8 |664
tty0 |Current virtual console |Char |4 |0 |600
tty1 |First virtual console |Char |4 |1 |600
ttyS0 |First UART serial port |Char |4 |64 |600
tty |Current TTY device |Char |4 |0 |666
console |System console |Char |5 |1 |600
- Step 3: install libraries and kernel modules
-download drivers for devices , compile ,and copy to /lib/modules
- Step 4: install system utilities
- Step 5: make root file system image
-mkfs.cramfs
- Free the memory
- Open a system console device
- Start the first user space program
10. "init" Process in File system
- "Init" is the ultimate parent of all userspace processes in a Linux system
- "init" runs with scripts (/etc/rc.X) commonly called system V init
- "init" has the concept of a runlevel
- folders corresponding to RunLevel (/etc)
./rcS.d
./rc0.d
./rc6.d
./rc5.d
./rc.local
./rc1.d
./rc2.d
./rc3.d
./rc4.d
- script files in "rc0.d"
- files with S point to service scripts, which invoked with startup instruction
- files with K point to service scripts, which invoked with shutdown instruction
/etc/rc2.d$ ls -l
total 4
lrwxrwxrwx 1 root root 29 Aug 5 19:29 K10unattended-upgrades -> ../init.d/unattended-upgrades
lrwxrwxrwx 1 root root 20 Aug 5 19:29 K20kerneloops -> ../init.d/kerneloops
lrwxrwxrwx 1 root root 18 Oct 1 16:42 K20openipmi -> ../init.d/openipmi
lrwxrwxrwx 1 root root 15 Aug 5 19:29 K20rsync -> ../init.d/rsync
lrwxrwxrwx 1 root root 27 Aug 5 19:29 K20speech-dispatcher -> ../init.d/speech-dispatcher
lrwxrwxrwx 1 root root 27 Oct 13 15:56 K80nfs-kernel-server -> ../init.d/nfs-kernel-server
-rw-r--r-- 1 root root 353 Mar 13 2014 README
lrwxrwxrwx 1 root root 18 Aug 5 19:29 S20sendsigs -> ../init.d/sendsigs
lrwxrwxrwx 1 root root 17 Aug 5 19:29 S30urandom -> ../init.d/urandom
lrwxrwxrwx 1 root root 22 Aug 5 19:29 S31umountnfs.sh -> ../init.d/umountnfs.sh
lrwxrwxrwx 1 root root 18 Aug 5 19:29 S40umountfs -> ../init.d/umountfs
lrwxrwxrwx 1 root root 26 Aug 5 15:41 S59cryptdisks-early -> ../init.d/cryptdisks-early
lrwxrwxrwx 1 root root 20 Aug 5 19:29 S60umountroot -> ../init.d/umountroot
lrwxrwxrwx 1 root root 14 Aug 5 19:29 S90halt -> ../init.d/halt
0 意見:
張貼留言