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

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.0b1331709591d260c1c78e86d0c51c18.png

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541332.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

greenlet 详解

greenlet初体验回到顶部Greenlet是python的一个C扩展,来源于Stackless python,旨在提供可自行调度的‘微线程’, 即协程。generator实现的协程在yield value时只能将value返回给调用者(caller)。 而在greenlet中,target.switch&am…

详细图解mongodb 3.4.1 win7x64安装

原文:http://www.cnblogs.com/yucongblog/p/6895983.html 详细图解,记录 win7 64 安装mongo数据库的过程。安装的版本是 MongoDB-win32-x86_64-2008plus-ssl-3.4.1-signed。 我下载的源文件:mongodb-win32-x86_64-2008plus-ssl-3.4.1-signed我…

linux用ping命令测试网速,linux下面使用命令测试网速

大家都知道在speedtest是市面上最准确最全面的测速工具,但在linux命令行不能直接使用,所以我们就借助脚本调用speedtest的接口来利用他测试网速。1.下载speedtest-cli脚本:下载地址:https://raw.githubusercontent.com/sivel/spee…

rocksdb ubuntu c++源码编译测试

2019独角兽企业重金招聘Python工程师标准>>> 环境: ubuntu16.4 需要安装 snappy gflage bz2 zstd 以及g 其中zstd是facebook开放源代码里的压缩的库 git clone https://github.com/facebook/rocksdb.git cd rocksdb make static_lib 成功生成 librocksd…

NABARD的完整形式是什么?

NABARD:国家农业和农村发展银行 (NABARD: National Bank for Agriculture and Rural Development) NABARD is an abbreviation of National Bank for Agriculture and Rural Development. NABARD是国家农业和农村发展银行的缩写 。 On 12 July 1982, it was establ…

基于opencv+Dlib的面部合成(Face Morph)

引自:http://blog.csdn.net/wangxing233/article/details/51549880 零、前言 前段时间看到文章【1】和【2】,大概了解了面部合成的基本原理。这两天空下来了,于是参考【3】自己实现了下。虽然【1】和【2】已经讲的很清楚了,但是有…

大脑应对危机的模式_危机的完整形式是什么?

大脑应对危机的模式危机:印度信用评级信息服务有限公司 (CRISIL: Credit Rating Information Services of India Limited) CRISIL is an abbreviation of Credit Rating Information Services of India Limited. It is an international analytic company which off…

linux网络延迟命令,2. Linux使用ping命令查看网络延迟

ping命令持续发送少量互联网流量到远程地址并报告收到回应的总时间。如果流量因为网络故障或者错误配置而被丢弃,它也会报告。ping命令是最基本和初级的诊断网络问题的工具之一。ping常被用来测试网络延迟,但是有时ping的延迟并不是网络引起的&#xff0…

linux查看磁盘io带宽,[Linux] 磁盘IO性能查看和优化以及iostat命令

iostat命令:%user:CPU处在用户模式下的时间百分比。%nice:CPU处在带NICE值的用户模式下的时间百分比。%system:CPU处在系统模式下的时间百分比。%iowait:CPU等待输入输出完成时间的百分比。%steal:管理程序维护另一个虚…

Jsoup 数据修改

2019独角兽企业重金招聘Python工程师标准>>> 1 设置属性的值 在解析一个Document之后可能想修改其中的某些属性值,然后再保存到磁盘或都输出到前台页面。 可以使用属性设置方法 Element.attr(String key, String value), 和 Elements.attr(String key, S…

软件静态架构 软件组件图_组件图| 软件工程

软件静态架构 软件组件图什么是组件图? (What is Component Diagram?) A Component Diagram breaks down the real system under development into different heights of working. Every component is reactive for the main aim in the entire system and only re…

如何卸载非linux系统分区,如何卸载Linux系统分区?卸载Linux系统分区的方法-站长资讯中心...

系统为windows xp sp2和redhat as 5双系统,其中linux系统后安装的在D盘,华彩软件站www.huacolor.com小编今天发现硬盘不够用了,想干掉linux分区,在虚拟机中用linux。就在windows的磁盘管理(命令为:diskmgmt)下删除linux分区&#…

顺序结构复习

复习一些易错知识点还有习题 目录 可能不熟悉的知识点 逻辑表达式的求解 if,else的配队 条件运算符 运算符优先级的问题 switch的使用 goto和if构成的循环 例题讲解 1 2 3 4 ​编辑 5 ​编辑 6赋值 ​编辑 7 可能不熟悉的知识点 逻辑表达式的求解 如果…

模板模式(部分方法延迟到子类实现)

项目中,用到了抽象类作为父类,有部分实现。 提供了了模板方法作为子类公共方法,模板方法中调用了抽象类的抽象方法和部分非抽象方法。 执行代码时,发现模板方法调用了抽象类的抽象方法,当时比较好奇,后来发…

【转载】浏览器缓存详解:expires cache-control last-modified

下面的内容展示了一个常见的 Response Headers,这些 Headers 要求客户端最多缓存 3600 秒,也给出了一个 pub1259380237;gz 的校验值。 HTTP/1.x 200 OK Transfer-Encoding: chunked Date: Sat, 28 Nov 2009 04:36:25 GMT Server: LiteSpeed Connection: …

linux下php的安装,Linux下PHP安装

1 下载php源码安装包 个人是php-5.6.30.tar.gzphp2 解压文件mysqltar -zxvf php-5.6.30.tar.gznginx3 编译安装sqlcd php-5.6.30api建立www用户和www用户组curlgroupadd wwwsocketuseradd -g www wwwphp-fpm在编译以前先把依赖包都装上urlyum install curl curl-develyum inst…

微软宣布以 262 亿美元现金收购 LinkedIn

北京时间6月13日20:45(美国当地时间6月13日上午8:45),微软(Nasdaq: MSFT)和LinkedIn(领英,NYSE: LNKD)对外宣布,双方达成协议,微软宣布将以每股196美元、总价262亿美元的价格收购LinkedIn,由现金…

本月初 本月末 java_本月内容作家(2018年8月)

本月初 本月末 javaWe are feeling glad to announce that Prerana Jain is the Content Writer Of The Month (August 2018) on the basis of her excellent contribution and her support to us. 我们很高兴地宣布, Prera​​na Jain凭借其出色的贡献和对我们的支…

c语言案例朗读工具源码,C语言编写简单朗读小工具(有源码)

原标题:C语言编写简单朗读小工具(有源码)最近不少人在后台留言说学C都是面对枯燥的控制台程序,能不能体现一下C语言的实际用途,今天我们就理论结合实践一把:C语言结合VBS脚本编写一个简单的朗读小工具,做一个能够发音的…

WAS集群系列(5):集群搭建:步骤3:安装IHS软件

选择“安装IBM HTTPServer”选项,点击“安装向导”。例如以下图提示: 安装提示,逐步点击“下一步”,当中偶有几处细节注意就可以。列举例如以下: (1)、产品安装路径与先前WAS软件所安装路径统一…