November 30, 2010 David Collier wrote:I noticed that in busybox, the links are laid out in these four directories.
Is there any simple rule to determine in which directory which of the links should be located ...
For example, kill is in / bin, and killall is in / usr / bin ... I don’t see any logic in this separation.
You probably know that Ken Thompson and Dennis Ritchie created Unix on the PDP-7 in 1969th. So, around 1971, they upgraded to a PDP-11 with a pair of RK05 disks (1.5 megabytes each).
When the operating system expanded and ceased to fit on the first disk (on which the root file system was located), they moved the part to the second, where the home directories were located (therefore, the mount point was called / usr - from the word user). They duplicated all the necessary OS directories there (/ bin, / sbin, / lib, / tmp ...) and put the files on the new disk, because the old one ran out of space. Then they got the third disk, they mounted it in the / home directory and transferred the user's home directories there so that the OS could take all the remaining space on the two disks, which were
three megabytes (ogogo!).
Of course, they had to enter the rule that “when the operating system boots, it must be able to mount the second disk in the / usr directory, so you don’t need to put a program like mount on the second disk in / usr, otherwise we’ll get the chicken and egg problem”. Just like that. And this applied to Unix V6 35 years ago.
')
The separation of / bin and / usr / bin (and all similar directories) is a consequence of those events, the implementation detail from the 70s, which has been copied by bureaucrats for decades. They never asked the question
why , they just did it. This separation has ceased to make sense even before Linux was created, for several reasons:
- When downloading, use the initrd or initramfs, which takes on problems such as "we need this file earlier than the one." Thus, we already have a temporary file system that is used to load everything else.
- Shared libraries (which were added to Unix by Berkley guys) do not allow you to independently change the contents of / lib and / usr / lib. These two parts must match each other, otherwise they will not work. This did not happen in 1974, because then they had some independence due to static linking.
- Cheap hard drives broke the 100-megabyte barrier around 1990 and programs for resizing partitions appeared at about the same time (partition magic 3.0 was released in 1997).
Of course, since there is a separation, some people have come up with rules that justify it. Type, the root partition is needed for all sorts of general OS stuff, and in / usr you need to put your local files. Or to / place what AT & T distributes, and to / usr - that your distribution kit, IBM AIX, or Dec Ultrix, or SGI Irix added, and the files specific to your system to / usr / local. And then someone decided that / usr / local is not the right place to install new software there, so let's add / opt! Do not be surprised if there is also / opt / local ...
Of course, for 30 years, due to such a separation, all sorts of interesting rules specific to individual distributions appeared and disappeared. For example, "/ tmp is cleared on reboot, and / usr / tmp is not." (And in Ubuntu / usr / tmp is not in principle, but in Gentoo / usr / tmp is a symbolic link to / var / tmp, which is now covered by that rule, and it is not cleared when rebooting. Yes, that was all before tmpfs. It also happens that the root file system is available only for reading, and then you also don’t have to write anything to / usr, but you should write to / var. Or you can’t write
mostly in / etc, except that sometimes tried to transfer to / var ...)
Bureaucrats like the Linux Foundation (who absorbed the Free Standards Group during the expansion years ago) happily document and complicate these rules without even trying to figure out why they appeared. They do not realize that Ken and Dennis simply transferred part of the OS to their home directory, due to the fact that the RK05 drive on the PDP-11 was too small.
I’m pretty sure that it simply puts files in busybox just as it has historically been. There is no real reason to do so until now. Personally, I just make / bin, / sbin, and / lib links to similar directories in / usr. After all, people who work with embedded software, try to understand and simplify ...