-
-
Save vvuk/4986933 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# | |
# Version 0.2, for Ubuntu 13.04 (Raring) | |
# | |
# Based on Chrubuntu 34v87 script | |
BASE_IMAGE_FILE="http://mirrors.med.harvard.edu/ubuntu-cdimage/lubuntu/releases/13.04/release/lubuntu-13.04-preinstalled-desktop-armhf+ac100.tar.gz" | |
# fw_type will always be developer for Mario. | |
# Alex and ZGB need the developer BIOS installed though. | |
fw_type="`crossystem mainfw_type`" | |
if [ ! "$fw_type" = "developer" ] | |
then | |
echo -e "\nYou're Chromebook is not running a developer BIOS!" | |
echo -e "You need to run:" | |
echo -e "" | |
echo -e "sudo chromeos-firmwareupdate --mode=todev" | |
echo -e "" | |
echo -e "and then re-run this script." | |
return | |
else | |
echo -e "\nOh good. You're running a developer BIOS...\n" | |
fi | |
# hwid lets us know if this is a Mario (Cr-48), Alex (Samsung Series 5), ZGB (Acer), etc | |
hwid="`crossystem hwid`" | |
echo -e "Chome OS model is: $hwid\n" | |
chromebook_arch="`uname -m`" | |
if [ ! "$chromebook_arch" = "armv7l" ] | |
then | |
echo -e "This version of Chrome OS is for the ARM-based Chromebooks only\n" | |
exit 1 | |
else | |
echo -e "and you're running on a ARM-based Chromebook, awesome!\n" | |
fi | |
read -p "Press [Enter] to continue..." | |
powerd_status="`initctl status powerd`" | |
if [ ! "$powerd_status" = "powerd stop/waiting" ] | |
then | |
echo -e "Stopping powerd to keep display from timing out..." | |
initctl stop powerd | |
fi | |
powerm_status="`initctl status powerm`" | |
if [ ! "$powerm_status" = "powerm stop/waiting" ] | |
then | |
echo -e "Stopping powerm to keep display from timing out..." | |
initctl stop powerm | |
fi | |
setterm -blank 0 | |
# Figure out what the target disk is | |
if [ "$1" != "" ]; then | |
target_disk=$1 | |
echo "Got ${target_disk} as target drive" | |
echo "" | |
echo "WARNING! All data on this device will be wiped out! Continue at your own risk!" | |
echo "" | |
if [ "$target_disk" = "/dev/mmcblk0" ]; then | |
echo 'Cowardly refusing to install to /dev/mmcblk0 in this mode; run with no args instead' | |
echo 'to properly partition your disk!' | |
exit 1 | |
fi | |
read -p "Press [Enter] to install ChrUbuntu on ${target_disk} or CTRL+C to quit" | |
ext_size="`blockdev --getsz ${target_disk}`" | |
aroot_size=$((ext_size - 65600 - 33)) | |
parted --script ${target_disk} "mktable gpt" | |
cgpt create ${target_disk} | |
# always use 6 and 7 for sanity | |
cgpt add -i 6 -b 64 -s 32768 -S 1 -P 5 -l KERN-A -t "kernel" ${target_disk} | |
cgpt add -i 7 -b 65600 -s $aroot_size -l ROOT-A -t "rootfs" ${target_disk} | |
sync | |
blockdev --rereadpt ${target_disk} | |
partprobe ${target_disk} | |
crossystem dev_boot_usb=1 | |
else | |
target_disk="`rootdev -d -s`" | |
# Do partitioning (if we haven't already) | |
ckern_size="`cgpt show -i 6 -n -s -q ${target_disk}`" | |
croot_size="`cgpt show -i 7 -n -s -q ${target_disk}`" | |
state_size="`cgpt show -i 1 -n -s -q ${target_disk}`" | |
max_ubuntu_size=$(($state_size/1024/1024/2)) | |
rec_ubuntu_size=$(($max_ubuntu_size - 1)) | |
# If KERN-C and ROOT-C are one, we partition, otherwise assume they're what they need to be... | |
if [ "$ckern_size" = "1" -o "$croot_size" = "1" ] | |
then | |
while : | |
do | |
read -p "Enter the size in gigabytes you want to reserve for Ubuntu. Acceptable range is 5 to $max_ubuntu_size but $rec_ubuntu_size is the recommended maximum: " ubuntu_size | |
if [ ! $ubuntu_size -ne 0 2>/dev/null ] | |
then | |
echo -e "\n\nNumbers only please...\n\n" | |
continue | |
fi | |
if [ $ubuntu_size -lt 5 -o $ubuntu_size -gt $max_ubuntu_size ] | |
then | |
echo -e "\n\nThat number is out of range. Enter a number 5 through $max_ubuntu_size\n\n" | |
continue | |
fi | |
break | |
done | |
# We've got our size in GB for ROOT-C so do the math... | |
#calculate sector size for rootc | |
rootc_size=$(($ubuntu_size*1024*1024*2)) | |
#kernc is always 16mb | |
kernc_size=32768 | |
#new stateful size with rootc and kernc subtracted from original | |
stateful_size=$(($state_size - $rootc_size - $kernc_size)) | |
#start stateful at the same spot it currently starts at | |
stateful_start="`cgpt show -i 1 -n -b -q ${target_disk}`" | |
#start kernc at stateful start plus stateful size | |
kernc_start=$(($stateful_start + $stateful_size)) | |
#start rootc at kernc start plus kernc size | |
rootc_start=$(($kernc_start + $kernc_size)) | |
#Do the real work | |
echo -e "\n\nModifying partition table to make room for Ubuntu." | |
echo -e "Your Chromebook will reboot, wipe your data and then" | |
echo -e "you should re-run this script..." | |
umount /mnt/stateful_partition | |
# stateful first | |
cgpt add -i 1 -b $stateful_start -s $stateful_size -l STATE ${target_disk} | |
# now kernc | |
cgpt add -i 6 -b $kernc_start -s $kernc_size -l KERN-C ${target_disk} | |
# finally rootc | |
cgpt add -i 7 -b $rootc_start -s $rootc_size -l ROOT-C ${target_disk} | |
reboot | |
exit | |
fi | |
fi | |
if [[ "${target_disk}" =~ "mmcblk" ]] | |
then | |
target_rootfs="${target_disk}p7" | |
target_kern="${target_disk}p6" | |
else | |
target_rootfs="${target_disk}7" | |
target_kern="${target_disk}6" | |
fi | |
echo "Target Kernel Partition: $target_kern Target Root FS: ${target_rootfs}" | |
# try mounting a USB / SD Card if it's there... | |
if [ ! -d /tmp/usb_files ]; then | |
mkdir /tmp/usb_files | |
fi | |
echo "Looking for USB or SD media with image..." | |
if [ -f /tmp/usb_files/cb-ubuntu ] ; then | |
echo "Already mounted, great." | |
else | |
echo "Trying /dev/sda... (USB)" | |
mount /dev/sda /tmp/usb_files > /dev/null 2>&1 | |
if [ $? -ne 0 ] ; then | |
echo "Trying /dev/sda1... (USB)" | |
mount /dev/sda1 /tmp/usb_files > /dev/null 2>&1 | |
if [ $? -ne 0 ] ; then | |
echo "Trying /dev/mmcblk1p1... (SD)" | |
mount /dev/mmcblk1p1 /tmp/usb_files > /dev/null 2>&1 | |
if [ $? -ne 0 ] ; then | |
echo "No USB or SD media found, will download." | |
fi | |
fi | |
fi | |
fi | |
if [ -z "$IMAGE_FILE" ]; then | |
IMAGE_FILE="$BASE_IMAGE_FILE" | |
fi | |
if [[ "${IMAGE_FILE}" =~ "http" ]]; then | |
base_image_file="`basename \"${IMAGE_FILE}\"`" | |
if [ -f "/tmp/usb_files/$base_image_file" ]; then | |
echo "Using /tmp/usb_files/$base_image_file instead of downloading" | |
untar_file="/tmp/usb_files/$base_image_file" | |
else | |
echo "Downloading $IMAGE_FILE..." | |
untar_file="/mnt/stateful_partition/$base_image_file" | |
wget -c -O "/mnt/stateful_partition/$base_image_file" "$IMAGE_FILE" | |
if [ $? -ne 0 ] ; then | |
echo "Download failed!" | |
exit 1 | |
fi | |
fi | |
else | |
if [ -f "/tmp/usb_files/$IMAGE_FILE" ]; then | |
untar_file="/tmp/usb_files/$IMAGE_FILE" | |
echo "Using ${untar_file}" | |
elif [ -f "$IMAGE_FILE" ]; then | |
untar_file="$IMAGE_FILE" | |
echo "Using ${untar_file}" | |
else | |
echo "File '${IMAGE_FILE}' not found, either on USB device or as absolute path!" | |
exit 1 | |
fi | |
fi | |
# our mount target | |
if [ ! -d /tmp/ubuntu ]; then | |
mkdir /tmp/ubuntu | |
fi | |
if [[ -z "$SKIP_UNTAR" ]]; then | |
echo "Creating filesystem on ${target_rootfs}..." | |
mkfs.ext4 -j ${target_rootfs} && mount ${target_rootfs} /tmp/ubuntu | |
if [ $? -ne 0 ] ; then | |
echo 'Failed to create and/or mount filesystem!' | |
exit 1 | |
fi | |
if [[ "$untar_file" =~ "tgz" || "$untar_file" =~ ".gz" ]] ; then | |
tar xvzCf /tmp/ubuntu "$untar_file" | |
elif [[ "$untar_file" =~ "bz2" ]] ; then | |
tar xvjCf /tmp/ubuntu "$untar_file" | |
elif [[ "$untar_file" =~ "xz" ]] ; then | |
tar xvJCf /tmp/ubuntu "$untar_file" | |
else | |
echo "Hmm... not sure how to untar your file" | |
exit 1 | |
fi | |
else | |
if [ -d /tmp/ubuntu/lost+found ] ; then | |
echo "Skipping untar, /tmp/ubuntu already mounted" | |
else | |
echo "Skipping untar, just mounting ${target_rootfs}..." | |
mount ${target_rootfs} /tmp/ubuntu | |
if [ $? -ne 0 ] ; then | |
echo 'Failed to mount filesystem!' | |
exit 1 | |
fi | |
fi | |
fi | |
# Let's get some firmware in place | |
cp /lib/firmware/mrvl/sd8797_uapsta.bin /tmp/ubuntu/lib/firmware/mrvl | |
cp /lib/firmware/mfc_fw.bin /tmp/ubuntu/lib/firmware | |
# Create the setup script in /tmp/setup-script on the ubuntu partition | |
cat > /tmp/ubuntu/tmp/setup-script <<EOF | |
rm -f /tmp/setup-script-ok | |
# fix up /etc/shadow so root can log in | |
passwd -d root | |
echo "nameserver 8.8.8.8" > /etc/resolv.conf | |
# update-initramfs will need this | |
mount -t devpts devpts /dev/pts | |
mount -t proc proc /proc | |
add-apt-repository -y ppa:chromebook-arm/ppa | |
apt-get update | |
apt-get -y --force-yes remove flash-kernel linux-ac100 | |
apt-get -y --force-yes install cgpt chromebook-s3-default-settings vboot-utils | |
apt-get -y --force-yes install linux-tools-3.4.0-5 | |
# we need this because update-initrd will still run, even though | |
# it doesn't need to and the image package doesn't have an initrd | |
touch /boot/initrd.img-3.4.0-5-chromebook | |
# --no-install-recommends is there because the image incorrectly | |
# recommends flash-kernel, which we don't want | |
apt-get -y --force-yes install --no-install-recommends linux-image-chromebook | |
apt-get -y --force-yes install xserver-xorg-video-armsoc | |
apt-get -y --force-yes install chromium-mali-opengles || echo Failed to install chromium-mali-opengles, this is ok | |
# clean up | |
umount /dev/pts | |
umount /proc | |
if [ ! -d /etc/X11/xorg.conf.d ] ; then mkdir /etc/X11/xorg.conf.d ; fi | |
cat > /etc/X11/xorg.conf.d/exynos5.conf <<EOZ | |
Section "Device" | |
Identifier "Mali FBDEV" | |
Driver "armsoc" | |
Option "fbdev" "/dev/fb0" | |
Option "Fimg2DExa" "false" | |
Option "DRI2" "true" | |
Option "DRI2_PAGE_FLIP" "false" | |
Option "DRI2_WAIT_VSYNC" "true" | |
# Option "Fimg2DExaSolid" "false" | |
# Option "Fimg2DExaCopy" "false" | |
# Option "Fimg2DExaComposite" "false" | |
Option "SWcursorLCD" "false" | |
EndSection | |
Section "Screen" | |
Identifier "DefaultScreen" | |
Device "Mali FBDEV" | |
DefaultDepth 24 | |
EndSection | |
Section "InputClass" | |
Identifier "touchpad" | |
MatchIsTouchpad "on" | |
Option "FingerHigh" "5" | |
Option "FingerLow" "5" | |
EndSection | |
Section "InputClass" | |
Identifier "touchpad catchall" | |
Driver "synaptics" | |
MatchIsTouchpad "on" | |
MatchDevicePath "/dev/input/event*" | |
Option "TapButton1" "1" | |
Option "TapButton2" "2" | |
Option "TapButton3" "3" | |
EndSection | |
EOZ | |
echo ===== successfully executed setup script ===== | |
touch /tmp/setup-script-ok | |
EOF | |
# run the setup script | |
echo ===== running chroot setup script ===== | |
chroot /tmp/ubuntu bash /tmp/setup-script | |
echo ===== setting up kernel ===== | |
# now set up the kernel | |
echo "console=tty1 printk.time=1 nosplash rootwait root=${target_rootfs} rw rootfstype=ext4" > /tmp/ubuntu/boot/cmdline | |
vbutil_kernel --pack /tmp/ubuntu/boot/chronos-kernel-image --keyblock /usr/share/vboot/devkeys/kernel.keyblock --signprivate /usr/share/vboot/devkeys/kernel_data_key.vbprivk --config /tmp/ubuntu/boot/cmdline --vmlinuz /tmp/ubuntu/boot/vmlinuz-3.4.0-5-chromebook --version 1 --arch arm | |
dd if=/tmp/ubuntu/boot/chronos-kernel-image of=${target_kern} bs=512 | |
if [ -f /tmp/ubuntu/tmp/setup-script-ok ] ; then | |
success=1 | |
else | |
success=0 | |
fi | |
# Make the scripts -- one on the ubuntu partition, and one in local /tmp | |
echo "cgpt add -S 0 -T 1 -P 12 -i 6 ${target_disk}" > /tmp/ubuntu/bin/chromebook-boot-ubuntu | |
echo "cgpt add -S 1 -T 1 -P 12 -i 6 ${target_disk}" > /tmp/ubuntu/bin/chromebook-boot-ubuntu-always | |
chmod +x /tmp/ubuntu/bin/chromebook-boot-ubuntu* | |
cp /tmp/ubuntu/bin/chromebook-boot-ubuntu /usr/local | |
cp /tmp/ubuntu/bin/chromebook-boot-ubuntu-always /usr/local | |
# Unmount ubuntu | |
umount /tmp/ubuntu | |
echo "==========================" | |
if [ $success -ne 1 ] ; then | |
echo 'Something went wrong while executing the chroot setup script!' | |
echo 'Look above for more clues.' | |
exit 1 | |
fi | |
# finally make it bootable, but just once (-S 0: flagged as not successful, -T 1: one try) | |
cgpt add -S 0 -T 1 -P 12 -i 6 ${target_disk} | |
echo "Done -- reboot to enter Ubuntu (not set as default, only once)." | |
echo "In Ubuntu, the root password is blank -- please change it and create a user" | |
echo "To set Ubuntu to boot again once, run" | |
echo " /usr/local/chromebook-boot-ubuntu" | |
echo "To always boot Ubuntu (after testing), run" | |
echo " /usr/local/chromebook-boot-ubuntu-always" | |
echo "These scripts are also in /bin on the Ubuntu partition." |
this scripted failed when i want to install the image to mmcblk1
So I am looking to install ubuntu on my samsung 3 chomebook. How do i run this from the console?
I tried it last might and it had a couple of glitches.
One minor issue that I had was the SD card was already formated and auto mounted by the ChromeOS. I needed to manually unmount the partitions (trivial), but it would be nice to automagically do this in the script.
I also got an error on this because it could not find the opengles package:
apt-get -y install xserver-xorg-video-armsoc chromium-mali-opengles
It looks like the chromiuim-mali-opengles package has been removed - but there are still references to it.
Also - I had to manually do some of the commands at the bottom of the setup-script because the "apt-get update" did not pull all of the updates.
Anyway - I was able to boot the system without it after installation.
I am not particularly happy with the default Window manager - looking for something else.
But in general this is pretty close to working.
how can i run this script on ubuntu, sorry if this an obvious questions but im new with this.
thanks for the great info. i believe i installed on my samsung chromebook xe303. i get a message
Ubuntu Raring Ringtail (development branch) localhost.localdomain tty1
it then asks for localhost login. that's where i get stuck. says above that password is blank but for the life of me, i cannot figure out user id. tried admin, user, root, sudo, blank, guest...
what am i missing? any help would be much appreciated.
on further inspection i see the script returned a bunch of error messages on the passwd and all the apt-get; then an error reading kernel file. i suspect there may be a problem somewhere from 202 or lower. again any tips most welcome.
This didn't completely work for me. Upon reboot, I'm greeted with a "plymouthd" error that other people seem to be getting here and elsewhere:
http://virtuallyhyper.com/2013/03/update-chrubuntu-12-04-to-13-04-on-the-samsung-chromebook/
https://bugs.launchpad.net/ubuntu/+source/plymouth/+bug/1082742
Anyone have thoughts for a workaround?
Thanks for your great script. And I have a few question.
Q1:In line 168, it seem that the script should check USB flash drive for local image. If I had already downloaded the img file from cdimage.ubuntu.com, what directory should I place in the USB flash drive? In root directory should be OK? and what file name should I rename this image file?
Q2:In the post of 'smithwd', there was a faild package, how can we fix it?
Q3:Should this script be available for Samsung Chromebook 2 (both 11.6" and 13.3")? It seems that they have a different processor with Samsung CB 1(4-cores A-15 plus 4-cores A-7, 2-cores A15).
Thank you very for answering.
Cool script, very easy to set up. The touch-pad seems a bit erratic though, sometimes the cursor does not move and other times it clicks when trying to just move cursor.
Any thoughts?
Cheers