Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Why busybox sysctl and not /usr/sbin/sysctl?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
Fog_Watch
Apprentice
Apprentice


Joined: 24 Jul 2006
Posts: 217
Location: Utility Muffin Research Kitchen

PostPosted: Thu Mar 26, 2020 9:57 pm    Post subject: Why busybox sysctl and not /usr/sbin/sysctl? Reply with quote

Hello,
My rc.log from booting includes:
Quote:
* Configuring kernel parameters ...
sysctl: unrecognized option '--system'
BusyBox v1.31.1 (2020-03-24 14:37:21 AEDT) multi-call binary.

Usage: sysctl -p [-enq] [FILE...] / [-enqaw] [KEY[=VALUE]]...

Show/set kernel parameters

-pSet values from FILEs (default /etc/sysctl.conf)
-eDon't warn about unknown keys
-nDon't show key names
-q Quiet
-aShow all values
-wSet values

Why is openrc choosing busybox sysctl and not /usr/sbin/sysctl?

emerge --info
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 14922

PostPosted: Fri Mar 27, 2020 1:15 am    Post subject: Reply with quote

What is the value of $PATH for openrc? What is the output of emerge --pretend --verbose sys-apps/busybox? If you are using a savedconfig for busybox, please pastebin it. What is the output of ls -l /bin/sysctl /usr/bin/sysctl /sbin/sysctl /usr/sbin/sysctl?

Why did you use quote tags instead of code tags?
Back to top
View user's profile Send private message
Fog_Watch
Apprentice
Apprentice


Joined: 24 Jul 2006
Posts: 217
Location: Utility Muffin Research Kitchen

PostPosted: Fri Mar 27, 2020 2:00 am    Post subject: Reply with quote

Hu wrote:
What is the value of $PATH for openrc?

Indeed. How do I find out?
(Just in case:
Code:
# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/9/bin
)
Hu wrote:
What is the output of emerge --pretend --verbose sys-apps/busybox? If you are using a savedconfig for busybox, please pastebin it.

The following seems fairly boring:
Code:
# emerge --pretend --verbose sys-apps/busybox

Performing Global Updates
(Could take a couple of minutes if you have a lot of binary packages.)
  .='update pass'  *='binary update'  #='/var/db update'  @='/var/db move'
  s='/var/db SLOT move'  %='binary move'  S='binary SLOT move'
  p='update /etc/portage/package.*'
/mnt/auto/portage/profiles/updates/1Q-2020.............



These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] sys-apps/busybox-1.31.1-r2::gentoo  USE="static -debug -ipv6 -livecd -make-symlinks -math -mdev -pam -savedconfig (-selinux) -sep-usr -syslog -systemd" 0 KiB

Total: 1 package (1 reinstall), Size of downloads: 0 KiB

 * IMPORTANT: 9 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items.


Hu wrote:
What is the output of ls -l /bin/sysctl /usr/bin/sysctl /sbin/sysctl /usr/sbin/sysctl?

Code:
# ls -l /bin/sysctl /usr/bin/sysctl /sbin/sysctl /usr/sbin/sysctl
ls: cannot access '/bin/sysctl': No such file or directory
ls: cannot access '/usr/bin/sysctl': No such file or directory
lrwxrwxrwx 1 root root    12 Mar 25 15:56 /sbin/sysctl -> /bin/busybox
-rwxr-xr-x 1 root root 31104 Mar 26 10:17 /usr/sbin/sysctl

Hu wrote:
Why did you use quote tags instead of code tags?

So [quote] is for authors and [code] is for commands and responses?

Cheers Hu.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3535
Location: Illinois, USA

PostPosted: Fri Mar 27, 2020 3:05 am    Post subject: Reply with quote

[quote="Fog_Watch"]So
Quote:
is for authors and [code] is for commands and responses?
Yes.

And I think I know the answer to your question. OpenRC runs at boot. Ony the top level directories are guaranteed to be present. So OpenRC runs /sbin/sysctl which is symlinked to busybox. /usr isn't guaranteed to be mounted at boot time.

Now that people are starting to abandon split-usr and require /usr to be mounted that isn't so.

If your /usr is mounted (as most are) you can change the symlink if you wish. Keep a rescue medium and backup handy in case it fails to boot or does something else horrible.
But, I beleive that is the historical reason. Original Linux followed Unix design principles and worked very well. IMHO it's when the Unix principles are abandoned and Windows(tm) principles are followed that Linux goes into the alligator-infested swamp.
Back to top
View user's profile Send private message
Goverp
l33t
l33t


Joined: 07 Mar 2007
Posts: 797

PostPosted: Fri Mar 27, 2020 9:14 am    Post subject: Reply with quote

Fog_Watch,

Fog_Watch wrote:
...
These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild R ] sys-apps/busybox-1.31.1-r2::gentoo USE="static -debug -ipv6 -livecd -make-symlinks -math -mdev -pam -savedconfig (-selinux) -sep-usr -syslog -systemd" 0 KiB
...
Code:
# ls -l /bin/sysctl /usr/bin/sysctl /sbin/sysctl /usr/sbin/sysctl
ls: cannot access '/bin/sysctl': No such file or directory
ls: cannot access '/usr/bin/sysctl': No such file or directory
lrwxrwxrwx 1 root root    12 Mar 25 15:56 /sbin/sysctl -> /bin/busybox
-rwxr-xr-x 1 root root 31104 Mar 26 10:17 /usr/sbin/sysctl

...

IIUC there's something not right there - you're installing busybox with "-make-symlinks", which is the only sensible way, but /sbin/sysctl is linked to /bin/busybox. I suspect you're run "busybox --install", which will have created symlinks for all the busybox commands, and that's something you almost certainly DON'T want!

