(2012-07-20 10:59:26)
Reproduced
Original from http://forum.ubuntu.org.cn/viewtopic.php?f=120&t=257333
The system organization of Linux is--the whole system from the root, according to the tree-shaped directory downward gradually expand, classify and store different uses of the file,/read as a "slash", English slash; When writing a path,first one/represents the root, which isRoot, the other/represents the path separator, but is read as "Slash" or "slash".
When the system starts, a partition is mounted to the/, which can be understood as the partition is assigned/This strange "drive letter" (Note that in Windows, this symbol is used as the command parameter guide symbol, and the backslash \, English backslash as the path separator, the habit is different only, Just like the British driving on the left, there is nothing strange about it.
This mounted partition, called the root partition (whether it is a primary partition or a logical partition), has a special place in the Stacks Linux system since all the hard drives on the stacks computer, including all the other partitions on it, will have this "Root partition"as the backbone, start constructingLinuxtree, and eventually become a branch or leaf on the tree. WholeLinuxsystem structure, there is only oneRoot(root partition), it is impossible to have a second (in fact, any one partition can be mounted as/,windows partition can also.) The purpose of mounting the root partition is to start the system, and if/below it does not have the Linux kernel and the required system files, it will not boot the system. So this root partition is not mysterious).
Your other partitions can only be attached to a directory under the/(root partition), such as "/mnt" or "/media" or "/what" directories, to see what you like. After mounting, when you read and write data to this directory, you are actually reading and writing data to another partition that is mounted to the directory.multiple partitions can only be mounted to multiple different directories at the same time, such as "/mnt/a", "/media/123" or "/home/anywhere", any one in/under the directory can be used as a "platform" to mount other partitions, of course, the system needs to use the directory of HA, you create your own use it.
After mounting, the data in your hard drive can be found in a way similar to/path/to/anywhere, and if it is not mounted, you cannot find it.
In a vulgar analogy, "/" is equivalent to C: \, while the "/etc,/bin,/sbin,/lib" directories are probably equivalent to C:\Windows and C. \program Files, and "/home" equals c:\Documents and Settings, and when you mount the second partition to "/mnt/partition2", this directory is the equivalent of d:\, you understand?
If you don't believe, just hang up and try it:
Code :
CD/MNT (Switch to/mnt directory)
sudo mkdir partition2 (Create a new empty directory named Partition2, you can use any other name)
sudo mount/dev/sda5 partition2 (if you have only one hard disk and the second partition is a logical partition, this command will mount the partition to Partition2)
CD partition2 (switch to/mnt/partition2 directory)
LS (listing files for this directory)
This should allow you to see the files under your D-disk.
Now that you can mount it, you will be able to counter-mount it:
Code :
Sudoumount/dev/sda5 (or/mnt/partition2)
This command will "unload" the partition, and now you will see that Partition2 is empty directory again.
Here, someone might say, "Linux is too much trouble, I have more than 10 partitions, do I have to knock dozens of lines at a time?" Why don't you just hook me up when you start up like Windows? ”
1. I said to knock orders, but I didn't say "every time"! The fstab file that will be introduced below will let you solve the problem once and for all in this matter; in fact, there is even a "0" peace method, you even a command do not have to knock, a few mouse click on it;
2. Automatically hangs like Windows? No problem, install one or two software, but I want to remind you:
Is this really good? Not necessarily. I am sure that you will only use a few specific partitions most of the time, and then take a step back, even if you are the exception, but you should also think for others? For example, I have a partition with "sensitive" data (what you guess), and not commonly used, before using Windows, I am very annoying to this practice, anyone can look at casually, not good! Later all moved to the Linux partition, usually do not mount, to use only hang on, ha ha, my system I am the master! Since then no longer suffer from the pain of Microsoft ~ ~ ~
"Like windows," Why are you thinking like that all the time in your head? Is it because Windows has the most "good" method? Not necessarily, at best, you are accustomed to "that" only. Imagine if you've ever used Linux for "this" and then one day when I suddenly gave you a Windows computer, you'd be wondering, "Where's My home directory?" "Why can't you do it like Linux?" ”。
Admit it, the so-called "best" "that" is not, in addition to your the old signs of thinking, nowhere! Hurry up and move on.
An example ______________________________________________________________
/(This is the famous root)
├──bin (most programs you run at the terminal, such as CP, MV ...)
├──boot (the kernel is placed here, this directory is also often used as a mount point for a separate partition)
│└──grub (The Grub bootloader and boot menu are placed here)
├──cdrom
├──dev (storage device file, here is equivalent to a Device Manager, automatically generated by the system.) Vary greatly depending on the hardware environment)
│├──block
│├──bsg
│├──bus
│├──char
│├──disk (disk information, to mount the hard disk partition will pay attention to the information here)
││├──by-id (permanent symbolic link for hard disk partitions)
││├──by-label (identifies other hard disk partitions by volume, often used for mounting)
││├──by-path (node link for hard disk partitioning)
││└──by-uuid (hard drive partition identified by UUID, often used for mounting)
│├──dri
│├──fd
│├──input
│├──net
│├──pts
│├──shm
│└──snd
├──ETC (Storage of all program and system configuration files and global variables, effective for all users, well worth backup)
├──home (This is the famous home directory, note is not "home directory", it is highly recommended to put a separate partition to mount here!) )
│├──adagio (This is my real home!) In general, the directory name is the account name, of course, it can not, casually. Wavy lines in command line ~ represent here)
│├──mnt (This is where I mount other hard drive partitions, you can see directory names that are differentiated by the hard drive brand, capacity, or purpose)
││├──max40nt1 (Maxtor 40G)
││├──st160nt1 (Seagate 160G First Partition, below two similar)
││├──st160nt2
││├──st160sys
││├──st320g (Seagate 320G)
│││├──movie
│││├──music
│││└──P2P (electric donkey, BT buffer zone)
││├──st80g (Seagate 80G)
│││├──program
│││├──st80pe
│││└──year
││└──wd1000 (West number 1T)
││├──wd2
││├──wd3
││├──wd5
││├──wd6. Lib
││└──wd7
│└──test (the home directory of another account I created, dedicated to testing, once you get to the point where you can't clean up, simply
│ Delete all the files inside, you can restore the default. You can actually have an unlimited number of accounts)
├──lib (library files shared by all programs)
├──lost+found (missing data from disk scan)
├──media (the partition that you automatically mount when you click in the File Manager is here, named after the volume, no volume is named by size)
├──mnt (also used to mount the disk, which is the most traditional location, like hanging where casually)
├──opt (some special programs like to put data here, like Java)
├──proc (all the details of the current system, the "file" here does not exist in the hard disk, but in memory or cache, each boot is not the same)
├──root (This is the home of the system's highest authority root user!) He is the boss, so he does not live in/home, where the Grass people live)
├──sbin (similar to/bin, store common programs, but the program here is very deadly Ah, such as formatting, so only the root user or sudo program is authorized to use)
├──srv (Files to be accessed by some services)
├──sys (System core file, similar to/proc, do not care about it)
├──tmp (store temporary files, all users can use, but you have to be careful, all of the files here once restarted is completely gone, automatically emptied)
├──USR (all the program data you used under X are here, including icons, manual, etc.). Available to all users. Also the largest catalogue)
└──var (Variation, as the name implies, is a variable, which stores the frequently changing data in the system. Different from/tmp, very useful place)
├──backups
├──cache
│└──apt
│└──archives (the Deb pack that holds all the programs you install!) Re-install the system is too useful, be sure to back up well, then put back.
│ I recommend stacks/var to be mounted separately to a separate partition, like/home. After you re-install the system, only
│ need to simply mount the stacks partition to/var on the line, eliminating the backup-restore time. You know, these Deb packs
│ is not dozens of M, but it is possible hundreds of M, a few g, one can be very tough. You can also mount it separately
│ partitions to/var/cache/apt/archives, no other.
│ Of course, this adds a little more complexity to the system structure, like how to please yourself. )
├──crash
├──games
├──lib
├──local
├──lock
├──log (hehe, the file here is the complete record of the system operation, out of the problem must come here to see)
├──mail (this is where all user email is stored)
├──opt
├──run
├──spool
└──tmp
OK, now let's be specific, use my Ubuntu startup process to do an example to see how Linux has gradually planted this tree.
First of all, you need to know what the UUID is, or at least understand what the number of HDA and SDC mean. Otherwise it must have been're same page.
grub________________________________________________
System boot of course is starting from grub, please open your /boot/grub/grub.cfg file, find similar to the following paragraph (the following GRUB2 menu as a sample, grub0.97 Menu.lst is actually similar).
Code :
Menuentry "Ubuntu 9.10, kernel 2.6.31-17-generic" {
Search--no-floppy--fs-uuid--set f1bafdd4-73c2-44b2-9a62-d50a2da4d019
linux/boot/vmlinuz-2.6.31-17-genericroot=uuid=f1bafdd4-73c2-44b2-9a62-d50a2da4d019 RO Splash
Initrd/boot/initrd.img-2.6.31-17-generic
}
It could be like this.
Code :
Menuentry "Ubuntu 9.10, kernel 2.6.31-17-generic" {
Set root= (hd2,6)
Linux/boot/vmlinuz-2.6.31-17-generic ROOT=/DEV/SDC5 RO Splash
Initrd/boot/initrd.img-2.6.31-17-generic
}
This is a standard Ubuntu boot menu, menuentry that line only shows the name of the item (including all the statements that are enclosed in curly braces), without having to worry about it;
The second line to start, just really into the Linux system boot process, search as the name implies is to find, what? Find the kernel.
Open your/boot directory to see if there is a file named Vmlinuz-xxxxx, usually within 10M size, which is known as the Linux kernel.
With the kernel, you have half a Linux operating system, you can start booting the system.
Linux/boot/vmlinuz-2.6.31-17-generic This part of the third line, Linux is an instruction that tells the GRUB program: "Please use this kernel given later", hence the name "/boot/vmlinuz-2.6.31-17- Generic "kernel will be loaded into memory and read" root=uuid=f1bafdd4-73c2-44b2-9a62-d50a2da4d019 (SDC5) "Some of the necessary files for this partition.
The third line means: Use a file named "/boot/initrd.img-2.6.31-17-generic" first in memory to construct a "virtual" root file system, so that the kernel after the detection of hardware information to load the necessary modules and so on, in fact, this INITRD can also be thought of as part of the kernel, just to keep the vmlinuz clean and separate, and some kernels do not even need this.
OK,Grubto this end, the following will be done byLinuxKernel this"Half"the system takes over control of the computer and begins the initialization phase.
Note that you have not started to mount the root partition so far, so you can see that the partition root=xxxxxxxx (SDC5) is read-only (RO) mounted.
If you remove the "quiet" parameter in the third row, you can see the output of the whole process in the kernel initialization on the screen, of course, the screen scrolling will be very fast, and a lot of content, mainly in the detection of hardware environment, loading the corresponding modules, start-up services and so on .... Well, it's not an easy thing to start a computer, is it?
Fortunately, you just need to worry about one thing at the moment-mount. Notice the line of characters that will appear at approximately the middle stage--mounting Locale Filesystem
If your Linux has just been installed, because there are not many mounts, it may be a flash. And if you need to mount a lot of partitions, especially if the pass parameter is 1 or 2, you can see the list of the Mount situation.
fstab_____________________________________________
YEAH! The real partition mount starts here.
At this time, Linux will read a file named Fstab, and follow the instructions in line execution, until the completion of all the content, enter the system quickly open to see it, he is located in/etc/fstab. The following is my (do not think I said "directive" afraid of fear, in fact, the content is very simple, the earth can read).
Code :
#/etc/fstab:static file System Information.
#
# use ' Blkid-o value-s UUID ' to print the universally unique identifier
# for a device; This is used with uuid= as a more robust-to name
# devices that works even if disks is added and removed. See Fstab (5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
PROC/PROC proc Defaults 0 0
#/was ON/DEV/SDA5 during installation
UUID=CE8493A2-73A2-46D3-AC32-FE28AC9EC860/EXT4 Errors=remount-ro 0 0
#/Home was ON/DEV/SDA6 during installation
Uuid=5ae0aea4-f7bb-4504-bf0c-f3dbffc8fa0f/home EXT4 Defaults 0 0
# Swap was ON/DEV/SDA7 during installation
Uuid=db44da00-1b52-4d25-a870-57d36a6a2a85 None swap SW 0 0
Or it could have been written like this.
Code :
#/etc/fstab:static file System Information.
#
# use ' Blkid-o value-s UUID ' to print the universally unique identifier
# for a device; This is used with uuid= as a more robust-to name
# devices that works even if disks is added and removed. See Fstab (5).
#
# <file system> <mount point> <type> <options> <dump> <pass>
PROC/PROC proc Defaults 0 0
#/was ON/DEV/SDA5 during installation
/DEV/SDC6/EXT4 Errors=remount-ro 0 0
#/Home was ON/DEV/SDA6 during installation
/dev/sdc5/home EXT4 Defaults 0 0
# Swap was ON/DEV/SDA7 during installation
/DEV/SDC4 None swap SW 0 0
1. Ignore all lines starting with #, which is a comment, to show to yourself that Linux will not execute it, just as a complete command of a line, it will be completely ignored.
2. Keep in mind that each line is a complete command and cannot have line breaks. or the line break (carriage return) is equivalent to the period in the article.
3. Each space or tab symbol in each line is a parameter split symbol that acts as a comma in the article. Multiple connected spaces or tabs will be treated as one.
4. Linux mount partitions will be executed from top to bottom, sequentially
The first line that works (line 8th) is proc,1 has been explained, we don't care about it;
The second working row (line 10th) is/dev/sdc6 there, which is the first root partition that Linux is mounted on;
Again down (line 12th) will continue to mount the SDC5 to/home, that is, sdc5 this original relationship equal to the partition, now feel the sdc6 of a subordinate directory;
Finally (line 14th) will "mount" the swap partition, the reason is quoted, because the swap partition is a bit special, because he is not "attached" to/, but independent use, at least you can not find it from the root directory (so the mount point is not written/swap), in short, it was "occupied" by the system , you cannot read or write any data directly in this partition.
So far, a truly "usable" Linux system has been created and can be delivered to you using.
About Linux Mount--mount (i)