Linux下的文件存储与Windows完全不同,Windows将系统文件存储在系统盘(比如说C:\下)

Linux根本没有盘符到概念只有一个根文件系/,各个磁盘分区挂载在/media/下(或者/mnt/下)

/下到如/etc,/proc,/bin,/dev,lib等很是让用惯了Windows的用户

不解,下面是从Linux.org中找到到比较权威的说明。

4.3.1. /dev

A /dev directory containing a special file for all devices to be used by the system is mandatory for any Linux system. The directory itself is a normal directory, and can be created with mkdir in the normal way. The device special files, however, must be created in a special way, using the mknod command.

There is a shortcut, though — copy devices files from your existing hard disk /dev directory. The only requirement is that you copy the device special files using -R option. This will copy the directory without attempting to copy the contents of the files. Be sure to use an upper case R. For example:         cp -dpR /dev/fd[01]* /mnt/dev

cp -dpR /dev/tty[0-6] /mnt/dev

assuming that the diskette is mounted at /mnt. The dp switches ensure that symbolic links are copied as links, rather than using the target file, and that the original file attributes are preserved, thus preserving ownership information.

If you want to do it the hard way, use ls -l to display the major and minor device numbers for the devices you want, and create them on the diskette using mknod.

However the devices files are created, check that any special devices you need have been placed on the rescue diskette. For example, ftape uses tape devices, so you will need to copy all of these if you intend to access your floppy tape drive from the bootdisk. www.linuxidc.com

Note that one inode is required for each device special file, and inodes can at times be a scarce resource, especially on diskette filesystems. You'll need to be selective about the device files you include. For example, if you do not have SCSI disks you can safely ignore /dev/sd*; if you don't intend to use serial ports you can ignore /dev/ttyS*.

If, in building your root filesystem, you get the error No space left on device but a df command shows space still available, you have probably run out of inodes. A df -i will display inode usage.

Be sure to include the following files from this directory: console, kmem, mem, null, ram0 and tty1.

4.3.2. /etc

The /etc directory contains configuration files. What it should contain depends on what programs you intend to run. On most systems, these can be divided into three groups:

Required at all times, e.g. rc, fstab, passwd.

May be required, but no one is too sure.

Junk that crept in.

Files which are not essential can usually be identified with the command:         ls -ltru

This lists files in reverse order of date last accessed, so if any files are not being accessed, they can be omitted from a root diskette.

On my root diskettes, I have the number of config files down to 15. This reduces my work to dealing with three sets of files:

The ones I must configure for a boot/root system:

