西西河

主题:【原创】Install and boot linux on a USB external hard drive -- whoknows

共:💬4 🌺7 新:
全看分页树展 · 主题 跟帖
家园 一点建议

首先,我不是什么牛人了。其次,不好意思,最近忙着搬家,不是很经常上网,见谅。

在ubuntu上有一个命令mkinitramfs (ubuntu 6.06) / mkinitrd(?) (older version of ubuntu)。 这个命令应该是一个script,你可以参考一下。但是基本上不太可能直接修改initrd_usb.img里面的内容;而是要根据你自己的设置重新生成这个image。

至于你的具体问题,我觉得举个例子会好说清楚一些:

首先假定有一个目录叫ramdisk/,里面是你要放的东西。当然,放什么东西取决于你做initrd的目的了。然后哪,有一个script,就叫做makeinitrd.sh吧:

============ script start =================

#!/bin/sh

dd if=/dev/zero of=rd-ext2.bin bs=1k count=2048

mke2fs -F -m0 rd-ext2.bin

mount -t ext2 rd-ext2.bin /mnt -o loop

tar -C ramdisk --exclude .svn -cf - . | tar -C /mnt -xf -

umount /mnt

============= script end ====================

The 2nd line is to create a empty 2M file filled with zeros.

The 3rd line is to create an ext2 filesystem on that empty 2M file we just created.

Then, at the 4th line, we mount this file using /dev/loop to a local mounting point as an ext2 filesystem.

The 5th line is to put what we have prepared in the ramdisk folder to the mounted file system.

Then at last, the ramdisk image is unmounted at 6th line.

上面的解释是从我的笔记里面copy出来的,比较懒,就不翻译成中文了。希望对你的问题有帮助

全看分页树展 · 主题 跟帖


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河