Linux file system migration-root file system creation

Source: Internet
Author: User
Tags temporary file storage
Linux file system migration-root file system creation is always an important part of all Unix-like operating systems, it can also be considered that the embedded Linux system is different from some other important features of traditional embedded operating systems. it brings many powerful and flexible features to Linux... linux file system migration-root file system creation is always an important part of all Unix-like operating systems, it can also be considered that the embedded Linux system is different from some other important features of traditional embedded operating systems. it brings many powerful and flexible functions to Linux, but also brings some complexity. We need to clearly understand the basic structure of the root file system, carefully select the required system Library, kernel modules and applications, and configure various initialization script files, and select the appropriate file system type and place it in the appropriate location of the actual storage device. The Linux root file system is organized in a tree structure, including the various files and programs required by the kernel and system management, generally, the top-level directories under the root directory "/" have some fixed names and purposes.
The following lists a common directory structure in the Linux root file system:/bin stores binary executable commands, which stores basic commands that can be used by all users, these commands can be used before mounting other file systems, so the/bin directory must be in the same partition as the root file system. Common commands in the/bin directory include cat, chgrp, chmod, cp, ls, sh, kill, mount, umount, mkdir, m knod ,[, the "[" command such as test is actually the test command. when we use Busybox to create the root file system, we can see some executable files in the generated bin directory, that is, some available commands.
/Dev: The Directory where device files are stored: www.2cto.com. the device files are special file types in Linux. in Linux, you can access various devices by file, that is, you can read and write a device file to operate a specific hardware. For example, you can use the "dev/ttySAC0" file to operate on the serial port 0. you can use "/dev/mtdblock1" to access the 2nd partitions of the MTD device. The/etc directory stores system management and configuration files. this directory stores various configuration files. for Linux systems on PCs, there are many files and directories under the/etc directory, these directory files are optional. they depend on all applications in the system and on whether these programs need configuration files. In an embedded system, the content can be greatly reduced. /Home: the user's home directory. for example, if the user's home directory is/home/user, you can use ~ User indicates the user directory, which is optional. for every common user, there is a subdirectory named after the user name under the/home directory, which stores the user-related configuration files. /Lib stores the dynamic link shared library directory, which stores the shared library and the load (driver). the shared library is used to start the system. Run executable programs in the root file system, such as programs in the/bin/sbin directory. /Sbin stores the directory of administrative programs used by the system administrator. this directory stores system commands, that is, commands only available to the Administrator. system commands can also be stored in/usr/sbin, in the/usr/local/sbin directory, the/sbin Directory stores basic system commands, which are used to start the system and repair the system. they are similar to the/bin directory, you can use/sbin before mounting other file systems. Therefore, the/sbin directory must be in the same partition as the root file system. Common commands in the/sbin directory include shutdown reboot fdisk fsck and so on. The system commands installed by local users are stored in the/usr/local/sbin directory. /Tmp public temporary file storage points are used to store temporary files, usually empty directories. some programs that need to generate temporary files use the/tmp directory, therefore, the/tmp directory must exist and be accessible. The root user directory of the/root system administrator's main directory. corresponding to this, the common user directory is a subdirectory under/home. /The mnt system provides this directory for users to temporarily mount other file systems. It is used to temporarily mount the mount point of a file system, usually an empty directory. you can also create a subdirectory that causes null in it, such as/mnt/cdram/mnt/hda1. It is used to temporarily mount a CD or hard disk. /Proc virtual file system. you can directly access this directory to obtain system information. This is an empty directory, which is often used as the Mount point of the proc file system. The proc file system is a virtual file system, and it does not have an actual storage device, files are generated temporarily by the kernel to indicate the running status of the system. you can also operate the file control system. The largest directory of www.2cto.com/usr, where almost all applications and files are used. The content of the/usr directory can be stored in another partition. after the system is started, it is mounted to the/usr directory in the root file system. It stores shared and read-only programs and data, which indicates that the content in the/usr directory can be shared among multiple hosts. these files comply with the FHS standard. Files in/usr should be read-only, and files related to other hosts should be stored in other directories, such as/var. The/usr directory can be reduced in embedded systems. The overflow area of some large files in/var is opposite to that in the/usr Directory. The/var Directory stores variable data, such as the spool Directory (mail, news), log file, and temporary file. --------------------------------------------------------------------- One, transplant environment: 1, Ubuntu 10.10 release version 2, u-boot.bin http://download.csdn.net/detail/baby_afu/44128263 , The target machine: FS_S5PC100 platform 4, cross compiler arm-cortex_a8-linux-gnueabi-gcc slave 2, porting step 1, Source Code Download we choose is busybox-1.17.3.tar.bz2 download path: http://busybox.net/downloads/2 , Unzip the source code $ tar xvf busybox-1.17.3.tar.bz23, enter the source code directory $ cd busybox-1.17.3 4, configure the source code $ make menuconfig www.2cto.com Busybox Settings ---> Build Options ---> [*] Build BusyBox as a static binary (no shared libs) [] Force NOMMU build [] Build with Large File Support (for accessing files> 2 GB) (arm-cortex_a8-linux-gnueabi-) Cross Compiler prefix () additional CFLAGS5, compile www.2cto.com $ make 6, and install busybox by default. Path: _ install $ make install 7 under the source code directory, go to the installation directory $ cd _ install $ lsbin linuxrc sbin usr 8, and create other required directories $ mkdir dev etc mnt proc var tmp sys root www.2cto.com 9. add a library and create a lib folder under the _ install directory, copy the library in the toolchain to the lib directory $ mkdir lib $ cp/home/linux/x-tools/arm-cortex_a8-linux-gnueabi/arm-cortex_a8-linux-gnueabi/lib /*. /lib/delete all directories and ,. o files and. file a, slimming the library to reduce the size of the file system $ rm *. o *. a $ arm-cortex_a8-linux-gnueabi-strip lib/* 10, add a system Add the inittab $ vim/etc/inittab file under etc as follows: www.2cto.com # this is run first started t when booting in single-user mode.: sysinit:/etc/init. d/rcS #/bin/sh invocations on selected ttys # Start an "askfirst" shell on the console (whatever that may be): askfirst: -/bin/sh # Stuff to do when restarting the init process: restart:/sbin/init # Stuff to do before rebooting: ctrlaltdel: /sbin/reboot add File f under etc The content of the stab $ vim/etc/fstab file is as follows: www.2cto.com # device mount-point type options dump fsck orderproc/proc defaults 0 0 tmpfs/tmp tmpfs defaults 0 0 0 sysfs/sys sysfs defaults 0 0 tmpfs/dev tmpfs defaults 0 0 Here we the mounted file system has three proc, sysfs, and tmpfs, in the kernel, proc and sysfs are supported by default, but tmpfs is not supported. we need to add tmpfs support to modify the kernel configuration: $ make menuconfig www.2cto.com File systems ---> Pseudo filesystems ---> [*] Virtual memory file system sup Port (former shm fs) [*] Tmpfs POSIX Access Control Lists re-compile the kernel $ make zImage to create init under etc. d directory, and in init. d. create the RFM file $ mkdir/etc/init. d-p $ vim/etc/init. the content of the d/rcS file is :#! /Bin/sh # This is the first script called by init process/bin/mount-a: $ chmod + x init. d/rcS add the profile file $ vim/etc/profile under etc. the file content is: www.2cto.com #! /Bin/shexport HOSTNAME = farsightexport USER = rootexport HOME = root # export PS1 = "\ [\ u @ \ h \ W \] \ $" export PS1 = "[$ USER @ $ HOSTNAME \ W] \ # "PATH =/bin: /sbin:/usr/bin:/usr/sbinLD_LIBRARY_PATH =/lib:/usr/lib: $ LD_LIBRARY_PATHexport PATH LD_LIBRARY_PATH 11. it is required to create a device node in the root file system of the device file. create a console node under dev $ mknod dev/console c 5 important: if the size of the new file system exceeds 8 MB, delete unnecessary library files. Author lr_ting
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.