Skip to content

Commit a92c3e4

Browse files
author
alesimula
committed
Chromefy images on chromiumOS/chromeOS too (needs bug solving)
1 parent 8f51a3c commit a92c3e4

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

chromefy.sh

+26-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#Script to install ChromeOS on top of ChromiumOS
44
#If installing to a system partition, must be ran from ChromiumOS Live USB (otherwise, any Linux distro is fine)
5-
#You must install ChromiumOS on your Hard Drive before running this script
5+
#If installing to a system partition, You must install ChromiumOS on your Hard Drive before running this script
66

77
#Parameters:
88
#1 - ChromiumOS image or (HDD) system partition (ex: /dev/sda3) (If partition: I suggest to manually resize it to 4GB before running the script)
@@ -63,30 +63,39 @@ if [ "$flag_image" = true ]; then
6363
cp -av /home/chronos/local/lib /home/chronos/RAW/
6464
umount /home/chronos/local
6565

66+
PART_B=`sudo sfdisk -lq "$chromium_image" | grep "^""$chromium_image""[^:]" | awk '{print $1}' | grep [^0-9]5$`
67+
PART_A=`sudo sfdisk -lq "$chromium_image" | grep "^""$chromium_image""[^:]" | awk '{print $1}' | grep [^0-9]3$`
68+
PART_STATE=`sudo sfdisk -lq "$chromium_image" | grep "^""$chromium_image""[^:]" | awk '{print $1}' | grep [^0-9]1$`
69+
70+
START_NEWB=`sfdisk -o Device,Start -lq "$chromium_image" | grep "^""$PART_B"[[:space:]] | awk '{print $2}'`
71+
END_NEWB=`expr $START_NEWB + 8191`
72+
UUID_B=`sfdisk --part-uuid "$chromium_image" 5`
73+
START_NEWA=`expr $END_NEWB + 1`
74+
END_NEWA=`expr $(sfdisk -o Device,Start -lq "$chromium_image" | grep "^""$PART_STATE"[[:space:]] | awk '{print $2}') - 1`
75+
UUID_A=`sfdisk --part-uuid "$chromium_image" 3`
76+
6677
#Deletes third (ROOT_A) and fifth (ROOT_B) partitions
6778
sfdisk --delete $chromium_image 5
6879
sfdisk --delete $chromium_image 3
6980

7081
#Recreates the fifth partition with 4MB = 4194304
71-
START_NEWB=`sgdisk -f $chromium_image`
72-
END_NEWB=`expr $START_NEWB + 8192` #Considering sectors of 512 bytes
73-
sgdisk -n 5:$START_NEWB:$END_NEWB $chromium_image
74-
sgdisk -c 5:"ROOT-B" $chromium_image
75-
sgdisk -t 5:"7F01" $chromium_image
76-
e2label "$chromium_image"p5 "ROOT-B"
77-
mkfs.ext4 "$chromium_image"p5
82+
echo -e 'n\n5\n'"$START_NEWB"'\n'"$END_NEWB"'\nw' | fdisk "$chromium_image"; sync
83+
sfdisk --part-label "$chromium_image" 5 "ROOT-B"
84+
sfdisk --part-type "$chromium_image" 5 "3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC"
85+
sfdisk --part-uuid "$chromium_image" 5 "$UUID_B"
86+
e2label "$PART_B" "ROOT-B"
87+
mkfs.ext4 "$PART_B"
7888

7989
#Recreates the third partition with the remaining space
80-
START_NEWA=`sgdisk -f $chromium_image`
81-
END_NEWA=`sgdisk -E $chromium_image`
82-
sgdisk -n 3:$START_NEWA:$END_NEWA $chromium_image
83-
sgdisk -c 3:"ROOT-A" $chromium_image
84-
sgdisk -t 3:"7F01" $chromium_image
85-
e2label "$chromium_image"p3 "ROOT-A"
86-
mkfs.ext4 "$chromium_image"p3
90+
echo -e 'n\n3\n'"$START_NEWA"'\n'"$END_NEWA"'\nw' | fdisk "$chromium_image"; sync
91+
sfdisk --part-label "$chromium_image" 3 "ROOT-A"
92+
sfdisk --part-type "$chromium_image" 3 "3CB8E202-3B7E-47DD-8A3C-7FF2A13CFCEC"
93+
sfdisk --part-uuid "$chromium_image" 3 "$UUID_A"
94+
e2label "$PART_A" "ROOT-A"
95+
mkfs.ext4 "$PART_A"
8796

8897
#Searches and fixes errors at filesystem-3, then remounts
89-
e2fsck -f -y -v -C 0 "$chromium_image"p3
98+
e2fsck -f -y -v -C 0 "$PART_A"
9099
fi
91100

92101
#Mounts ChromiumOS system partition
@@ -98,7 +107,7 @@ if [ "$flag_image" = false ]; then
98107
if [ ! $? -eq 0 ]; then echo "Partition $1 inexistent"; abort_chromefy; fi
99108
else
100109
chromium_root_dir="/home/chronos/RAW"
101-
mount "$chromium_image"p3 /home/chronos/local -o loop,rw,sync 2>/dev/null
110+
mount "$PART_A" /home/chronos/local -o loop,rw,sync 2>/dev/null
102111
if [ ! $? -eq 0 ]; then echo "Something went wrong while changing $1 partition table (corrupted?)"; abort_chromefy; fi
103112
fi
104113

0 commit comments

Comments
 (0)