2011年7月25日星期一

Use grub to boot a windows on a usb device

I'm going to install a windows for test. But somehow I don't have a dvd device to do that.
So it consists of two steps:

1. Get everything ready on usb device:
a) Make a ntfs partition on the usb disk
b) Copy all of the data from installation dvd to the ntfs partition
c) Run the following command with a windows:

bootsect /mbr /nt60 e:

Suppose E is the partition number of the usb disk. You can find the bootsect.exe from the installation dvd.

2. Boot from the usb disk.
I have grub installed on the hard disk already. Once the grub menu is presented, press C into command mode, and input:

rootnoverify (hd2,0)
makeactive
chainloader +1
boot

hd2 is assumed that you have two built-in harddisks, so usb disk is the 3rd one(hd0, hd1, hd2).
And 0 is the first partition on the usb disk.

That's it. The system should boot from the usb disk soon.

2011年7月9日星期六

Dual boot linux and osx on powermac with 2 disks

I have a powermac with osx installed. I don't want to resize the first disk to install linux, so another disk was installed and linux was installed there.

The second disk's partition type can be normal MBR and can be partitioned using fdisk.

The installation is as simple as it can be found on gentoo's handbook.

The tricky part is to install the yaboot.
I decide the install the yahoot on the first disk because it's apple partition type and it actually has enough free space to host a bootstrap patron:

/dev/sda
# type name length base ( size ) system
/dev/sda1 Apple_partition_map Apple 63 @ 1 ( 31.5k) Partition map
/dev/sda2 Apple_Free 262144 @ 64 (128.0M) Free space
/dev/sda3 Apple_HFS Untitled 700585936 @ 262208 (334.1G) HFS

Start mac-fdisk and using "b" to create a bootstrap partition:
The first block can be 64. Then it looks like this:

/dev/sda
# type name length base ( size ) system
/dev/sda1 Apple_partition_map Apple 63 @ 1 ( 31.5k) Partition map
/dev/sda2 Apple_Bootstrap bootstrap 1600 @ 64 (800.0k) NewWorld bootblock
/dev/sda3 Apple_Free 260544 @ 1664 (127.2M) Free space
/dev/sda4 Apple_HFS Untitled 700585936 @ 262208 (334.1G) HFS


The yaboot.conf needs to specify the second disk manually:

* Because the linux is installed on /dev/sdb1, we have to use ofpath to get the device path first:

# ofpath /dev/sdb
/ht@0,f2000000/pci@7/k2-sata-root@c/k2-sata@1/disk@0:

* Then in the yaboot.conf:
boot=/dev/sda2 # This is the bootstrap partition we created
# This is the disk and partition where linux is installed.
device=/ht@0,f2000000/pci@7/k2-sata-root@c/k2-sata@1/disk@0:
partition=1

Then use ybin to install yaboot.

Bingo!

2011年7月8日星期五

Boot the powerpc with usb disk

1. Use Option-Command-o-f boot into open firmware

2. Use devalias to find device list

3. Enumerate the usb disk device number

dev usb0 ls
dev usb1 ls

4. Check whether the disk is readable

dir usb0/disk@1,\\:tbxi
dir usb0/disk@1,\\:tbxi
dir usb0/disk@1:1,\\:tbxi
dir usb0/disk@1:2,\\:tbxi
dir usb0/disk:2,\\:tbxi

5. Boot the system

boot usb0/disk@1,\\:tbxi

See also
http://en.gentoo-wiki.com/wiki/LiveUSB_on_PPC

2008年11月9日星期日

If SO_BINDTODEVICE doesn't work as expected

I made a simple patch to wget so that the out going connection can go through the desired interface to bypass the default route table. But it always fails:


