Initrd

Матеріал з Wiki Welard
Перейти до навігації Перейти до пошуку

статья

Разбор 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

разобрать -> добавить -> собрать

1 Decompress.
gunzip < initrd.img > initrd.cpio
2. Append files.
ls myfile | cpio -oAO initrd.cpio -H newc
3. Recompress.
gzip -cz initrd.cpio > initrd.img

и еще один вариант [1] 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