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.pswp.cn/news/541332.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541332.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541332.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

greenlet 詳解

greenlet初體驗回到頂部Greenlet是python的一個C擴展,來源于Stackless python,旨在提供可自行調度的‘微線程’, 即協程。generator實現的協程在yield value時只能將value返回給調用者(caller)。 而在greenlet中,target.switch&am…

Java Calendar toString()方法與示例

日歷類toString()方法 (Calendar Class toString() method) toString() method is available in java.util package. toString()方法在java.util包中可用。 toString() method is used to string denotations of the calendar object. toString()方法用于對日歷對象的符號進行字…

linux虛擬機怎么看var文件,一種獲取Linux虛擬機內部日志的方法

一種獲取Linux虛擬機內部日志的方法【技術領域】[0001]本發明涉及云計算管理技術領域,特別是指一種獲取Linux虛擬機內部日志的方法。【背景技術】[0002]在云計算環境下,虛擬機被廣泛使用,對于虛擬機的維護要求越來越高,當虛擬機出…

詳細圖解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我…

java calendar_Java Calendar complete()方法與示例

java calendarCalendar類的complete()方法 (Calendar Class complete() method) complete() method is available in java.util package. complete()方法在java.util包中可用。 complete() method is used to fills in any non-set fields in the calendar fields. complete()方…

LXD 2.0 系列(十二):調試,及給 LXD 做貢獻

介紹 終于要結束了!這個大約一年前開始的這系列文章的最后一篇博文。 LXD 入門安裝與配置你的第一個 LXD 容器資源控制鏡像管理遠程主機及容器遷移LXD 中的 DockerLXD 中的 LXD實時遷移LXD 和 JujuLXD 和 OpenStack調試,及給 LXD 做貢獻如果你從一開始就…

linux用ping命令測試網速,linux下面使用命令測試網速

大家都知道在speedtest是市面上最準確最全面的測速工具,但在linux命令行不能直接使用,所以我們就借助腳本調用speedtest的接口來利用他測試網速。1.下載speedtest-cli腳本:下載地址:https://raw.githubusercontent.com/sivel/spee…

Java ArrayList isEmpty()方法與示例

ArrayList類isEmpty()方法 (ArrayList Class isEmpty() method) isEmpty() method is available in java.util package. isEmpty()方法在java.util包中可用。 isEmpty() method is used to check whether this Arraylist is "empty" or "not empty". isEmp…

linux家用系統版本,查看linux系統版本

篇一:linux下如何查看系統和內核版本linux下如何查看系統和內核版本 1. 查看內核版本命令:1) [rootq1test01 ~]# cat /proc/versionLinux version 2.6.9-22.ELsmp (bhcompilecrowe.devel.redhat.com) (gcc version 3.4.4 20050721 (Red Hat 3.4.4-2)) #1…

python中locked_Python鎖類| 帶示例的locked()方法

python中lockedPython Lock.locked()方法 (Python Lock.locked() Method) locked() is an inbuilt method of the Lock class of the threading module in Python. Locked()是Python中線程模塊的Lock類的內置方法。 This method returns True if the lock is acquired by a th…

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…

vs生成linux服務器程序,從Visual Studio到Linux上調試C++代碼

從Visual Studio到Linux上調試C代碼04/30/20155 分鐘可看完本文內容[原文發表時間] 2015/4/29 10:00 PM正如您可能已經聽說的那樣,Visual Studio 2015新推出了對Android開發的GDB支持。有趣的是,因為這項功能依賴GDB調試,我們完全可能稍加改動…

java clock計時_Java Clock類| 實例的Instant()方法

java clock計時Clock Class Instant()方法 (Clock Class instant() method) instant() method is available in java.time package. Instant()方法在java.time包中可用。 instant() method is used to get the current instant that is used with this Clock. Instant()方法用于…

使用國內DOCKER鏡像源

在國內,通過Docker的pull和push命令訪問hub.docker時,網絡十分慢,而且會出現各種各樣的網絡連接問題。因此這里介紹下如何使用國內的鏡像源,這里以DaoCloud為例。注冊DaoCloud用戶;注冊完成后,會進入dashboard頁面&…

linux命令top查看進程,linux 查看進程的命令(top)

標簽:top操作系統支持多任務并不是計算機同時做很多事情,而是快速的輪換著執行這些任務。linux安排不同的程序等待使用CPU。進程的工作方式:當系統啟動的時候,內核先把自己的程序初始化為進程,然后運行一個init的程序&…

stl vector 函數_vector :: back()函數以及C ++ STL中的示例

stl vector 函數C vector :: back()函數 (C vector::back() function) vector::back() is a library function of "vector" header, it is used to access the last element from the vector, it returns a reference to the last element of the vector. vector ::…

linux udp 端口 抓包,tcpdump之UDP抓包

摘要使用tcpdump抓UDP包,過濾過濾IP和port,并且自動拆分片段。安裝tcpdumpyum install -y tcpdump使用方法tcpdump -i bond0 udp port xxxx and host xxx.x.xx.xxx -s0 -G 600 -w %Y_%m%d_%H%M_%S.pcap參數說明-i 指定監聽的網卡udp 監聽UDP協議port 指定…

Vue版本過渡變化

到了2.0以后&#xff0c;有哪些變化&#xff1a; 在每個組件模板&#xff0c;不在支持片段代碼之前: <template id”aaa”><h3>我是組件</h3><strong>我是加粗標簽</strong></template> 現在: 必須有根元素&#xff0c;包裹住所有的代碼 …

NABARD的完整形式是什么?

NABARD&#xff1a;國家農業和農村發展銀行 (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)

引自&#xff1a;http://blog.csdn.net/wangxing233/article/details/51549880 零、前言 前段時間看到文章【1】和【2】&#xff0c;大概了解了面部合成的基本原理。這兩天空下來了&#xff0c;于是參考【3】自己實現了下。雖然【1】和【2】已經講的很清楚了&#xff0c;但是有…