FWIW on my system, sysctl is in /usr/sbin; I have no symlinks for busybox, and it boots OK using OpenRC.

My apologies to Hu and Tony0945 if I've got this wrong and there's a good reason for having busybox symlinks.
_________________
Greybeard
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1847

PostPosted: Fri Mar 27, 2020 10:16 am    Post subject: Reply with quote

There is a reason to have busybox symlinks.
The reason is that in the absence of a full-blown software you can run a more basic version which may be enough for the task at hand.
Since those symlinks are not "claimed" by busybox, portage does not protect them from collisions, so you can still install a dedicated binary on top of that (which will overwrite the symlink with only a warning from portage).
Also, if you install the full version under /usr/ and busybox version under / you can use _something_ when /usr is unmounted and _something_you_like_ when /usr is mounted, as it will typically shadow the busybox links out whenever available.
Back to top
View user's profile Send private message
Tony0945
Advocate
Advocate


Joined: 25 Jul 2006
Posts: 3535
Location: Illinois, USA

PostPosted: Fri Mar 27, 2020 3:37 pm    Post subject: Reply with quote

Goverp wrote:
FWIW on my system, sysctl is in /usr/sbin; I have no symlinks for busybox, and it boots OK using OpenRC.

My apologies to Hu and Tony0945 if I've got this wrong and there's a good reason for having busybox symlinks.

Code:
  # emerge -pv busybox

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R    ] sys-apps/busybox-1.31.1-r2::gentoo  USE="mdev static syslog -debug -ipv6 -livecd -make-symlinks -math -pam -savedconfig (-selinux) -sep-usr -systemd" 0 KiB
Surprised me!
Back to top
View user's profile Send private message
Fog_Watch
Apprentice
Apprentice


Joined: 24 Jul 2006
Posts: 217
Location: Utility Muffin Research Kitchen

PostPosted: Sat Mar 28, 2020 7:06 am    Post subject: Reply with quote

The fairies have infected my install with busybox symlinks.

After I uninstalled busybox:
Code:
# equery b /sbin/sysctl
 * Searching for /sbin/sysctl ...
# ls -la /sbin/sysctl
lrwxrwxrwx 1 root root 12 Mar 25 15:56 /sbin/sysctl -> /bin/busybox #orphaned symlink

Then installed busybox:
Code:
# equery b /sbin/sysctl
 * Searching for /sbin/sysctl ...
sys-apps/busybox-1.31.1-r2 (/bin/busybox)

Don't forget:
Code:
 # cat /var/db/pkg/sys-apps/busybox-1.31.1-r2/USE
abi_x86_64 amd64 elibc_glibc kernel_linux static userland_GNU

I think this is the question, how do I get rid of such symlinks as /sbin/sysctl?
Back to top
View user's profile Send private message
Goverp
l33t
l33t


Joined: 07 Mar 2007
Posts: 797

PostPosted: Sat Mar 28, 2020 9:46 am    Post subject: Reply with quote

Fog_Watch wrote:
...
I think this is the question, how do I get rid of such symlinks as /sbin/sysctl?

I guess something along the lines of
  1. Collect the list of symlinks created by busybox, or failing that all broken symlinks, though the latter will probably include a load of cruft and there's a question of where to look
  2. Use qfile or equery belongs to collect the list of packages providing the original file
  3. Sort the resulting file and remove duplicates and busybox
  4. emerge -1 that lot
  5. Take a long drink.

Probably not quite worth writing a script.
_________________
Greybeard
Back to top
View user's profile Send private message
szatox
Veteran
Veteran


Joined: 27 Aug 2013
Posts: 1847

PostPosted: Sat Mar 28, 2020 10:22 am    Post subject: Reply with quote

Quote:
Use qfile or equery belongs to collect the list of packages providing the original file
Sort the resulting file and remove duplicates and busybox

Busybox does not report itself as the owner of those files.
However, if you really don't want busybox (which is a shame 'cus it'a a damn handy tool for how much it takes), you can just unmerge* it and stick to exclusively coreutils, which I think is a part of @system set. Those 2 packages serve the same purpose, it's just that one is "necessities only", and the other is "convenience included" version.

*and probably delete broken links from /bin and /sbin afterward. I think find can do that for you if you just apply the right switch
Back to top
View user's profile Send private message
Ionen
Guru
Guru


Joined: 06 Dec 2018
Posts: 525

PostPosted: Sat Mar 28, 2020 1:23 pm    Post subject: Reply with quote

szatox wrote:
*and probably delete broken links from /bin and /sbin afterward. I think find can do that for you if you just apply the right switch
It's
Code:
find / -xdev -xtype l
-xdev is optional but it makes it more sane, repeat for /usr if it's on a different mount point.

Do double check before deleting, personally there is actually some dead links I want to keep (like in some git trees where the link becomes proper at a checkout location). I've had varied cases of portage leaving dead links behind, but easy enough to clean up.

And if _really_ want busybox gone and don't want portage to complain about it anymore
Code:
mkdir -p /etc/portage/profile &&
echo '-*sys-apps/busybox' >> /etc/portage/profile/packages
But do keep in mind you're removing something gentoo expects to be there and it voids the warranty.
Back to top
View user's profile Send private message
Fog_Watch
Apprentice
Apprentice


Joined: 24 Jul 2006
Posts: 217
Location: Utility Muffin Research Kitchen

PostPosted: Mon Mar 30, 2020 10:43 am    Post subject: Reply with quote

What I did was:
Code:
emerge -C busybox
find / -xdev -xtype l > links.txt
xargs ls <links.txt
xargs rm <links.txt
emerge -1 busybox


Hopefully I'll keep a keener eye out next time I do an install for busybox --install.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum