⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 make_initrd_img

📁 Linux嵌入式设计配套光盘,学习嵌入式设计可参考
💻
字号:
#!/bin/shexport PRJROOT=/lad# This script will create a compressed root filesystem image from# the $PRJROOT/initrd directory. The filesystem type, "ext2" or# "minix" is specified on the command line.# Inputs:  $PRJROOT/initrd root filesystem# Outputs: $PRJROOT/images/initrd.img.gz# if [ `whoami` != "root" ]# then#   echo "Must 'su root' before invoking this script."#   exit 1# fiif [ "$2" = "" ]then  echo "usage: $0 {ext2 | minix} 1K_block_count"  exit 1fiif [ "$1" = "ext2" ]then  FS_TYPE="ext2"  # "-m 0" prevents saving space for root.  MKFS_CMD="/sbin/mkfs.ext2 -m 0"elif [ "$1" = "minix" ]then  FS_TYPE="minix"  MKFS_CMD="/sbin/mkfs.minix"else  echo "usage: $0 {ext2 | minix} 1K_block_count"  exit 1fiecho "Creating root filesystem image..."# Change to the ''images'' directory and create a root filesystem image from# a file using a loopback device.pushd $PRJROOT/imagesdd if=/dev/zero of=initrd.img bs=1k count=$2$MKFS_CMD initrd.imgecho "Copying root filesystem to root filesystem image..."if [ -d mnt ]then  mnt_already_exists=1else  mnt_already_exists=0  mkdir mntfiecho "Removing ~* backup files..."rm -f $PRJROOT/initrd/*~ $PRJROOT/initrd/*/*~ $PRJROOT/initrd/*/*/*~echo "Root privilege required for mkfs.xxx, copying dev/nodes, and umount..."sudo mount -t $FS_TYPE initrd.img mnt -o loopsudo cp -r ../initrd/* mnt/sudo umount mntif [ $mnt_already_exists = 0 ]then  rmdir mntfiecho "Compressing root filesystem image..."gzip -c initrd.img > initrd.gzpopd

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -