在 Centos 中编译的 nWipe 包在嵌入式 Busybox 中不起作用 linux
nWipe Package compiled in Centos not working in Busybox embedded linux
我已经在 Centos 中编译了 nwipe 开源实用程序。编译后,它在编译它的机器上绝对可以正常工作。我还将已编译的包连同所需的库一起复制到另一台机器 运行ning Centos 并且它工作正常。
我已经尝试打包此实用程序以与嵌入式 Busybox RAMBOX 一起使用 linux。此实用程序的目的是通过 TFTP PXEBoot 工作站并自动擦除所有硬盘驱动器。
为了实现这一点,我使用了 Centos netboot CD 中的 Linux 内核并下载了 busybox,复制了我在另一台 Centos 开发服务器上编译的 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 kernel 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 编译的软件?
提前感谢您阅读本文post。
我已经设法通过不使用 busybox 解决了这个问题。这一次,我使用 Centos 最小安装并使用 dracut 实用程序创建内核和 initramfs,并将根文件系统作为 NFS 安装在服务器上。它就像一个魅力。
它像一个成熟的 Linux Centos 一样工作,而且速度非常快。
感谢您查看此内容 post :)
我已经在 Centos 中编译了 nwipe 开源实用程序。编译后,它在编译它的机器上绝对可以正常工作。我还将已编译的包连同所需的库一起复制到另一台机器 运行ning Centos 并且它工作正常。
我已经尝试打包此实用程序以与嵌入式 Busybox RAMBOX 一起使用 linux。此实用程序的目的是通过 TFTP PXEBoot 工作站并自动擦除所有硬盘驱动器。
为了实现这一点,我使用了 Centos netboot CD 中的 Linux 内核并下载了 busybox,复制了我在另一台 Centos 开发服务器上编译的 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 kernel 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 编译的软件?
提前感谢您阅读本文post。
我已经设法通过不使用 busybox 解决了这个问题。这一次,我使用 Centos 最小安装并使用 dracut 实用程序创建内核和 initramfs,并将根文件系统作为 NFS 安装在服务器上。它就像一个魅力。
它像一个成熟的 Linux Centos 一样工作,而且速度非常快。
感谢您查看此内容 post :)