-
Notifications
You must be signed in to change notification settings - Fork 2
/
hibuntu
209 lines (173 loc) · 7.46 KB
/
hibuntu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
# Script to install Ubuntu trusty (14.04 LTS) on Hisense C11 chromebook
# All rights reserved by the author
# https://github.com/com-py/Hibuntu
# Credit: based on ChrUnbutu and Arch Linux ARM
# This software is free. Use at your own risk. No warranty of any kind is implied.
#
# If you are seeing this in your web browser, save it as "hibuntu" to the "Downloads" folder.
# Usage: sudo bash ~/Downloads/hibuntu /dev/mmcblk1 [or /dev/sda for USB]
script=hibuntu
hostname=hibuntu
username=me
hwid="`crossystem hwid`"
chromebook_arch="`uname -mi`"
ubuntu_arch="armhf"
echo -e "
****** This software is free. Use at your own risk. No warranty of any kind is implied. ******
Chromebook/Hisense device model is: $hwid; Machine Arch is: $chromebook_arch
Installing Ubuntu 14.04 LTS (trusty, port $ubuntu_arch, aka $hostname) minimal with network manager
Usage for microSD: sudo $script /dev/mmcblk1; for USB: sudo $script /dev/sda
****** Preparation Warning ******
It is assumed that you have prepared the target disk (/dev/mmcblk1=microSD, /dev/sda=USB) by following exactly steps 1--8 from
https://archlinuxarm.org/platforms/armv7/rockchip/hisense-chromebook-c11
If not, abort immediately, prepared the disk, and restart the process.
This installation starts from step 9 for installing Ubuntu instead of Arch Linux."
# check target disk
if [ "$1" != "" ]; then
target_disk=$1
if test $target_disk = "/dev/mmcblk0"; then
echo -e "\nRefusing to install to internal disk $target_disk; exiting\n\a\a"
exit
elif test $target_disk = "/dev/mmcblk1"; then
device="microSD card"
kernp="${target_disk}p1"
rootp="${target_disk}p2"
elif test $target_disk = "/dev/sda"; then
device="USB stick"
kernp="${target_disk}1"
rootp="${target_disk}2"
else
echo -e "\nUnknown target disk $target_disk\n\a\a"
exit
fi
kstr="`cgpt show -i 1 $target_disk | grep kernel`"
dstr="`cgpt show -i 2 $target_disk | grep data`"
if [ "$kstr" = "" ] || [ "$dstr" = "" ]; then
echo -e "\nTarget disk $target_disk not prepared correctly; exiting\n\a\a"
exit
fi
dsiz="`cgpt show -i 2 $target_disk | grep Label | awk '{print $2}'`"
size="`expr $dsiz \* 512 / 1000 / 1000 / 1000`"
else
echo -e "\nNo target disk given; usage: sudo $script /dev/mmcblk1 [or /dev/sda]\n\a\a"
exit
fi
# check ok, ready to install
echo -e "
Your disk checks out OK --- $device $target_disk, usable size ~ $size GB.
Kernel will be installed to $kernp, and OS files to $rootp
All existing data on target disk --- $device $target_disk --- will be erased!\n"
read -p "Ready to Rock... Press [Enter] to continue, Ctrl-C to abort ..."
echo -e "\nStopping powerd to keep display from timing out..."
initctl stop powerd
umount $target_disk*
mkfs.ext4 -F $rootp
cd /tmp
mkdir kern
mkdir kern/boot
mkdir rootfs
mount $rootp rootfs
echo -e "mount $rootp rootfs"
kernname=vmlinux.kpart
# src=http://os.archlinuxarm.org/os/ArchLinuxARM-veyron-latest.tar.gz
# use compatible version 3.14-20
src=https://github.com/com-py/Hibuntu/raw/master/alarm-kernel-3.14-20.tar.gz
echo -e "\nDownloading kernel (5.8 MB), be patient ......"
wget -q $src -O - | tar -vzx -C kern/boot | grep -m 1 $kernname | echo
if [ -f kern/boot/$kernname ]; then
echo -e "...... got it, kernel $kernname found ....\n"
else
echo -e 'Failed kernel download. Please check source and try again; exiting\n'
exit
fi
# flash kernel
echo -e "Flashing kernel to $kernp..."
dd if=kern/boot/$kernname of=$kernp
echo -e "
...kernel flashed successfully.
Up next are 3 stages: ubuntu base, base update, and ubuntu-minimal+network manager
Depending on internet and $device speeds, it can take anywhere from 30 min to 1 hour+.
So sit back, relax, and ignore harmless Locale warnings.\n"
read -p "Ready to proceed; Press [Enter] to continue ..."
echo -e "Downloading Ubuntu 14.04 $ubuntu_arch port..."
tar_file="http://cdimage.ubuntu.com/ubuntu-base/releases/14.04/release/ubuntu-base-14.04.4-core-armhf.tar.gz"
echo -e "Writing base OS files to $rootp (57 MB)..."
wget -O - $tar_file | tar xzvp -C rootfs
echo -e "...base OS files done...\n"
# needed for Hisense C11, may not be necessary for other models
echo -e "Downloading mwifiex modules ..."
wget https://goo.gl/xANhPV -O wifimodules.tar.gz
# install ubuntu-minimal by chroot
mount -o bind /proc rootfs/proc
mount -o bind /dev rootfs/dev
mount -o bind /dev/pts rootfs/dev/pts
mount -o bind /sys rootfs/sys
cp /etc/resolv.conf rootfs/etc/
echo -e "$hostname" > rootfs/etc/hostname
echo -e "\n127.0.1.1 $hostname" >> rootfs/etc/hosts
add_apt_repository_package='software-properties-common'
# prepare shell script
echo -e "apt-get -y update
apt-get -y dist-upgrade
apt-get -y install ubuntu-minimal
apt-get -y install network-manager
apt-get -y install wget
apt-get -y install $add_apt_repository_package
add-apt-repository main
add-apt-repository universe
add-apt-repository restricted
add-apt-repository multiverse
apt-get update
if [ -f /usr/lib/lightdm/lightdm-set-defaults ]; then
/usr/lib/lightdm/lightdm-set-defaults --autologin $username
fi
useradd -m $username -s /bin/bash
echo $username:root | chpasswd
adduser $username adm
adduser $username sudo" > rootfs/hibuntu.sh
chmod a+x rootfs/hibuntu.sh
echo -e "\n Starting ubuntu-minimal install, get a cup of tea, will be a while...\n"
chroot rootfs /bin/bash -c /hibuntu.sh
echo -e "Wait 5 seconds..."
sleep 5
rm rootfs/hibuntu.sh
# copy modules
syskern=`uname -r`
mkdir -p rootfs/lib/modules/$syskern/
cp -ar /lib/modules/$syskern/* rootfs/lib/modules/$syskern/
if [ ! -d rootfs/lib/firmware/ ]; then
mkdir rootfs/lib/firmware/
fi
cp -ar /lib/firmware/* rootfs/lib/firmware/
tar xf wifimodules.tar.gz -C rootfs/
# change default brightness, insert before last line
sed -i '$i echo 50 > /sys/devices/backlight.20/backlight/backlight.20/brightness' rootfs/etc/rc.local
# load wireless modules; order important
sed -i '$i insmod /lib/modules/3.14.0-20-ARCH/mwifiex/cfg80211.ko' rootfs/etc/rc.local
sed -i '$i insmod /lib/modules/3.14.0-20-ARCH/mwifiex/mwifiex.ko' rootfs/etc/rc.local
sed -i '$i insmod /lib/modules/3.14.0-20-ARCH/mwifiex/mwifiex_sdio.ko' rootfs/etc/rc.local
echo -e "
Congratulations! Installation successful
After reboot, press Ctrl-U to boot from the $device.
If it beeps, just power off and on again. Make sure your $device is the only one plugged in.
Username: $username
Password: root
To set up wireless after login, use these commands to scan, connect, and check connections:
__________________________________
========================== Please jot this down for reference =========================
| nmcli dev wifi |
| sudo nmcli dev wifi con \"your_net ssid\" password \"your_net_password\" name \"My wifi\" |
| nmcli dev status |
=========================================================================================
Once you have a connection, you can add more stuff.
For example, to add the xfce desktop and assorted programs including firefox, do:
sudo apt-get install openbox xubuntu-desktop
If booting from the $device fails (black screen), hold down the power button
for 10 seconds to power off, then turn it back on to login to Chrome OS.
Check for latest update at https://github.com/com-py/Hibuntu
Ready to start Hibuntu!
"
umount rootfs
sync
read -p "Press [Enter] to reboot; then wait for the $device to unmount..."
reboot