10
24
2010
4

把Parted Magic装到移动硬盘

首先,不知道Parted Magic为何物的童鞋请先移步这里

之前折腾了Gparted live,然后看到了muzuiget童鞋的留言,决定有时间还是折腾下。首先去官网,结果官网说

As of Parted Magic version 5.3 the USB zip has been discontinued. We are only supporting Unetbootin as the method for booting Parted Magic from a USB drive.

Note: If you still want to do it manually, extract the files from the ISO image and execute the syslinux commands. If you know what you are doing this shouldn't be an issue.

好吧,我在看到第一段,在失望之余,“note”到了后面那段。

fuseiso ~/dl/pmagic-5.5.iso pm

我不喜欢需要根用户权限的mount,所以有一天在新立得里翻到了这个fuseiso,现在用上了。

里边就两个目录,boot和pmagic。pmagic比较简单,先说说它。

它下面也就三项,内核bzImage,initrd文件initramfs,和一个可以用来自定义其模块的目录pmodules,目前只包含pmagic-5.5.sqfs,file之可以知道它是一个Squashfs filesystem。

boot下东西有点多,还好我需要的很少,就是boot/isolinux/isolinux.cfg这个isolinux的配置文件了,里面有需要传给内核的参数,有好几个选项,基本上是这样子的:

LINUX /pmagic/bzImage
INITRD /pmagic/initramfs
APPEND edd=off noapic load_ramdisk=1 prompt_ramdisk=0 rw vga=788 loglevel=0 max_loop=256

APPEND那行就是内核的参数了。于是,grub2的参数应该这么写:

menuentry "Parted Magic (中文)" {
	set root="(hd1,1)"
	echo "Loading kernel..."
	linux /boot/pmagic/bzImage edd=off noapic load_ramdisk=1 prompt_ramdisk=0 rw vga=791 loglevel=0 max_loop=256 keymap=us zh_CN
	echo "Loading initrd..."
	initrd /boot/pmagic/initramfs
}

vga参数我自然要改下的,呵呵。

但是——

内核加载完毕之后它就告诉我找不到pmagic-5.5.sqfs文件……看来需要把它放到分区的/pmagic/pmodules下才行啊。可是我又不是做LiveUSB,是移动硬盘耶,不可能随随便便就把整个分区弄乱的。

于是——

file一下那个initramfs可知它是gzip压缩过的。

zcat initramfs > ../../initrd

然后继续file之,cpio文件。那就继续解包吧:

cat initrd|cpio -i

其实两步是可以一起做的。但没有file以及man cpio之前谁知道呢。

然后我很惊奇地看到一个名为init的可执行文件躺在当前目录下!我都没file,直接把它扔给Vim了。接下来就是看shell脚本了。

find_pmagic () {

   if [ ! -e /test_mnt/${directory}/pmagic/pmodules/pmagic-$VERSION.sqfs ]; then
      umount /test_mnt &> /dev/null
      return
   fi

关键是${directory}变量。继续寻找。。。

for i in $(cat /proc/cmdline); do
   case $i in
      directory=*)     directory=$(get_opt $i) ;;
      iso_location=*)  iso_location=$(get_opt $i)  ;;
      iso_filename=*)  ISO_VERSION=$(get_opt $i) ;;
      root=*)          root=$(get_opt $i)  ;;
      label=*)         label=$(get_opt $i)  ;;
      uuid=*)          uuid=$(get_opt $i) ;;
   esac
done

OK,原来是内核参数,于是在linux那行后面再加上directory=other,重启OK!

| Theme: Aeros 2.0 by TheBuckmaker.com