Initrd
Версія від 16:57, 25 вересня 2009, створена 87.238.157.5 (обговорення)
Разбор initrd
gzip -dc /mnt/boot/initrd.img >/tmp/initrd.ext2 mkdir /mnt/initrd mount -o loop /tmp/initrd.ext2 /mnt/initrd
Начиная с Fedora Core 3, по умолчанию образ initrd это сжатый cpio архив
посмотреть содержимое
zcat /boot/initrd-$(uname -r).img | cpio -itv | less
раскрутить
gzip –dc initrd.img >initrd.x cpio –id < initrd.x
запихнуть содержимое /root/initrd/modules.new в MODULES а потом собрать INITRD из каталога /mnt/initrd
#!/bin/sh MODULES="/mnt/initrd/modules/modules.cgz" INITRD="/srv/tftpboot/netboot/centos/centos53-x86_64-initrd" echo "Rebuilding $MODULES" cd /root/initrd/modules.new rm -f /mnt/initrd/modules/modules.cgz find . | cpio -o -H newc | gzip -9 >$MODULES echo "Rebuilding $INITRD" cd /mnt/initrd find . | cpio -o -H newc | gzip -9 >$INITRD
и еще один вариант
Оригинал
prereq.
copy of the standard boot and drivers images /mnt/cdrom/images/bootnet.img and drivers.img
1. Set things up for us
1. mkdir /tmp/boot 2. mkdir /tmp/boot/custum_img 3. mkdir /tmp/boot/initrd_img 4. mkdir /tmp/boot/modules 5. mkdir /tmp/drivers 6. mkdir /tmp/drivers/drivers_img 7. mkdir /tmp/drivers/modules 8. cp /mnt/cdrom/images/bootnet.img /tmp/boot/custom.img 9. cp /mnt/cdrom/images/drivers.img /tmp/drivers/
2. Mount and decompress the files from boot image
1. get into boot working dir. cd /tmp/boot 2. mount custum.img as filesystem mount -o loop custum.img custum_img 3. decompress the initrd gzip -dc custum_img/initrd.img >initrd.ext2 4. mount initrd.ext2 as filesystem mount -o loop initrd.ext2 initrd_img 5. get modules from initrd_img gzip -dc initrd_img/modules/modules.cgz modules.cpio 6. extract cpio archive into /tmp/boot/modules cd /tmp/boot/modules; cpio -idumv </tmp/boot/modules.cpio
3. Make the changes that's requeried i.e get new modules in place
1. copy ft.o to /tmp/boot/modules/2.4.2-2BOOT 2. remove unwanted modules in 2.4.2-2BOOT 3. edit /tmp/boot/initrd_img/modules/module-info remove old modules enter info for new modules 4. Find new dependencies if any & update /tmp/boot/initrd_img/modules/modules.dep 5. Find new hardware update if any & update /tmp/boot/initrd_img/modules/pcitable
4. Rebuild the new boot disk
1. get into modules dir. cd /tmp/boot/modules 2. create new modules.cpio file find 2.4.2-2BOOT -print -depth |cpio -H crc -ovF modules.cpio 2> /dev/null 3. compress modules.cpio gzip -S .cgz modules.cpio 4. remove old modules.cgz rm /tmp/boot/initrd_img/modules/modules.cgz 5. mv new modules.cgz in place mv modules.cpio.cgz /tmp/boot/initrd_img/modules/modules.cgz 6. get into boot dir. cd /tmp/boot/initrd_img 7. create zerofile touch zerofile 8. fill up filesystem with zero's cat /dev/zero >zerofile 9. sync filesystem to disk sync 10. remove zerofile rm zerofile 12. cd /tmp/boot 11. unmount initrd filesystem umount initrd_img 12. recompress initrd.ext2 gzip initrd.ext2 13. remove old initrd.img rm custum_img/initrd.img 14. place new initrd on boot img mv initrd.ext2.gz custum_img/initrd.img 15. unmount bootnet filesystem umount custum_img
5. place custum.img on boot disk
1. dd if=custum.img of=/dev/fdo