From c577571e2a6b623f7027d97d3ea523db663c68fa Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 22 May 2018 20:07:59 +0100 Subject: [PATCH] installer: Drop /var partition Fixes #11735 Signed-off-by: Michael Tremer --- src/installer/hw.c | 100 +++++++------------------------------------ src/installer/hw.h | 2 - src/installer/main.c | 1 - 3 files changed, 16 insertions(+), 87 deletions(-) diff --git a/src/installer/hw.c b/src/installer/hw.c index add36c8f49..6acddf9bff 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -420,21 +420,6 @@ static unsigned long long hw_swap_size(struct hw_destination* dest) { return swap_size; } -static unsigned long long hw_root_size(struct hw_destination* dest) { - unsigned long long root_size; - - if (dest->size < MB2BYTES(2048)) - root_size = MB2BYTES(1024); - - else if (dest->size >= MB2BYTES(2048) && dest->size <= MB2BYTES(3072)) - root_size = MB2BYTES(1536); - - else - root_size = MB2BYTES(2048); - - return root_size; -} - static unsigned long long hw_boot_size(struct hw_destination* dest) { return MB2BYTES(128); } @@ -480,6 +465,10 @@ static int hw_calculate_partition_table(struct hw_destination* dest, int disable // Add some more space for partition tables, etc. dest->size -= MB2BYTES(1); + // The disk has to have at least 2GB + if (dest->size <= MB2BYTES(2048)) + return -1; + // Determine partition table dest->part_table = HW_PART_TABLE_MSDOS; @@ -506,7 +495,14 @@ static int hw_calculate_partition_table(struct hw_destination* dest, int disable } dest->size_boot = hw_boot_size(dest); - dest->size_root = hw_root_size(dest); + + // Determine the size of the data partition. + unsigned long long space_left = dest->size - \ + (dest->size_bootldr + dest->size_boot); + + // If we have less than 2GB left, we disable swap + if (space_left <= MB2BYTES(2048)) + disable_swap = 1; // Should we use swap? if (disable_swap) @@ -514,21 +510,11 @@ static int hw_calculate_partition_table(struct hw_destination* dest, int disable else dest->size_swap = hw_swap_size(dest); - // Determine the size of the data partition. - unsigned long long used_space = dest->size_bootldr + dest->size_boot - + dest->size_swap + dest->size_root; + // Subtract swap + space_left -= dest->size_swap; - // Disk is way too small - if (used_space >= dest->size) - return -1; - - dest->size_data = dest->size - used_space; - - // If it gets too small, we remove the swap space. - if (dest->size_data <= MB2BYTES(256)) { - dest->size_data += dest->size_swap; - dest->size_swap = 0; - } + // Root is getting what ever is left + dest->size_root = space_left; // Set partition names if (dest->size_boot > 0) { @@ -550,11 +536,6 @@ static int hw_calculate_partition_table(struct hw_destination* dest, int disable snprintf(dest->part_root, sizeof(dest->part_root), "%s%d", path, part_idx++); - if (dest->size_data > 0) - snprintf(dest->part_data, sizeof(dest->part_data), "%s%d", path, part_idx++); - else - *dest->part_data = '\0'; - return 0; } @@ -682,14 +663,6 @@ int hw_create_partitions(struct hw_destination* dest, const char* output) { part_start += dest->size_root; } - if (*dest->part_data) { - asprintf(&cmd, "%s mkpart %s ext2 %lluB %lluB", cmd, - (dest->part_table == HW_PART_TABLE_GPT) ? "DATA" : "primary", - part_start, part_start + dest->size_data - 1); - - part_start += dest->size_data; - } - if (dest->part_boot_idx > 0) asprintf(&cmd, "%s set %d boot on", cmd, dest->part_boot_idx); @@ -721,9 +694,6 @@ int hw_create_partitions(struct hw_destination* dest, const char* output) { if (*dest->part_root && (try_open(dest->part_root) != 0)) continue; - if (*dest->part_data && (try_open(dest->part_data) != 0)) - continue; - // All partitions do exist, exiting the loop. break; } @@ -787,13 +757,6 @@ int hw_create_filesystems(struct hw_destination* dest, const char* output) { if (r) return r; - // data - if (*dest->part_data) { - r = hw_format_filesystem(dest->part_data, dest->filesystem, output); - if (r) - return r; - } - return 0; } @@ -839,19 +802,6 @@ int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) { } } - // data - if (*dest->part_data) { - snprintf(target, sizeof(target), "%s%s", prefix, HW_PATH_DATA); - mkdir(target, S_IRWXU|S_IRWXG|S_IRWXO); - - r = hw_mount(dest->part_data, target, filesystem, 0); - if (r) { - hw_umount_filesystems(dest, prefix); - - return r; - } - } - // swap if (*dest->part_swap) { r = swapon(dest->part_swap, 0); @@ -896,14 +846,6 @@ int hw_umount_filesystems(struct hw_destination* dest, const char* prefix) { return -1; } - // data - if (*dest->part_data) { - snprintf(target, sizeof(target), "%s%s", prefix, HW_PATH_DATA); - r = hw_umount(target); - if (r) - return -1; - } - // swap if (*dest->part_swap) { swapoff(dest->part_swap); @@ -1096,16 +1038,6 @@ int hw_write_fstab(struct hw_destination* dest) { free(uuid); } - // data - if (*dest->part_data) { - uuid = hw_get_uuid(dest->part_data); - - if (uuid) { - fprintf(f, FSTAB_FMT, uuid, "/var", "auto", "defaults", 1, 1); - free(uuid); - } - } - fclose(f); return 0; diff --git a/src/installer/hw.h b/src/installer/hw.h index e2d621be54..e127f1f510 100644 --- a/src/installer/hw.h +++ b/src/installer/hw.h @@ -84,7 +84,6 @@ struct hw_destination { char part_boot[DEV_SIZE]; char part_swap[DEV_SIZE]; char part_root[DEV_SIZE]; - char part_data[DEV_SIZE]; int part_boot_idx; int filesystem; @@ -94,7 +93,6 @@ struct hw_destination { unsigned long long size_boot; unsigned long long size_swap; unsigned long long size_root; - unsigned long long size_data; }; struct hw* hw_init(); diff --git a/src/installer/main.c b/src/installer/main.c index c7075aa71d..116f52b051 100644 --- a/src/installer/main.c +++ b/src/installer/main.c @@ -685,7 +685,6 @@ int main(int argc, char *argv[]) { fprintf(flog, " boot : %s (%lluMB)\n", destination->part_boot, BYTES2MB(destination->size_boot)); fprintf(flog, " swap : %s (%lluMB)\n", destination->part_swap, BYTES2MB(destination->size_swap)); fprintf(flog, " root : %s (%lluMB)\n", destination->part_root, BYTES2MB(destination->size_root)); - fprintf(flog, " data : %s (%lluMB)\n", destination->part_data, BYTES2MB(destination->size_data)); fprintf(flog, "Memory : %lluMB\n", BYTES2MB(hw_memory())); // Warn the user if there is not enough space to create a swap partition -- 2.39.2