1825771 Members
2360 Online
109687 Solutions
New Discussion

Duplicate system files

 
SOLVED
Go to solution
Krishnan Viswanathan
Frequent Advisor

Duplicate system files

I am seeing lot of duplicate files on most of my systems.

For eg.. there are two versions of lvchange.

# ls -l /sbin/lvchange
-r-sr-xr-x 31 root sys 835584 Sep 12 17:26 /sbin/lvchange
# ls -l /usr/sbin/lvchange
-r-sr-xr-x 31 root sys 557056 Sep 12 17:26 /usr/sbin/lvchange


There are many more such files.. Why does HPUX provide two such versions for many system files?

Thanks
Krishnan
3 REPLIES 3
Scott Van Kalken
Esteemed Contributor

Re: Duplicate system files

I think from memory that one is dynamically linked and the other is not.

What this means essentially is that one is a "stand alone" the other needs libraries to work.

Scott.
S.K. Chan
Honored Contributor
Solution

Re: Duplicate system files

From Technical DB

Files in /sbin are statically linked so that they won't need shared libraries to run. This is so that the commands will work when the system is in single-user mode, when other file systems like /usr are not mounted. If there is no /usr, there is no /usr/lib (where shared libraries live) and no /usr/sbin (where many system-administration commands live). Files in /sbin are often not NLS-smart either, meaning they speak only the default language
(C for computer). By the way, the problem of "no shared libraries in single-user mode" is the reason why the shell for the super-user needs to be /sbin/sh, not/usr/bin/sh. When the system is running in multi-user state, /usr (with /usr/lib and /usr/sbin) is mounted and its files are available. Also, the super-user's $PATH is set to use /usr/sbin, which is defined by the SVR4 (V.4) file system conventions and on the hier(5) manual page as being the location for system administration commands. What to do with programs that are useful in single-user mode (/sbin) and in multi-user mode (/usr/sbin)?
* One way would be to install duplicate copies of a binary in both /sbin and /usr/sbin, but that would waste too much disk space.
* Another way to solve the problem is to symlink the required file from /sbin to /usr/sbin. This second choice is the approach taken by the `mount' command, as an example:

# ll /usr/sbin/mount
lrwxr-xr-x 1 root sys 11 Jan 5 14:48 /usr/sbin/mount -> /sbin/mount

When the super-user types `mount', his shell runs /usr/sbin/mount because that directory is first in his $PATH. The file system de references the symlink to run the /sbin/mount command.
* Another way to solve the problem is to ship two versions of the binaries. LVM takes this approach:

# ll /sbin/vgcfgrestore /usr/sbin/vgcfgrestore
-r-sr-xr-x 24 root sys 528384 Dec 6 00:00 /sbin/vgcfgrestore
-r-sr-xr-x 24 root sys 327680 Dec 6 00:00 /usr/sbin/vgcfgrestore

Unlike the LVM commands in /sbin, the LVM commands in /usr/sbin use shared libraries. This is more efficient for the system at runtime. The LVM commands in /sbin save further space in the / logical volume by not being internationalized. They save even more disk space because each individual LVM command is a hard link to one single LVM command binary. The disk usage for LVM commands went from 3 Mb (= 3000 Kb) to 300 Kb using this method. Other HP subsystems like the optional HP product SoftBench use this same method to conserve disk space. /sbin has links in it, too, both hard and symbolic, but their targets are other files in /sbin.
James R. Ferguson
Acclaimed Contributor

Re: Duplicate system files

Hi:

Scott is correct. The versions in /sbin are linked staticly. Those in /usr are dynamically linked. To see this, do:

# chatr /usr/sbin/lvchange
# chatr /sbin/lvchange

Regards!

...JRF...