LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 04-25-2012, 02:28 PM   #1
masuch
Member
 
Registered: Sep 2011
Location: /dev/null
Distribution: ubuntu 64bits
Posts: 135

Rep: Reputation: 1
blkid in busybox - how does it work ?


Hi,

I have a question about blkid in busybox.
If I run from desktop in terminal /bin/busybox - there is no blkid command at all - not even /bin/busybox blkid work.
But when I am in busybox /because of booting process failure/ - blkid command runs.

Could please anybody explain me how is it possible ?

thank you for exlpanation,
regards,
Martin
 
Old 05-01-2012, 07:29 AM   #2
ciotog
Member
 
Registered: Mar 2004
Location: Canada
Distribution: Slackware current
Posts: 728
Blog Entries: 2

Rep: Reputation: 43
Quote:
Originally Posted by masuch View Post
But when I am in busybox /because of booting process failure/ - blkid command runs.
You're not "in busybox" in this situation, you're at the boot loader prompt (likely grub). It has blkid, busybox evidently was not configured to build with that applet.
 
Old 05-01-2012, 09:01 AM   #3
masuch
Member
 
Registered: Sep 2011
Location: /dev/null
Distribution: ubuntu 64bits
Posts: 135

Original Poster
Rep: Reputation: 1
Thanks for answer.

So, if I boot to busybox - it is /boot/initrd.img... which I can configure by update-initramfs ?
It was misleading me by the name of /bin/busybox which supposed to be grub2 ?

What I am completely confused is following:

ls -l --time-style=full-iso `sudo locate -b '\busybox'`
-rwxr-xr-x 1 root root 1827920 2012-04-13 20:53:12.000000000 +0100 /bin/busybox
-rwxr-xr-x 1 root root 315256 2012-04-13 20:53:27.000000000 +0100 /usr/lib/initramfs-tools/bin/busybox
-rwxr-xr-x 1 root root 1102 2011-07-13 15:13:15.000000000 +0100 /usr/share/initramfs-tools/hooks/busybox


--- So, which one is going to be used within boot process if boot process failed ???
--- each busybox has different command list ... have a look at following:



$ /bin/busybox --help

BusyBox v1.18.5 (Ubuntu 1:1.18.5-1ubuntu4) multi-call binary.
Copyright (C) 1998-2009 Erik Andersen, Rob Landley, Denys Vlasenko
and others. Licensed under GPLv2.
See source distribution for full notice.

Usage: busybox [function] [arguments]...
or: busybox --list[-full]
or: function [arguments]...

BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as.

