簡體   English   中英

在Centos中編譯的nWipe軟件包在Busybox嵌入式Linux中不起作用

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

我已經在Centos中編譯了nwipe開源實用程序。 編譯后,它在編譯它的機器上絕對可以正常工作。 我還將已編譯的程序包連同所需的庫一起復制到另一台運行Centos的計算機上,並且工作正常。

我試圖打包此實用程序以與Busybox RAMBOX嵌入式linux一起使用。 該實用程序的目的是通過TFTP PXEBoot工作站並自動擦除所有硬盤驅動器。

為了實現這一目標,我使用了來自Centos netboot CD的Linux內核,並下載了我在另一台Centos開發服務器上編譯的busybox,復制的nwipe實用程序。

我還復制了所有必需的庫。 見下文。

當我做ldd nwipe時。 它顯示了庫的依賴關系。

[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)

所以我將所有這些庫依賴項都復制到busybox / lib / usr / lib文件夾中。

最后,我編譯了busybox,並使用cpio和gzip來獲取initrd.img文件。

然后,我使用centos netboot內核2.6和initrd.img對工作站進行pxeboot。 一切正常,我可以使用所有busybox基本的linux命令。 但是當我執行./nwipe時,它不起作用。 它只是再次顯示shell提示。

/# ./nwipe
/#

請參閱下面的初始化文件內容。

#!/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

有人可以幫我解決這個問題嗎?

如何使用busybox運行編譯的軟件?

預先感謝您閱讀這篇文章。

我已經通過不使用busybox來解決此問題。 這次,我使用了Centos的最小安裝,並使用了dracut實用程序來創建內核和initramfs,並將根文件系統作為NFS掛載在服務器上。 它像一種魅力。

它像一個成熟的Linux Centos一樣工作,而且速度非常快。

謝謝你看這篇文章:)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM