简体   繁体   English

在Centos中编译的nWipe软件包在Busybox嵌入式Linux中不起作用

[英]nWipe Package compiled in Centos not working in Busybox embedded linux

I have compiled nwipe open source utility in Centos. 我已经在Centos中编译了nwipe开源实用程序。 Once compiled it works absolutely fine on the machine where it was compiled. 编译后,它在编译它的机器上绝对可以正常工作。 I have also copied the compiled package to another machine running Centos along with required libraries and it works fine. 我还将已编译的程序包连同所需的库一起复制到另一台运行Centos的计算机上,并且工作正常。

I have tried to package this utility to work with Busybox RAMBOX embedded linux. 我试图打包此实用程序以与Busybox RAMBOX嵌入式linux一起使用。 The purpose of this utility is to PXEBoot the workstations via TFTP and auto wipe all the hard-drives. 该实用程序的目的是通过TFTP PXEBoot工作站并自动擦除所有硬盘驱动器。

In order to achieve this, I have used Linux kernel from Centos netboot CD and downloaded the busybox, copied nwipe utility that I compiled on another Centos development server. 为了实现这一目标,我使用了来自Centos netboot CD的Linux内核,并下载了我在另一台Centos开发服务器上编译的busybox,复制的nwipe实用程序。

I also copied all the required libraries. 我还复制了所有必需的库。 See below. 见下文。

when I do ldd nwipe. 当我做ldd nwipe时。 It shows the dependencies for the libraries. 它显示了库的依赖关系。

[root@localhost src]# ldd nwipe
        linux-gate.so.1 =>  (0x00a78000)
        libpthread.so.0 => /lib/libpthread.so.0 (0x00650000)
        libparted.so.2 => /usr/lib/libparted.so.2 (0x007fd000)
        libpanel.so.5 => /usr/lib/libpanel.so.5 (0x00dd0000)
        libncurses.so.5 => /lib/libncurses.so.5 (0x006db000)
        libc.so.6 => /lib/libc.so.6 (0x004b0000)
        libtinfo.so.5 => /lib/libtinfo.so.5 (0x007e2000)
        /lib/ld-linux.so.2 (0x0048a000)
        libuuid.so.1 => /lib/libuuid.so.1 (0x0025b000)
        libdl.so.2 => /lib/libdl.so.2 (0x00649000)
        libdevmapper.so.1.02 => /lib/libdevmapper.so.1.02 (0x0073c000)
        libselinux.so.1 => /lib/libselinux.so.1 (0x006ba000)
        libsepol.so.1 => /lib/libsepol.so.1 (0x00a2e000)
        libudev.so.0 => /lib/libudev.so.0 (0x0066d000)

so I copied all these libraries dependencies to the busybox /lib /usr/lib folders. 所以我将所有这些库依赖项都复制到busybox / lib / usr / lib文件夹中。

Finally I compiled the busybox and used cpio and gzip to get the initrd.img file. 最后,我编译了busybox,并使用cpio和gzip来获取initrd.img文件。

Then I use centos netboot kernel 2.6 and initrd.img to pxeboot the workstation. 然后,我使用centos netboot内核2.6和initrd.img对工作站进行pxeboot。 Everything works fine, I can use all the busybox basic linux commands. 一切正常,我可以使用所有busybox基本的linux命令。 But when I execute ./nwipe it does not work. 但是当我执行./nwipe时,它不起作用。 It simply shows the shell prompt again. 它只是再次显示shell提示。

/# ./nwipe
/#

see below the content of my init file. 请参阅下面的初始化文件内容。

#!/bin/sh

#Mount things needed by this script
mount -t proc proc /proc
mount -t sysfs sysfs /sys

#Disable kernel messages from popping onto the screen
echo 0 > /proc/sys/kernel/printk

#Clear the screen
clear

#Create all the symlinks to /bin/busybox
busybox --install -s

#Create device nodes
mknod /dev/null c 1 3
mknod /dev/tty c 5 0
mdev -s

#Function for parsing command line options with "=" in them
# get_opt("init=/sbin/init") will return "/sbin/init"
get_opt() {
        echo "$@" | cut -d "=" -f 2
}

#Defaults
init="/sbin/init"
root="/dev/hda1"

#Process command line options
for i in $(cat /proc/cmdline); do
        case $i in
                root\=*)
                        root=$(get_opt $i)
                        ;;
                init\=*)
                        init=$(get_opt $i)
                        ;;
        esac
done
#Mount the root device
mount "${root}" /newroot

#Check if $init exists and is executable
if [[ -x "/newroot/${init}" ]] ; then
        #Unmount all other mounts so that the ram used by
        #the initramfs can be cleared after switch_root
        umount /sys /proc

        #Switch to the new root and execute init
        exec switch_root /newroot "${init}"
fi

#This will only be run if the exec above failed
echo "Failed to switch_root, dropping to a shell"
exec sh

Could someone please help me what I have to do to fix this? 有人可以帮我解决这个问题吗?

How I can run my compiled software with busybox? 如何使用busybox运行编译的软件?

Thanks well in advance for reading this post. 预先感谢您阅读这篇文章。

I have managed to fix this by not using busybox. 我已经通过不使用busybox来解决此问题。 This time around I have used Centos minimal install and used dracut utility to create kernel and initramfs and mounted the root file system as NFS on the server. 这次,我使用了Centos的最小安装,并使用了dracut实用程序来创建内核和initramfs,并将根文件系统作为NFS挂载在服务器上。 It works like a charm. 它像一种魅力。

It works like a full blown Linux Centos and it is pretty fast. 它像一个成熟的Linux Centos一样工作,而且速度非常快。

Thank you for looking at this post :) 谢谢你看这篇文章:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM