2016年12月3日 星期六

[Gentoo] 在 Libvirt 上跑 Chromium OS

先裝 repo [1]


$ git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
$ export PATH=`pwd`/depot_tools:"$PATH"


然後安裝時候需要 sudo,我用 gentoo 沒在用 sudo 所以還要另外裝一下 ...

$ emerge sudo


然後下載 chromium source code

$ mkdir -p ${HOME}/chromiumos
$ cd ${HOME}/chromiumos
$ repo init -u https://chromium.googlesource.com/chromiumos/manifest.git --repo-url https://chromium.googlesource.com/external/repo.git
$ repo sync -j4


開始編譯 [2]


$ export BOARD=amd64-generic
$ cd ${HOME}/chromiumos/src/script
$ ./build_packages --board=${BOARD}
$ ./build_image --board=${BOARD} --noenable_rootfs_verification dev
$ ./image_to_vm.sh --board=${BOARD}

然後就可以看到編好的 vm 檔

$ ls -l ../build/images/amd64-generic/latest/chromiumos_qemu_image.bin
$ file ../build/images/amd64-generic/latest/chromiumos_qemu_image.bin
../build/images/amd64-generic/latest/chromiumos_qemu_image.bin: DOS/MBR boot sector; partition 1 : ID=0xee, start-CHS (0x0,0,2), end-CHS (0x3ff,255,63), startsector 1, 14995391 sectors


用 virt-install 來 import [4]

$ virt-install --virt-type kvm \
               --name chromium \
               --ram 2048 \
               --disk path=/home/mkfsn/chromiumos/src/build/images/amd64-generic/latest/chromiumos_qemu_image.bin \
               --network bridge=br0 \
               --graphics vnc,listen=192.168.0.159 \
               --noautoconsole \
               --os-type=linux \
               --import



因為 os-variant 裡面沒一個適合的,所以我就乾脆不給 XP

打完收工

$ virsh list
 Id    Name                           State
----------------------------------------------------
 4     chromium                       running



Reference
  1. https://www.chromium.org/developers/how-tos/install-depot-tools
  2. https://www.chromium.org/chromium-os/developer-guide
  3. https://www.chromium.org/chromium-os/how-tos-and-troubleshooting/running-chromeos-image-under-virtual-machines
  4. https://www.itfromallangles.com/2011/03/kvm-guests-using-virt-install-to-import-an-existing-disk-image/

沒有留言:

張貼留言