rc.d/* -- system startup and run level change scripts

fstab -- list of file systems to be mounted

inittab -- parameters for the init process, the first process started at boot time.

gettydefs -- parameters for the init process, the first process started at boot time.

The ones I should tidy up for a boot/root system:

passwd -- Critical list of users, home directories, etc.

group -- user groups.

shadow -- passwords of users. You may not have this.

termcap -- the terminal capability database.

If security is important, passwd and shadow should be pruned to avoid copying user passwords off the system, and so that unwanted logins are rejected when you boot from diskette.

Be sure that passwd contains at least root. If you intend other users to login, be sure their home directories and shells exist.

termcap, the terminal database, is typically several hundred kilobytes. The version on your boot/root diskette should be pruned down to contain only the terminal(s) you use, which is usually just the Linux or Linux-console entry.

The rest. They work at the moment, so I leave them alone.

Out of this, I only really have to configure two files, and what they should contain is surprisingly small.

rc should contain:         #!/bin/sh

/bin/mount -av

/bin/hostname Kangaroo

Be sure it is executable, be sure it has a "#!" line at the top, and be sure any absolute filenames are correct. You don't really need to run hostname — it just looks nicer if you do.

fstab should contain at least:         /dev/ram0       /               ext2    defaults

/dev/fd0        /               ext2    defaults

/proc           /proc           proc    defaults

You can copy entries from your existing fstab, but you should not automatically mount any of your hard disk partitions; use the noauto keyword with them. Your hard disk may be damaged or dead when the bootdisk is used.

Your inittab should be changed so that its sysinit line runs rc or whatever basic boot script will be used. Also, if you want to ensure that users on serial ports cannot login, comment out all the entries for getty which include a ttys or ttyS device at the end of the line. Leave in the tty ports so that you can login at the console.

A minimal inittab file looks like this:         id:2:initdefault:

si::sysinit:/etc/rc

1:2345:respawn:/sbin/getty 9600 tty1

2:23:respawn:/sbin/getty 9600 tty2

The inittab file defines what the system will run in various states including startup, move to multi-user mode, etc. Check carefully the filenames mentioned in inittab; if init cannot find the program mentioned the bootdisk will hang, and you may not even get an error message.

Note that some programs cannot be moved elsewhere because other programs have hardcoded their locations. For example, on my system, /etc/shutdown has hardcoded in it /etc/reboot. If I move reboot to /bin/reboot, and then issue a shutdown command, it will fail because it cannot find the reboot file.

For the rest, just copy all the text files in your /etc directory, plus all the executables in your /etc directory that you cannot be sure you do not need. As a guide, consult the sample listing in Appendix C. Probably it will suffice to copy only those files, but systems differ a great deal, so you cannot be sure that the same set of files on your system is equivalent to the files in the list. The only sure method is to start with inittab and work out what is required.

Most systems now use an /etc/rc.d/ directory containing shell scripts for different run levels. The minimum is a single rc script, but it may be simpler just to copy inittab and the /etc/rc.d directory from your existing system, and prune the shell scripts in the rc.d directory to remove processing not relevent to a diskette system environment.

4.3.3. /bin and /sbin

The /bin directory is a convenient place for extra utilities you need to perform basic operations, utilities such as ls, mv, cat and dd. See Appendix C for an example list of files that go in a /bin and /sbin directories. It does not include any of the utilities required to restore from backup, such as cpio, tar and gzip. That is because I place these on a separate utility diskette, to save space on the boot/root diskette. Once the boot/root diskette is booted, it is copied to the ramdisk leaving the diskette drive free to mount another diskette, the utility diskette. I usually mount this as /usr.

Creation of a utility diskette is described below in Section 9.2. It is probably desirable to maintain a copy of the same version of backup utilities used to write the backups so you don't waste time trying to install versions that cannot read your backup tapes.

Be sure to include the following programs: init, getty or equivalent, login, mount, some shell capable of running your rc scripts, a link from sh to the shell.

4.3.4. /lib

In /lib you place necessary shared libraries and loaders. If the necessary libraries are not found in your /lib directory then the system will be unable to boot. If you're lucky you may see an error message telling you why.

Nearly every program requires at least the libc library, libc.so.N, where N is the current version number. Check your /lib directory. The file libc.so.N is usually a symlink to a filename with a complete version number:

% ls -l /lib/libc*

-rwxr-xr-x   1 root     root      4016683 Apr 16 18:48 libc-2.1.1.so*

lrwxrwxrwx   1 root     root           13 Apr 10 12:25 libc.so.6 -> libc-2.1.1.so*

In this case, you want libc-2.1.1.so. To find other libraries you should go through all the binaries you plan to include and check their dependencies with ldd. For example:         % ldd /sbin/mke2fs

libext2fs.so.2 => /lib/libext2fs.so.2 (0x40014000)

libcom_err.so.2 => /lib/libcom_err.so.2 (0x40026000)

libuuid.so.1 => /lib/libuuid.so.1 (0x40028000)

libc.so.6 => /lib/libc.so.6 (0x4002c000)

/lib/ld-Linux.so.2 => /lib/ld-Linux.so.2 (0x40000000)

Each file on the right-hand side is required. The file may be a symbolic link.

Note that some libraries are quite large and will not fit easily on your root filesystem. For example, the libc.so listed above is about 4 meg. You will probably need to strip libraries when copying them to your root filesystem. See Section 8 for instructions.

In /lib you must also include a loader for the libraries. The loader will be either ld.so (for A.OUT libraries, which are no longer common) or ld-Linux.so (for ELF libraries). Newer versions of ldd tell you exactly which loader is needed, as in the example above, but older versions may not. If you're unsure which you need, run the file command on the library. For example: % file /lib/libc.so.4.7.2 /lib/libc.so.5.4.33 /lib/libc-2.1.1.so

/lib/libc.so.4.7.2: Linux/i386 demand-paged executable (QMAGIC), stripped

/lib/libc.so.5.4.33: ELF 32-bit LSB shared object, Intel 80386, version 1, stripped

/lib/libc-2.1.1.so: ELF 32-bit LSB shared object, Intel 80386, version 1, not stripped

The QMAGIC indicates that 4.7.2 is for A.OUT libraries, and ELF indicates that 5.4.33 and 2.1.1 are for ELF.

Copy the specific loader(s) you need to the root filesystem you're building. Libraries and loaders should be checked carefully against the included binaries. If the kernel cannot load a necessary library, the kernel may hang with no error message.

linux下的文件系统,Linux根文件系统(“/”文件系统)下的目录介绍相关推荐

  1. linux文件系统启动流程,linux 内核启动过程以及挂载android 根文件系统的过程

    转载 作者:汕头大学-黄珠唐 时间:2009 年10 月29 日 主要介绍linux 内核启动过程以及挂载android 根文件系统的过程,以及介绍android 源代码中文件系统部分的浅析. 主要源 ...

  2. linux服务器查杀,Linux服务器PHP后门查杀

    shell脚本一句话查找PHP一句话木马 # find ./ -name "*.php" |xargs egrep "phpspy|c99sh|milw0rm|eval( ...

  3. linux 0.11根文件系统,linux内核与根文件系统之间的关联的理解

    学者 于 2011-10-19 12:46:08发表: 哦,原来还有一个initrd镜像,后缀名为".img",我一直以为只有一个内核镜像呢: 还有引导程序的路径表示与系统不同啊! ...

  4. linux ext3 大文件,Linux下Ext2与Ext3文件系统

    Linux下的Ext2文件系统,是 GNU/Linux 系统中标准的文件系统,其特点为存取文件的性能极好,对于中小型的文件更显示出优势,这主要得利于其簇快取层的优良设计. Ext3文件系统,它属于一种 ...

  5. linux jfs文件名长度,Linux环境下使用JFS文件系统

    JFS提供了基于日志的字节级文件系统,该文件系统是为面向事务的高性能系统而开发的.JFS 能够在几秒或几 分钟内就把文件系统恢复到一致状态.JFS能够保证数据在任何意外宕机的情况下,不会造成磁盘数据的 ...

  6. Linux之系统移植与根文件系统构建

    Linux之系统移植与根文件系统构建 1.Uboot 1. 什么是Uboot: 一个裸机程序 就是一个bootloader用于启动Linux或其他系统 最主要的工作就是初始化DDR.因为Linux是运 ...

  7. 十九.Linux开发之根文件系统移植——根文件系统的原理

    有道云笔记地址: 详情看这里链接,记录太多,就不一一排版了. http://note.youdao.com/noteshare?id=f9c7c1b589233d7b6ed661c3749f1ce8& ...

  8. Linux学习(2)——根文件系统详解

    Linux:ELF文件:可执行文件的存储格式.可执行的.可链接的文件类型. Windows上是:PE  可移植的. 文件系统: rootfs:根文件系统. FHS:文件系统层级标准 [root@ben ...

  9. linux文件系统实验原理,根文件系统原理

    1.1.根文件系统概述 1.为什么需要根文件系统 (1)init进程的应用程序在根文件系统上 (2)根文件系统提供了根目录/ (3)内核启动后的应用层配置(etc目录)在根文件系统上 (4)shell ...

  10. Linux之文件系统和根文件系统

    在学习Linux的过程中,会遇到"文件系统"和"根文件系统"两个概念,这两个概念容易混淆,总觉得为什么Linux需要这么多的文件系统,这两种系统的各自作用是什么 ...

最新文章

  1. OSS- OSS brower 登陆失败
  2. Linux.Netstat
  3. java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.init([Ljava
  4. 《移山之道》第十一章:两人合作 读书笔记 PB16110698 第六周(~4.15)
  5. 【剑指offer】面试题10- II:青蛙跳台阶问题(Java)
  6. Django有办法打开HTTP长轮询连接吗?
  7. Excel通过身份证获取出生年月,性别,年龄,生肖,星座,省份等信息总结归纳...
  8. 金九银十,年轻人跳槽时,尽量不要选择这三类得不偿失的公司
  9. 关于《PHP任务学习》的说明
  10. 2.Jenkins 权威指南 --- 配置Jenkins 服务器
  11. jupyter notebook 快捷键
  12. el-descriptions引入代码中label不生效问题
  13. mysql 创建表指定时区_mysql解决时区相关问题
  14. JavaScript:在一个JS文件中引入另外的一个JS文件
  15. JAVA实验二:设计一个教师类Teacher(属于cn.net.sdkd包)实现接口进行排序等
  16. opencv学习记录——(5)图像像素的操作
  17. 移动APP导航栏设计对比
  18. Automatic Inference of Search Patterns for Taint-Style Vulnerabilities
  19. chrome控制台中console
  20. Python小白到老司机,快跟我上车!基础篇(二十)

热门文章

  1. 计算机二级循环队列知识点,考点!计算机二级考试公共基础知识冲刺复习笔记:栈、队列和循环队列...
  2. excel 区间人数柱状图_Excel中,区间统计的3种技巧都不掌握,那就真的OUt了!
  3. sambd ERROR: job for smbd.service failed
  4. LDAP命令介绍---dsreplication--initialize
  5. oracle控制文件
  6. linux一键安装node+npm
  7. Problem H: 今年第几天?
  8. Super-palindrome【字符串+思维】
  9. Centos7: 配置IO调度
  10. 在C#中创建DataTable