2
2
3
3
# Script to install ChromeOS on top of ChromiumOS
4
4
# 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
6
6
7
7
# Parameters:
8
8
# 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
63
63
cp -av /home/chronos/local/lib /home/chronos/RAW/
64
64
umount /home/chronos/local
65
65
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
+
66
77
# Deletes third (ROOT_A) and fifth (ROOT_B) partitions
67
78
sfdisk --delete $chromium_image 5
68
79
sfdisk --delete $chromium_image 3
69
80
70
81
# 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 "
78
88
79
89
# 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 "
87
96
88
97
# 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 "
90
99
fi
91
100
92
101
# Mounts ChromiumOS system partition
@@ -98,7 +107,7 @@ if [ "$flag_image" = false ]; then
98
107
if [ ! $? -eq 0 ]; then echo " Partition $1 inexistent" ; abort_chromefy; fi
99
108
else
100
109
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
102
111
if [ ! $? -eq 0 ]; then echo " Something went wrong while changing $1 partition table (corrupted?)" ; abort_chromefy; fi
103
112
fi
104
113
0 commit comments