LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1041|回复: 6

bootsplash 和 initrd 可以共存吗?

[复制链接]
发表于 2006-7-26 20:56:39 | 显示全部楼层 |阅读模式
我研究splash生成的initrd的文件不是普通的 initrd格式,
平时我生成 initrd的过程是先
dd if=/dev/zero of=./initrd bs=5M count=1
mkfs.ext2 ./initrd
mount -t ext2 -o loop ./initrd /mnt
cp 需要的东西到 /mnt
umount /mnt
gzip -9 ./initrd
但我发现用splash -s -f 配置文件 >> test
生成的test 不是gzip 格式也不是ext2格式的ram盘

请问有没有人知道是什么格式的。
或者有什么办法可以共存?
 楼主| 发表于 2006-7-26 21:44:24 | 显示全部楼层
自己顶一下,我正在bootsplash的源代码,希望有头绪。。。
回复 支持 反对

使用道具 举报

发表于 2006-7-26 23:15:18 | 显示全部楼层
本来就是这样的, 非 cpio 的 initrd 是直接由 grub 装入内存, 不管格式的, mount 时才根据格式解压, 多余的数据不会出错.

bootsplash 就是根据多余的数据不会出错这点加到 initrd 后面的.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-7-26 23:53:57 | 显示全部楼层
终于找到了。。呵呵。。。
上述是对于2.4内核是有效的。..
对于2.6内核就要
出处:http://www.graphics-muse.org/wp/?p=99
Okay, so it seems this is completely wrong.  What is required is to copy the splash image file to the rootfs of your initramfs.  You don't need to append the image to the compressed initramfs at all.  So the correct process is actually:

Build busybox and install it into a directory.  We'll call it /mnt/mythbox/busybox.

   1. Create a splash data file using a command like this:  splash -s -f <path to splash config file> > splashfile
   2. Copy splashfile to the top level of your busybox directory: cp splashfile /mnt/mythbox/busybox/bootsplash  Note that the filename in the busybox directory must be bootsplash.
   3. Now build your compressed cpio image that will be your 2.6 initramfs.  You don't need to append the splash file to the compressed initramfs.

Now it works.  This makes sense, too, if you read the bootsplash patch in the init() function.  It tries to open the file "/bootsplash".  I can see how people thought you still needed to append the file because that's what you did with 2.4.  But I'm not sure why the information about placing the file in the root of the rootfs isn't posted somewhere else.

Anyway, this seems to work now.  I've verified it with several builds.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-7-26 23:56:48 | 显示全部楼层
很高兴,今晚终于搞好了

总结对于2.6内核的ramdisk  (initrd) 和 bootsplash共存的办法是

splash -s -f <path to splash config file> > bootsplash
生成的 copy bootsplash文件放到 ramdisk 的根目录去,即是最顶那层。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-7-27 00:16:28 | 显示全部楼层
+void splash_init(void)
+{
+        struct fb_info *info;
+        struct vc_data *vc;
+        int isramfs = 1;
+        int fd;
+        int len;
+        int max_len = 1024*1024*2;
+        char *mem;
+
+        if (splash_registered)
+                return;
+        vc = vc_cons[0].d;
+        info = registered_fb[0];
+        if (!vc || !info || info->var.bits_per_pixel != 16)
+                return;
+#ifdef CONFIG_PROC_FS
+        splash_proc_register();
+#endif
+        splash_registered = 1;
+        if (vc->vc_splash_data)
+                return;//这句就是对2.6内核的bootsplash补丁里,尝试读取ramdisk里的bootsplas
+        if ((fd = sys_open("/bootsplash", O_RDONLY, 0)) < 0) {
+                isramfs = 0;
+                fd = sys_open("/initrd.image", O_RDONLY, 0);
+        }
+        if (fd < 0)
+                return;
+        if ((len = (int)sys_lseek(fd, (off_t)0, 2)) <= 0) {
+                sys_close(fd);
+                return;
+        }
+        /* Don't look for more than the last 2MB */
+        if (len > max_len) {
+                printk( KERN_INFO "bootsplash: scanning last %dMB of initrd for signature\n",
+                                max_len>>20);
+                sys_lseek(fd, (off_t)(len - max_len), 0);
+                len = max_len;
+        } else {
+                sys_lseek(fd, (off_t)0, 0);
+        }
+
+        mem = vmalloc(len);
+        if (mem) {
+                acquire_console_sem();
+                if ((int)sys_read(fd, mem, len) == len && splash_getraw((unsigned char *)mem, (unsigned char *)mem + len, (int *)0) == 0 && vc->vc_splash_data)
+                        vc->vc_splash_data->splash_state = splash_default & 1;
+                release_console_sem();
+                vfree(mem);
+        }
+        sys_close(fd);
+        if (isramfs)
+                sys_unlink("/bootsplash");
+        return;
+}
+
回复 支持 反对

使用道具 举报

发表于 2006-7-27 17:19:27 | 显示全部楼层
这个~~,我觉得网上关于bootsplash的教程讲的都挺清楚的.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表