Currently defined functions:
[, [[, acpid, addgroup, adduser, adjtimex, ar, arping, ash, awk, basename, blockdev, brctl, bunzip2, bzcat, bzip2, cal, cat, chgrp, chmod, chown,
chroot, chvt, clear, cmp, cp, cpio, crond, crontab, cut, date, dc, dd, deallocvt, delgroup, deluser, df, diff, dirname, dmesg, dnsdomainname,
dos2unix, dpkg, dpkg-deb, du, dumpkmap, dumpleases, echo, ed, egrep, eject, env, expand, expr, false, fbset, fdflush, fdisk, fgrep, find, fold, free,
freeramdisk, fsck.minix, ftpget, ftpput, getopt, getty, grep, gunzip, gzip, head, hexdump, hostid, hostname, httpd, hwclock, id, ifconfig, ifdown,
ifup, init, ionice, ip, ipcalc, kill, killall, klogd, last, length, less, linuxrc, ln, loadfont, loadkmap, logger, login, logname, logread, losetup,
ls, lzcat, lzma, makedevs, md5sum, mdev, mesg, microcom, mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp, more, mount, mt, mv, nameif, nc, netstat,
nslookup, od, openvt, passwd, patch, pidof, ping, ping6, pivot_root, printf, ps, pwd, rdate, readlink, realpath, renice, reset, rev, rm, rmdir, route,
rpm, rpm2cpio, run-parts, sed, seq, setkeycodes, sh, sha1sum, sha256sum, sha512sum, sleep, sort, start-stop-daemon, static-sh, strings, stty, su,
sulogin, swapoff, swapon, switch_root, sync, sysctl, syslogd, tac, tail, tar, tee, telnet, telnetd, test, tftp, time, timeout, top, touch, tr,
traceroute, traceroute6, true, tty, tunctl, udhcpc, udhcpd, umount, uname, uncompress, unexpand, uniq, unix2dos, unlzma, unxz, unzip, uptime, usleep,
uudecode, uuencode, vconfig, vi, vlock, watch, watchdog, wc, wget, which, who, whoami, xargs, xz, xzcat, yes, zcat



:-) 5.49 5.11 4.90 3/1126 307 pts/14 jobs=0 13:55:27 ~
masuch@MYMAIN 1:2004:5
$ /usr/lib/initramfs-tools/bin/busybox --help

BusyBox v1.18.5 (Ubuntu 1:1.18.5-1ubuntu4) multi-call binary.
Copyright (C) 1998-2009 Erik Andersen, Rob Landley, Denys Vlasenko
and others. Licensed under GPLv2.
See source distribution for full notice.

Usage: busybox [function] [arguments]...
or: busybox --list[-full]
or: function [arguments]...

BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as.

Currently defined functions:
[, [[, ash, awk, basename, blockdev, cat, chmod, chroot, chvt, clear,
cmp, cp, cut, deallocvt, df, dnsdomainname, du, dumpkmap, echo, egrep,
env, expr, false, fbset, fdflush, fgrep, find, grep, gunzip, gzip,
hostname, ifconfig, ip, kill, ln, loadfont, loadkmap, ls, mkdir,
mkfifo, mknod, mkswap, mktemp, modinfo, more, mount, mv, openvt, pidof,
printf, ps, pwd, readlink, reset, rm, rmdir, sed, seq, setkeycodes, sh,
sleep, sort, stat, static-sh, stty, switch_root, sync, tail, tee, test,
touch, tr, true, tty, umount, uname, uniq, wc, wget, which, yes, zcat



--- BUT both have exactly the same version - (Ubuntu 1:1.18.5-1ubuntu4) - what does it mean ?
--- Did I messed up something ?

thanks for any clue.
M.

Last edited by masuch; 05-01-2012 at 09:13 AM.
 
Old 05-01-2012, 08:39 PM   #4
ciotog
Member
 
Registered: Mar 2004
Location: Canada
Distribution: Slackware current
Posts: 728
Blog Entries: 2

Rep: Reputation: 43
Are you booting from an iso image? If so, then the boot loader is probably isolinux which includes a minimal busybox in the minirt (only enough for booting and troubleshooting at that stage), along with some version of blkid but evidently not the busybox version. You can see how much smaller the initrd version of busybox is vs the one in bin (nearly 1/6 the size).
 
Old 05-02-2012, 06:42 AM   #5
masuch
Member
 
Registered: Sep 2011
Location: /dev/null
Distribution: ubuntu 64bits
Posts: 135

Original Poster
Rep: Reputation: 1
No, I am not booting from ISO. It is normally installed , two times dist-upgraded Ubuntu 64 bit.

My point is:

Which file is for "busybox" when boot process failed and get into it ?
Which file is for "grub" , "grub rescue" when booting process failed and get into it ?
Why have I three busybox files with different length, date , command list , (all are executable) - and what is it for ?

Thank you very much for any clue,
If somebody please have some URLs please I would much appreciate it. (I did not find some complete/complex description/experience yet)

M.
 
Old 05-02-2012, 08:36 PM   #6
ciotog
Member
 
Registered: Mar 2004
Location: Canada
Distribution: Slackware current
Posts: 728
Blog Entries: 2

Rep: Reputation: 43
The "/usr/lib/initramfs-tools/bin/busybox" one is the one that's available during the boot process, so if booting fails that's the one that's used. It's a minimal set of utilities.

The "/bin/busybox" one is the one that's available when the system has booted, only because "/bin" is in the "PATH" environment variable.

The third one isn't actually busybox, it's a script used to create all the symlinks to the applets and install busybox in the right place during the install phase. You can see this by running "file /usr/share/initramfs-tools/hooks/busybox" and then even "less /usr/share/initramfs-tools/hooks/busybox".

Both busyboxen display the same version info because it was the same source and platform used to build it, but each was configured differently. The version string has "Ubuntu 1:1.18.5-1ubuntu4" after it because the Ubuntu folks like to patch everything to death :P

You can run "/usr/lib/initramfs-tools/bin/busybox blkid" if you want to have use blkid, it should work ok.
 
Old 05-03-2012, 07:27 AM   #7
masuch
Member
 
Registered: Sep 2011
Location: /dev/null
Distribution: ubuntu 64bits
Posts: 135

Original Poster
Rep: Reputation: 1
--- thank you , thank you very much for induction lesson ... just couple of questions if you can :

The "/usr/lib/initramfs-tools/bin/busybox" one is the one that's available during the boot process, so if booting fails that's the one that's used. It's a minimal set of utilities.

--- blkid in busybox works BUT when I run normally running OS in terminal:
/usr/lib/initramfs-tools/bin/busybox blkid
blkid: applet not found
... what am I missing to understand ?


The "/bin/busybox" one is the one that's available when the system has booted, only because "/bin" is in the "PATH" environment variable.

--- Does it mean that all commands located in /bin directory are accessible when system booting ? OR do I have to recompile busybox to include further commands?

The third one isn't actually busybox, it's a script used to create all the symlinks to the applets and install busybox in the right place during the install phase. You can see this by running "file /usr/share/initramfs-tools/hooks/busybox" and then even "less /usr/share/initramfs-tools/hooks/busybox".

-- Do you mean OS installation or busybox installation (both) ?
-- What applets means ? Are those commands in only /bin directory or is this some special location for them ?
-- what ${DESTDIR} in hat scipt could be ?
-- What applet could be ? script , compiled program , anything else (any other script language) ? Where they must be located when I want to create it by myself ?
:-) I probably need to study those scripts by myself to get more info ... :-)

Both busyboxen display the same version info because it was the same source and platform used to build it, but each was configured differently. The version string has "Ubuntu 1:1.18.5-1ubuntu4" after it because the Ubuntu folks like to patch everything to death :P

--- :-) but it is good habit , isn't it - as far as I have been programing in windows it has always helped :-)

You can run "/usr/lib/initramfs-tools/bin/busybox blkid" if you want to have use blkid, it should work ok.
--- no, I have got
blkid: applet not found

... that's exactly what I do not understand - I do know that when OS booting failed and got into busybox - blkid works !
(even if I had to after dist-upgrade solved problem blkid: /lib/x86_64-linux-gnu/libblkid.so.1: version `BLKID_2.20' not found
... BUT I cannot find "busybox command" where blkid applet works when I try to run it in terminal ... ?

$ /bin/busybox blkid
blkid: applet not found

$ /usr/lib/initramfs-tools/bin/busybox blkid
blkid: applet not found

(I do not have more busybox (except that installation script) in my system :-))

thank you again for explanation.
Kind Regards,
Martin
 
Old 05-03-2012, 05:54 PM   #8
ciotog
Member
 
Registered: Mar 2004
Location: Canada
Distribution: Slackware current
Posts: 728
Blog Entries: 2

Rep: Reputation: 43
Quote:
Originally Posted by masuch View Post
--- blkid in busybox works BUT when I run normally running OS in terminal:
/usr/lib/initramfs-tools/bin/busybox blkid
blkid: applet not found
... what am I missing to understand ?
Ah yes, I'm sorry I misled you - I forgot that neither busyboxen were compiled with the blkid applet. When the system fails to boot and you're in the boot loader environment, blkid is provided by some other means.

Quote:
Originally Posted by masuch View Post
--- Does it mean that all commands located in /bin directory are accessible when system booting ? OR do I have to recompile busybox to include further commands?
No, those commands are only available after the system has booted. Well that's not technically true, there are ways to access them without actually fully booting the computer but it's complicated

Quote:
Originally Posted by masuch View Post
-- Do you mean OS installation or busybox installation (both) ?
Just busybox, but the package that installs busybox probably recreates the links in its own fashion (packages usually don't have symlinks as part of the archive).

Quote:
Originally Posted by masuch View Post
-- What applets means ? Are those commands in only /bin directory or is this some special location for them
An applet as far as busybox is concerned is one of the utilities that's built in and linked to it. They can be in /bin, /usr/bin, /sbin, etc. Generally a busybox applet is linked from the "typical" location for that utility. So you could have "/bin/test -> /bin/busybox" and "/sbin/route -> /bin/busybox"

Quote:
Originally Posted by masuch View Post
-- what ${DESTDIR} in hat scipt could be ?
DESTDIR is set during the configuration process, it could be anything but is likely "/" (which means everything is to be installed relative to the root)

Quote:
Originally Posted by masuch View Post
-- What applet could be ? script , compiled program , anything else (any other script language) ? Where they must be located when I want to create it by myself ?
In terms of busybox, everything is compiled into a single executable - no scripts. A script generally doesn't need to be included in some kind of single executable like busybox.

Quote:
Originally Posted by masuch View Post
... that's exactly what I do not understand - I do know that when OS booting failed and got into busybox - blkid works !
Well like I said, you're not "in busybox" - you're in an environment where busybox and some other stuff is available. In this particular case, busybox doesn't provide blkid - something else does. It could be a standalone binary, or linked in to some other utility like busybox.

Last edited by ciotog; 05-03-2012 at 05:56 PM.
 
  


Reply

Tags
blkid, busybox


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
blkid help needed rng Linux - Newbie 13 11-03-2011 10:04 PM
Cant identify drive with 'blkid' clifford227 Linux - Newbie 3 08-22-2010 09:28 AM
Can busybox work independently? LinuxNewman Linux - Newbie 4 07-29-2009 12:53 AM
making alsa work in busybox tomnab Linux - Software 1 07-03-2009 02:54 AM
/sbin/reboot of busybox filesystem does not work raklo Linux - Kernel 16 04-10-2009 04:47 AM


All times are GMT -5. The time now is 12:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration