From Fedora Project Wiki
Line 223: Line 223:


* Graphics not working. The ChromeOS kernel usually have a working frame buffer, verify your X11 configs in /etc/X11/. But if you have more serious problems or if you simply prefer console mode, you can repack your kernel with cmdline option 'systemd.unit=multi-user.target' or from inside Fedora by 'systemctl set-default multi-user.target
* Graphics not working. The ChromeOS kernel usually have a working frame buffer, verify your X11 configs in /etc/X11/. But if you have more serious problems or if you simply prefer console mode, you can repack your kernel with cmdline option 'systemd.unit=multi-user.target' or from inside Fedora by 'systemctl set-default multi-user.target
* SElinux, Auditing, control groups, name spaces... systemd is not happy when modern Linux features are disabled, as they are in the ChromeOS kernels.


===Mainline Kernel===
===Mainline Kernel===

Revision as of 22:31, 23 October 2015

There's currently a number of ARM (currently all are ARMv7) based Chromebooks base on a few specific SoCs.

They are:

Samsung Exynos:

  • Snow (Exynos 5240)
  • CB2 (Exynos 5800, 1080p, microSD)

NVIDIA Tegra K1:

  • Acer nyan-big (1080p HD version, and non-HD variant)
  • HP nyan-blaze (discontinued)

Rockchips:

  • Asus flip


Preparing Fedora

Start by downloading your Fedora, here we use the XFCE variant, but you can choose another at the download site:

http://download.fedoraproject.org/pub/fedora/linux/releases/22/Images/armhfp/

$ cd /tmp

$ wget http://download.fedoraproject.org/pub/fedora/linux/releases/22/Images/armhfp/Fedora-Xfce-armhfp-22-3-sda.raw.xz

$ unxz -v Fedora-Xfce-armhfp-22-3-sda.raw.xz


Next you mount the raw disk image, and extract the rootfs. (Note the loop devices in the output)

$ sudo kpartx -av /tmp/Fedora-Xfce-armhfp-22-3-sda.raw

$ sudo dd if=/dev/mapper/loop0p3 of=/tmp/Fedora-22-Xfce-rootfs.ext4 conv=fsync

$ sudo kpartx -d /tmp/Fedora-Xfce-armhfp-22-3-sda.raw


At this point you may optionally shrink ext4 rootfs. (It will be expanded in a later step)

$ sudo e2fsck -f /tmp/Fedora-22-Xfce-rootfs.ext4

$ sudo resize2fs -fM /tmp/Fedora-22-Xfce-rootfs.ext4


Label the rootfs, and apply a new UUID

$ UUID=$(uuidgen)

$ LABEL='ROOTFS'

$ sudo tune2fs -U "$UUID" -L "$LABEL" /tmp/Fedora-22-Xfce-rootfs.ext4


Create the partitions

$ truncate --size=7GiB /tmp/chromebook-xfce.raw

$ sgdisk -a 8192 -n 1:0:+30M -t 1:7F00 -c 1:"KERN-A" -A 1:=:0x011F000000000000 \
                 -n 2:0:+30M -t 2:7F00 -c 2:"KERN-B" -A 2:=:0x011A000000000000 \
                 -n 3:0:+30M -t 3:7F00 -c 3:"KERN-C" -A 3:=:0x0115000000000000 \
                 -n 4:0:+1G  -t 4:8300 -c 4:"BOOT"   \
                 -n 5:0:+1G  -t 5:8200 -c 5:"SWAP"   \
                 -n 6:0:0    -t 6:8300 -c 6:"ROOTFS" /tmp/chromebook-xfce.raw


Write the Xfce rootfs to the partition.

$ sudo kpartx -avg /tmp/chromebook-xfce.raw

$ dd if=/tmp/Fedora-22-Xfce-rootfs.ext4 of=/dev/mapper/loop0p6 bs=2M conv=fsync

$ sudo resize2fs -f /dev/mapper/loop0p6


Setup the swap device

$ UUID_SWAP=$(uuidgen)
$ sudo swapon -v -U "$UUID_SWAP" -L 'SWAP' /dev/mapper/loop0p5


Setup the Fedora boot partition

$ UUID_BOOT=$(uuidgen)
$ sudo mkfs.ext4 -m0 -U "$UUID_BOOT" -L 'BOOT' /dev/mapper/loop0p4


Mount the filesystems

$ sudo mount /dev/mapper/loop0p6 /mnt

$ sudo mount /dev/mapper/loop0p4 /mnt/boot

Configure the filesystem table

cat <<-EOF > /mnt/etc/fstab
UUID=$UUID / ext4 defaults 1 1
UUID=$UUID_SWAP swap swap defaults 0 0
UUID=$UUID_BOOT /boot ext4 defaults 0 2
EOF


Optionally chroot into the mounted rootfs. You may want to make configuration changes, or install packages. (Note: this requires you be operating from an ARMv7 system already)

$ sudo chroot /mnt bash

# dnf download vboot-utils

# exit


Dis-mount the filesystems and teardown the loop device

$ sudo umount --recursive /mnt

$ sudo kpartx -dvg /tmp/chromebook-xfce.raw


Write the Fedora image to your SDcard (Note: for example purpose the fictional sdcard device is "/dev/sdz", and it will most certainly be different for you)

$ sudo dd if=/tmp/chromebook-xfce.raw of=/dev/sdz bs=2M conv=fsync

$ sudo partprobe /dev/sdz


Move the GPT backup header to the end of storage, expand the ROOTFS partition, and grow the rootfs within.

$ sgdisk -a8192 -e -d6 -n6:0:0 -t6:8300 -c6:'ROOTFS' -p /dev/sdz

$ resize2fs /dev/sdz6


From within ChromeOS

  • Enable developer mode by simultaneously pressing 'POWER + REFRESH + ESC'
  • In the boot recovery screen press 'CTRL + D'
  • After an arbitrary amount of time passes you will reboot into developer mode
  • To boot into ChromeOS, Press 'CTRL + D'
  • [Optionally, wait for ChromeOS to update it's kernel before proceeding.]
  • Once you have login to ChromeOS, open the terminal by pressing 'CTRL + ALT + T'
  • From the terminal, get root by typing 'shell' and then 'sudo -i'
  • Insert the prepared Fedora sdcard into the chromebook.


Re-pack the ChromeOS kernel

# cd /media/removable/boot/

# dd if=/dev/mmcblk0p2 of=/tmp/kern-a.blob conv=fsync

# eval $(blkid -o export /dev/mmcblk1p6)

# cat <<-EOF > /media/removable/boot/kcmdline
console=tty1 debug verbose root=PARTUUID=${PARTUUID} rootwait rw lsm.module_locking=0
EOF

# dev_make_keypair fedora

# vbutil_kernel --oldblob     /tmp/kern-a.blob \
                --repack      /media/removable/boot/chromeos-kernel.img \
                --config      /media/removable/boot/kcmdline \
                --keyblock    /media/removable/boot/fedora.keyblock \
                --signprivate /media/removable/boot/fedora.vbprivk \
                --arch arm --version 1

# dd if=/media/removable/boot/chromeos-kernel.img of=/dev/mmcblk1p1 

Copy the firmware and kernel modules to the sdcard

# cp -r /lib/modules/*  /media/removable/rootfs/lib/modules/.

# cp -r /lib/firmware/* /media/removable/rootfs/lib/firmware/.

Enable USB boot

# crossystem dev_boot_usb=1

Booting Fedora

  • At the boot screen press 'CTRL + U'
  • The kernel partition with the highest priority will boot.
  • Using the ChromeOS kernel with Fedora user-space can sometimes be challenging, you may encounter problems.
  • If you're lucky you will boot into Xfce, and have wifi


Known issues

  • The output of lsmod is empty, no kernel modules loaded. Usually indicates the ChromeOS kernel booted without 'lsm.module_locking=0' You can verify the kernel cmdline, or rebuild the kernel without CONFIG_CHROMEOS_SECUIRTY.
  • systemd emergency mode, and /boot not mounted. A byproduct of some weird kernel security in the ChromeOS kernel. Simply 'mount /dev/mmcblk1p4 /boot' and exit the emergency shell.
  • wifi not working. Did you copy over the ChromeOS modules and firmware correctly? The Marvel mwifiex driver loads a firmware blob.
  • Graphics not working. The ChromeOS kernel usually have a working frame buffer, verify your X11 configs in /etc/X11/. But if you have more serious problems or if you simply prefer console mode, you can repack your kernel with cmdline option 'systemd.unit=multi-user.target' or from inside Fedora by 'systemctl set-default multi-user.target
  • SElinux, Auditing, control groups, name spaces... systemd is not happy when modern Linux features are disabled, as they are in the ChromeOS kernels.

Mainline Kernel

(to be continued)