... | ... |
@@ -360,8 +360,6 @@ class Installer(object): |
360 | 360 |
shutil.copy(modules.commons.KS_POST_INSTALL_LOG_FILE_NAME, |
361 | 361 |
self.photon_root + '/var/log/') |
362 | 362 |
|
363 |
- if self.install_config['iso_installer'] and os.path.isdir("/sys/firmware/efi"): |
|
364 |
- self.install_config['boot'] = 'efi' |
|
365 | 363 |
# install grub |
366 | 364 |
if 'boot_partition_number' not in self.install_config['disk']: |
367 | 365 |
self.install_config['disk']['boot_partition_number'] = 1 |
... | ... |
@@ -385,6 +383,15 @@ class Installer(object): |
385 | 385 |
self.install_config['disk']['bootdirectory'], |
386 | 386 |
str(self.install_config['disk']['boot_partition_number'])], |
387 | 387 |
stdout=self.output) |
388 |
+ elif self.install_config['boot'] == 'dualboot': |
|
389 |
+ process = subprocess.Popen( |
|
390 |
+ [self.setup_grub_command, '-w', self.photon_root, |
|
391 |
+ "dualboot", self.install_config['disk']['disk'], |
|
392 |
+ self.install_config['disk']['root'], |
|
393 |
+ self.install_config['disk']['boot'], |
|
394 |
+ self.install_config['disk']['bootdirectory'], |
|
395 |
+ str(self.install_config['disk']['boot_partition_number'])], |
|
396 |
+ stdout=self.output) |
|
388 | 397 |
except: |
389 | 398 |
#install bios if variable is not set. |
390 | 399 |
process = subprocess.Popen( |
... | ... |
@@ -21,12 +21,12 @@ grub_efi_install() |
21 | 21 |
# |
22 | 22 |
if [[ $HDD == *"loop"* ]] |
23 | 23 |
then |
24 |
- BOOT_PARTITION=/dev/mapper/`basename ${HDD}`p1 |
|
24 |
+ BOOT_PARTITION=/dev/mapper/`basename ${HDD}`p$EFI_PARTITION_NUMBER |
|
25 | 25 |
elif [[ $HDD == *"nvme"* || $HDD == *"mmcblk"* ]] |
26 | 26 |
then |
27 |
- BOOT_PARTITION=${HDD}p1 |
|
27 |
+ BOOT_PARTITION=${HDD}p$EFI_PARTITION_NUMBER |
|
28 | 28 |
else |
29 |
- BOOT_PARTITION=${HDD}1 |
|
29 |
+ BOOT_PARTITION=${HDD}$EFI_PARTITION_NUMBER |
|
30 | 30 |
fi |
31 | 31 |
mkfs.fat $BOOT_PARTITION |
32 | 32 |
mount -t vfat $BOOT_PARTITION $BUILDROOT/boot/efi |
... | ... |
@@ -48,7 +48,7 @@ search -n -u ${BOOT_UUID} -s |
48 | 48 |
configfile ${BOOT_DIRECTORY}grub2/grub.cfg |
49 | 49 |
EOF |
50 | 50 |
# Some platforms do not support adding boot entry. Thus, ignore failures. |
51 |
- efibootmgr --create --remove-dups --disk "$HDD" --part 1 --loader "/EFI/Boot/$EXE_NAME" --label Photon --verbose >&2 || : |
|
51 |
+ efibootmgr --create --remove-dups --disk "$HDD" --part $EFI_PARTITION_NUMBER --loader "/EFI/Boot/$EXE_NAME" --label Photon --verbose >&2 || : |
|
52 | 52 |
umount $BUILDROOT/boot/efi |
53 | 53 |
} |
54 | 54 |
|
... | ... |
@@ -68,7 +68,6 @@ LOGFILE=/var/log/"${PRGNAME}-${LOGFILE}" # set log file name |
68 | 68 |
ARCH=$(uname -m) # host architecture |
69 | 69 |
[ ${EUID} -eq 0 ] || fail "${PRGNAME}: Need to be root user: FAILURE" |
70 | 70 |
> ${LOGFILE} # clear/initialize logfile |
71 |
- |
|
72 | 71 |
# Check if passing a HHD and partition |
73 | 72 |
if [ $# -eq 6 ] |
74 | 73 |
then |
... | ... |
@@ -78,6 +77,7 @@ if [ $# -eq 6 ] |
78 | 78 |
BOOT_PARTITION_PATH=$4 |
79 | 79 |
BOOT_DIRECTORY=$5 |
80 | 80 |
BOOT_PARTITION_NUMBER=$6 |
81 |
+ EFI_PARTITION_NUMBER="1" |
|
81 | 82 |
fi |
82 | 83 |
|
83 | 84 |
# |
... | ... |
@@ -98,8 +98,16 @@ if [ "$BOOTMODE" == "bios" ]; then |
98 | 98 |
exit 1 |
99 | 99 |
fi |
100 | 100 |
grub_mbr_install |
101 |
-fi |
|
102 |
-if [ "$BOOTMODE" == "efi" ]; then |
|
101 |
+elif [ "$BOOTMODE" == "efi" ]; then |
|
102 |
+ grub_efi_install |
|
103 |
+elif [ "$BOOTMODE" == "dualboot" ]; then |
|
104 |
+ EFI_PARTITION_NUMBER="2" |
|
105 |
+ if [ -z $grubInstallCmd ]; then |
|
106 |
+ echo "Unable to find grub install command" |
|
107 |
+ exit 1 |
|
108 |
+ fi |
|
109 |
+ grub_mbr_install |
|
110 |
+ |
|
103 | 111 |
grub_efi_install |
104 | 112 |
fi |
105 | 113 |
|
... | ... |
@@ -41,21 +41,29 @@ def partition_disk(disk, partitions): |
41 | 41 |
if retval != 0: |
42 | 42 |
log(LOG_ERROR, "Failed clearing disk {0}".format(disk)) |
43 | 43 |
return None |
44 |
- |
|
45 | 44 |
# Partitioning the disk |
46 | 45 |
extensible_partition = None |
47 | 46 |
partitions_count = len(partitions) |
48 |
- partition_number = 2 |
|
47 |
+ partition_number = 3 |
|
49 | 48 |
# Add part size and grub flags |
50 |
- grub_flag = ':ef02' |
|
51 |
- part_size = '+2M' |
|
52 |
- if os.path.isdir("/sys/firmware/efi"): |
|
53 |
- grub_flag = ':ef00' |
|
54 |
- part_size = '+3M' |
|
55 | 49 |
|
50 |
+ bios_flag = ':ef02' |
|
51 |
+ part_size = '+2M' |
|
56 | 52 |
# Adding the bios partition |
57 | 53 |
partition_cmd = ['sgdisk', '-n 1::' + part_size] |
54 |
+ |
|
55 |
+ efi_flag = ':ef00' |
|
56 |
+ part_size = '+3M' |
|
57 |
+ # Adding the efi partition |
|
58 |
+ partition_cmd.extend(['-n 2::' + part_size]) |
|
58 | 59 |
# Adding the known size partitions |
60 |
+ |
|
61 |
+ arch = subprocess.check_output(['uname', '-m'], universal_newlines=True) |
|
62 |
+ if "x86" not in arch: |
|
63 |
+ partition_number = 2 |
|
64 |
+ # Adding the efi partition |
|
65 |
+ partition_cmd = ['sgdisk', '-n 1::' + part_size] |
|
66 |
+ |
|
59 | 67 |
for partition in partitions: |
60 | 68 |
if partition['size'] == 0: |
61 | 69 |
# Can not have more than 1 extensible partition |
... | ... |
@@ -86,12 +94,25 @@ def partition_disk(disk, partitions): |
86 | 86 |
log(LOG_ERROR, "Faild partition disk, command: {0}". format(partition_cmd)) |
87 | 87 |
return None |
88 | 88 |
|
89 |
- process = subprocess.Popen(['sgdisk', '-t1' + grub_flag, disk], stderr=output, stdout=output) |
|
90 |
- retval = process.wait() |
|
91 |
- if retval != 0: |
|
92 |
- log(LOG_ERROR, "Failed to setup grub partition") |
|
93 |
- return None |
|
94 |
- |
|
89 |
+ if "x86" not in arch: |
|
90 |
+ process = subprocess.Popen(['sgdisk', '-t1' + efi_flag, disk], stderr=output, stdout=output) |
|
91 |
+ retval = process.wait() |
|
92 |
+ if retval != 0: |
|
93 |
+ log(LOG_ERROR, "Failed to setup efi partition") |
|
94 |
+ return None |
|
95 |
+ |
|
96 |
+ else: |
|
97 |
+ process = subprocess.Popen(['sgdisk', '-t1' + bios_flag, disk], stderr=output, stdout=output) |
|
98 |
+ retval = process.wait() |
|
99 |
+ if retval != 0: |
|
100 |
+ log(LOG_ERROR, "Failed to setup bios partition") |
|
101 |
+ return None |
|
102 |
+ |
|
103 |
+ process = subprocess.Popen(['sgdisk', '-t2' + efi_flag, disk], stderr=output, stdout=output) |
|
104 |
+ retval = process.wait() |
|
105 |
+ if retval != 0: |
|
106 |
+ log(LOG_ERROR, "Failed to setup efi partition") |
|
107 |
+ return None |
|
95 | 108 |
# Format the filesystem |
96 | 109 |
for partition in partitions: |
97 | 110 |
if "mountpoint" in partition: |
... | ... |
@@ -9,6 +9,7 @@ from menu import Menu |
9 | 9 |
from confirmwindow import ConfirmWindow |
10 | 10 |
import modules.commons |
11 | 11 |
from progressbar import ProgressBar |
12 |
+import subprocess |
|
12 | 13 |
|
13 | 14 |
class SelectDisk(object): |
14 | 15 |
def __init__(self, maxy, maxx, install_config): |
... | ... |
@@ -95,6 +96,11 @@ class SelectDisk(object): |
95 | 95 |
self.partition_window.adderror('Partitioning failed, you may try again') |
96 | 96 |
else: |
97 | 97 |
self.install_config['disk'] = partitions_data |
98 |
+ arch = subprocess.check_output(['uname', '-m'], universal_newlines=True) |
|
99 |
+ if "x86" in arch: |
|
100 |
+ self.install_config['boot'] = 'dualboot' |
|
101 |
+ else: |
|
102 |
+ self.install_config['boot'] = 'efi' |
|
98 | 103 |
|
99 | 104 |
self.progress_bar.hide() |
100 | 105 |
return ActionResult(partitions_data != None, None) |
... | ... |
@@ -136,7 +136,6 @@ def createIso(options): |
136 | 136 |
config['vmdk_install'] = False |
137 | 137 |
config['type'] = 'iso' |
138 | 138 |
config['working_directory'] = working_directory |
139 |
- |
|
140 | 139 |
result = runInstaller(options, config) |
141 | 140 |
if not result: |
142 | 141 |
raise Exception("Installation process failed") |
... | ... |
@@ -228,10 +227,12 @@ def verifyImageTypeAndConfig(config_file, img_name): |
228 | 228 |
|
229 | 229 |
def create_vmdk_and_partition(config, vmdk_path, disk_setup_script): |
230 | 230 |
partitions_data = {} |
231 |
- |
|
232 | 231 |
firmware = "bios" |
233 |
- if 'boot' in config and config['boot'] == 'efi': |
|
234 |
- firmware = "efi" |
|
232 |
+ if 'boot' in config: |
|
233 |
+ if config['boot'] == 'efi': |
|
234 |
+ firmware = "efi" |
|
235 |
+ if config['boot'] == 'dualboot': |
|
236 |
+ firmware = 'dualboot' |
|
235 | 237 |
process = subprocess.Popen([disk_setup_script, '-rp', config['size']['root'], '-sp', |
236 | 238 |
config['size']['swap'], '-n', vmdk_path, '-fm', firmware], |
237 | 239 |
stdout=subprocess.PIPE) |
... | ... |
@@ -176,6 +176,9 @@ def generateImage(raw_image_path, additional_rpms_path, tools_bin_path, src_root |
176 | 176 |
working_directory = os.path.dirname(raw_image_path) |
177 | 177 |
mount_path = os.path.splitext(raw_image_path)[0] |
178 | 178 |
build_scripts_path = os.path.dirname(os.path.abspath(__file__)) |
179 |
+ root_partition_no = 2 |
|
180 |
+ if 'boot' in config and config['boot'] == 'dualboot': |
|
181 |
+ root_partition_no = 3 |
|
179 | 182 |
|
180 | 183 |
if os.path.exists(mount_path) and os.path.isdir(mount_path): |
181 | 184 |
shutil.rmtree(mount_path) |
... | ... |
@@ -186,9 +189,7 @@ def generateImage(raw_image_path, additional_rpms_path, tools_bin_path, src_root |
186 | 186 |
device_name = disk_device.split('/')[2] |
187 | 187 |
if not device_name: |
188 | 188 |
raise Exception("Could not create loop device and partition") |
189 |
- |
|
190 |
- loop_device_path = "/dev/mapper/{}p2".format(device_name) |
|
191 |
- |
|
189 |
+ loop_device_path = "/dev/mapper/{}p{}".format(device_name, root_partition_no) |
|
192 | 190 |
print(loop_device_path) |
193 | 191 |
|
194 | 192 |
try: |
... | ... |
@@ -76,28 +76,55 @@ echo "Associating loopdevice to raw disk" |
76 | 76 |
DISK_DEVICE=`losetup --show -f $VMDK_IMAGE_NAME` |
77 | 77 |
|
78 | 78 |
echo "Creating partition on raw disk" |
79 |
-if [ $SWAP_PARTITION_SIZE -gt 0 ] |
|
79 |
+if [ $BOOT_FIRM_WARE = "dualboot" ] |
|
80 | 80 |
then |
81 |
- sgdisk -n 1::+8M -n 2::+${ROOT_PARTITION_SIZE}G -n 3: -p $DISK_DEVICE >> $LOGFILE |
|
82 |
-else |
|
83 |
- sgdisk -n 1::+8M -n 2: -p $DISK_DEVICE >> $LOGFILE |
|
84 |
-fi |
|
81 |
+ if [ $SWAP_PARTITION_SIZE -gt 0 ] |
|
82 |
+ then |
|
83 |
+ sgdisk -n 1::+8M -n 2::+8M -n 3::+${ROOT_PARTITION_SIZE}G -n 4: -p $DISK_DEVICE >> $LOGFILE |
|
84 |
+ else |
|
85 |
+ sgdisk -n 1::+8M -n 2::+8M -n 3: -p $DISK_DEVICE >> $LOGFILE |
|
86 |
+ fi |
|
85 | 87 |
|
86 |
-if [ $BOOT_FIRM_WARE = "efi" ] |
|
87 |
-then |
|
88 |
- echo "EFI boot partition" |
|
89 |
- sgdisk -t1:ef00 $DISK_DEVICE >> $LOGFILE |
|
88 |
+ echo "EFI boot partition" |
|
89 |
+ sgdisk -t2:ef00 $DISK_DEVICE >> $LOGFILE |
|
90 |
+ |
|
91 |
+ echo "BIOS boot partition" |
|
92 |
+ sgdisk -t1:ef02 $DISK_DEVICE >> $LOGFILE |
|
93 |
+ |
|
94 |
+ echo "Mapping device partition to loop device" |
|
95 |
+ kpartx -avs $DISK_DEVICE >> $LOGFILE |
|
96 |
+ |
|
97 |
+ DEVICE_NAME=`echo $DISK_DEVICE|cut -c6- ` |
|
98 |
+ |
|
99 |
+ echo "Adding file system to device partition" |
|
100 |
+ mkfs -t ext4 /dev/mapper/${DEVICE_NAME}p3 |
|
101 |
+ |
|
102 |
+ echo "DISK_DEVICE=$DISK_DEVICE" |
|
103 |
+ echo "ROOT_PARTITION=/dev/mapper/${DEVICE_NAME}p3" |
|
90 | 104 |
else |
91 |
- echo "BIOS boot partition" |
|
92 |
- sgdisk -t1:ef02 $DISK_DEVICE >> $LOGFILE |
|
93 |
-fi |
|
94 |
-echo "Mapping device partition to loop device" |
|
95 |
-kpartx -avs $DISK_DEVICE >> $LOGFILE |
|
105 |
+ if [ $SWAP_PARTITION_SIZE -gt 0 ] |
|
106 |
+ then |
|
107 |
+ sgdisk -n 1::+8M -n 2::+${ROOT_PARTITION_SIZE}G -n 3: -p $DISK_DEVICE >> $LOGFILE |
|
108 |
+ else |
|
109 |
+ sgdisk -n 1::+8M -n 2: -p $DISK_DEVICE >> $LOGFILE |
|
110 |
+ fi |
|
96 | 111 |
|
97 |
-DEVICE_NAME=`echo $DISK_DEVICE|cut -c6- ` |
|
112 |
+ if [ $BOOT_FIRM_WARE = "efi" ] |
|
113 |
+ then |
|
114 |
+ echo "EFI boot partition" |
|
115 |
+ sgdisk -t1:ef00 $DISK_DEVICE >> $LOGFILE |
|
116 |
+ else |
|
117 |
+ echo "BIOS boot partition" |
|
118 |
+ sgdisk -t1:ef02 $DISK_DEVICE >> $LOGFILE |
|
119 |
+ fi |
|
120 |
+ echo "Mapping device partition to loop device" |
|
121 |
+ kpartx -avs $DISK_DEVICE >> $LOGFILE |
|
98 | 122 |
|
99 |
-echo "Adding file system to device partition" |
|
100 |
-mkfs -t ext4 /dev/mapper/${DEVICE_NAME}p2 |
|
123 |
+ DEVICE_NAME=`echo $DISK_DEVICE|cut -c6- ` |
|
101 | 124 |
|
102 |
-echo "DISK_DEVICE=$DISK_DEVICE" |
|
103 |
-echo "ROOT_PARTITION=/dev/mapper/${DEVICE_NAME}p2" |
|
125 |
+ echo "Adding file system to device partition" |
|
126 |
+ mkfs -t ext4 /dev/mapper/${DEVICE_NAME}p2 |
|
127 |
+ |
|
128 |
+ echo "DISK_DEVICE=$DISK_DEVICE" |
|
129 |
+ echo "ROOT_PARTITION=/dev/mapper/${DEVICE_NAME}p2" |
|
130 |
+fi |