|
在 IBM Developer Works 看到的文章 "Linux 初始 RAM 磁盘(initrd)概述"
http://www.ibm.com/developerworks/cn/linux/l-initrd.html
其中描述了在2.4内核下相关操作的方法,我也想在2.6下试试,但是出现了点问题,请大家帮助,谢谢!
脚本在下面
#!/bin/bash
#cleaning up!!
rm -rf /tmp/ramdisk
rm -rf /tmp/initrd-will
# Ramdisk Constants
RDSIZE=4000
BLKSIZE=1024
# Create an empty ramdisk image
dd if=/dev/zero of=/tmp/ramdisk bs=$BLKSIZE count=$RDSIZE
# Make it an ext2 mountable file system
/sbin/mke2fs -F -m 0 -b $BLKSIZE /tmp/ramdisk $RDSIZE
# Mount it so that we can populate
mount /tmp/ramdisk /mnt/initrd -t ext2 -o loop=/dev/loop0
# Populate the filesystem (subdirectories)
mkdir /mnt/initrd/bin
mkdir /mnt/initrd/sys
mkdir /mnt/initrd/dev
mkdir /mnt/initrd/proc
# Grab busybox and create the symbolic links
pushd /mnt/initrd/bin
#push $`pwd` into a directory stack && cd /initrd/bin
cp /usr/local/src/busybox-1.13.2/busybox .
ln -s busybox ash
ln -s busybox mount
ln -s busybox echo
ln -s busybox ls
ln -s busybox cat
ln -s busybox ps
ln -s busybox dmesg
ln -s busybox sysctl
popd
# Grab the necessary dev files
cp -a /dev/console /mnt/initrd/dev
cp -a /dev/ramdisk /mnt/initrd/dev
cp -a /dev/ram0 /mnt/initrd/dev
cp -a /dev/null /mnt/initrd/dev
cp -a /dev/tty1 /mnt/initrd/dev
cp -a /dev/tty2 /mnt/initrd/dev
# Equate sbin with bin
pushd /mnt/initrd
ln -s bin sbin
popd
# Create the init file
cat >> /mnt/initrd/linuxrc << EOF
#!/bin/ash
echo
echo "Simple initrd is active"
echo
mount -t proc /proc /proc
mount -t sysfs none /sys
/bin/ash --login
EOF
chmod +x /mnt/initrd/linuxrc
# Finish up...
#umount /mnt/initrd
echo `pwd`
#cd /mnt/initrd
find /mnt/initrd |cpio --quiet -H newc /temp/initrd-will
#cp /tmp/initrd-will /boot/initrd-will
出错的是
cpio : You must specify one of -oipt options |
|