# /dev/shm/wget --bind-interface=ppp0 -S www.google.cn/m
--12:49:18-- http://www.google.cn/m
=> `m'
Resolving www.google.cn... 203.208.35.100, 203.208.35.101
Connecting to www.google.cn|203.208.35.100|:80... ^C


Although the tcpdump indicates the ACK packet is back and the connection should be established:

# tcpdump -i ppp0 -v
tcpdump: listening on ppp0, link-type LINUX_SLL (Linux cooked), capture size 68 bytes
12:49:18.976925 IP (tos 0x0, ttl 64, id 29090, offset 0, flags [DF], proto: TCP (6), length: 60) 10.8.243.46.57503 > 203.208.35.100.http: S 3708069095:3708069095(0) win 5840
12:49:19.649198 IP (tos 0x0, ttl 54, id 45101, offset 0, flags [none], proto: TCP (6), length: 60) 203.208.35.100.http > 10.8.243.46.57503: S 1649371307:1649371307(0) ack 3708069096 win 5672
12:49:23.029140 IP (tos 0x0, ttl 54, id 45102, offset 0, flags [none], proto: TCP (6), length: 60) 203.208.35.100.http > 10.8.243.46.57503: S 1649371307:1649371307(0) ack 3708069096 win 5672


After some research, I realized there is something wrong with the route filter setting. So:

echo 0 > /proc/sys/net/ipv4/conf/ppp0/rp_filter


Now the connection works as desired. For more information, see here

2007年12月28日星期五

Fix the compilation error for gimp-2.4.2 on gentoo-alt@maxos-x86

USE settings:
[ebuild UD] media-gfx/gimp-2.4.2 [9999] USE="jpeg mmx pdf* png sse svg* tiff -aalib (-alsa) (-altivec) -curl -dbus -debug -doc -gnome -gtkhtml -lcms -mng -python -smp -wmf"

Error message:

gcc -O2 -march=pentium-m -msse3 -fomit-frame-pointer -pipe -I/opt/gentoo/usr/include -Wall -Wdeclaration-after-statement -Wmissing-prototypes -Wmissing-declarations -Winit-self -Wpointer-arith -o .libs/xpm xpm.o -framework Carbon ../../libgimp/.libs/libgimpui-2.0.dylib /opt/gentoo/var/tmp/portage/media-gfx/gimp-2.4.2/work/gimp-2.4.2/libgimp/.libs/libgimp-2.0.dylib -L/opt/gentoo/usr/lib /opt/gentoo/var/tmp/portage/media-gfx/gimp-2.4.2/work/gimp-2.4.2/libgimpwidgets/.libs/libgimpwidgets-2.0.dylib /opt/gentoo/var/tmp/portage/media-gfx/gimp-2.4.2/work/gimp-2.4.2/libgimpmodule/.libs/libgimpmodule-2.0.dylib ../../libgimpwidgets/.libs/libgimpwidgets-2.0.dylib ../../libgimpmodule/.libs/libgimpmodule-2.0.dylib ../../libgimp/.libs/libgimp-2.0.dylib /opt/gentoo/var/tmp/portage/media-gfx/gimp-2.4.2/work/gimp-2.4.2/libgimpconfig/.libs/libgimpconfig-2.0.dylib ../../libgimpmath/.libs/libgimpmath-2.0.dylib ../../libgimpconfig/.libs/libgimpconfig-2.0.dylib /opt/gentoo/var/tmp/portage/media-gfx/gimp-2.4.2/work/gimp-2.4.2/libgimpbase/.libs/libgimpbase-2.0.dylib /opt/gentoo/var/tmp/portage/media-gfx/gimp-2.4.2/work/gimp-2.4.2/libgimpcolor/.libs/libgimpcolor-2.0.dylib /opt/gentoo/var/tmp/portage/media-gfx/gimp-2.4.2/work/gimp-2.4.2/libgimpmath/.libs/libgimpmath-2.0.dylib ../../libgimpcolor/.libs/libgimpcolor-2.0.dylib ../../libgimpbase/.libs/libgimpbase-2.0.dylib /opt/gentoo/usr/lib/libgtk-quartz-2.0.dylib /opt/gentoo/usr/lib/libgdk-quartz-2.0.dylib /opt/gentoo/usr/lib/libatk-1.0.dylib /opt/gentoo/usr/lib/libgdk_pixbuf-2.0.dylib /opt/gentoo/usr/lib/libpangocairo-1.0.dylib /opt/gentoo/usr/lib/libpango-1.0.dylib -lm /opt/gentoo/usr/lib/libcairo.dylib /opt/gentoo/usr/lib/libfontconfig.dylib /opt/gentoo/usr/lib/libfreetype.dylib /opt/gentoo/usr/lib/libexpat.dylib /opt/gentoo/usr/lib/libpng12.dylib -lz /opt/gentoo/usr/lib/libgobject-2.0.dylib /opt/gentoo/usr/lib/libgmodule-2.0.dylib /opt/gentoo/usr/lib/libgthread-2.0.dylib /opt/gentoo/usr/lib/libglib-2.0.dylib -L/usr/X11R6/lib -lSM -lICE -lXpm /opt/gentoo/usr/lib/libintl.dylib /opt/gentoo/usr/lib/libiconv.dylib -lc
binutils-config: warning: no GCC found on your system!
ld: warning, duplicate dylib /opt/gentoo/usr/lib/libiconv.2.dylib
ld: cycle in dylib re-exports with /usr/X11R6/lib/libGL.dylib
collect2: ld returned 1 exit status
make: *** [xpm] Error 1

Solution:

edit /var/tmp/portage/media-gfx/gimp-2.4.2/work/gimp-2.4.2/plug-ins/common/Makefile

Append the following flag to xpm_LDADD

-Wl,-dylib_file,/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib:/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib

Thanks to: