Skip to content

Commit

Permalink
remove swap entirely
Browse files Browse the repository at this point in the history
  • Loading branch information
yocalebo committed May 31, 2024
1 parent c8b3eac commit b5bde33
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 27 deletions.
17 changes: 7 additions & 10 deletions truenas_installer/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
BOOT_POOL = "boot-pool"


async def install(disks, create_swap, set_pmbr, authentication, post_install, sql, callback):
async def install(disks, set_pmbr, authentication, post_install, sql, callback):
with installation_lock:
try:
if not os.path.exists("/etc/hostid"):
await run(["zgenhostid"])

for disk in disks:
callback(0, f"Formatting disk {disk}")
await format_disk(f"/dev/{disk}", create_swap, set_pmbr, callback)
await format_disk(f"/dev/{disk}", set_pmbr, callback)

callback(0, "Creating boot pool")
await create_boot_pool([get_partition(disk, 3) for disk in disks])
Expand All @@ -34,25 +34,22 @@ async def install(disks, create_swap, set_pmbr, authentication, post_install, sq
raise InstallError(f"Command {' '.join(e.cmd)} failed:\n{e.stderr.rstrip()}")


async def format_disk(device, create_swap, set_pmbr, callback):
async def format_disk(device, set_pmbr, callback):
if (result := await run(["wipefs", "-a", device], check=False)).returncode != 0:
callback(0, f"Warning: unable to wipe partition table for {device}: {result.stderr.rstrip()}")

# Erase both typical metadata area.
await run(["sgdisk", "-Z", device], check=False)
await run(["sgdisk", "-Z", device], check=False)

# Create BIOS boot partition
# Create BIOS boot partition (1st partition)
await run(["sgdisk", "-a4096", "-n1:0:+1024K", "-t1:EF02", "-A1:set:2", device])

# Create EFI partition (Even if not used, allows user to switch to UEFI later)
# (2nd partition)
await run(["sgdisk", "-n2:0:+524288K", "-t2:EF00", device])

if create_swap:
await run(["sgdisk", "-n4:0:+16777216K", "-t4:8200", device])
await run(["wipefs", "-a", "-t", "zfs_member", get_partition(device, 4)], check=False)

# Create data partition
# Create data partition (3rd partition)
await run(["sgdisk", "-n3:0:0", "-t3:BF01", device])

# Bad hardware is bad, but we've seen a few users
Expand All @@ -61,7 +58,7 @@ async def format_disk(device, create_swap, set_pmbr, callback):
# to do something with the partition(s), they won't
# be present. This is almost _exclusively_ related
# to bad hardware, but we add this here as a compromise.
await wait_on_partitions(device, [1, 2, 3, 4] if create_swap else [1, 2, 3])
await wait_on_partitions(device, [1, 2, 3])

if set_pmbr:
await run(["parted", "-s", device, "disk_set", "pmbr_boot", "on"], check=False)
Expand Down
8 changes: 1 addition & 7 deletions truenas_installer/installer_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from .exception import InstallError
from .install import install
from .serial import serial_sql
from .swap import is_swap_safe


class InstallerMenu:
Expand Down Expand Up @@ -98,11 +97,6 @@ async def _install_upgrade_internal(self):
if authentication_method is False:
return False

create_swap = False
if all(is_swap_safe([disk for disk in disks if disk.name == destination_disk][0])
for destination_disk in destination_disks):
create_swap = await dialog_yesno("Swap", "Create 16GB swap partition on boot devices?")

set_pmbr = False
if not self.installer.efi:
set_pmbr = await dialog_yesno(
Expand All @@ -117,7 +111,7 @@ async def _install_upgrade_internal(self):
sql = await serial_sql()

try:
await install(destination_disks, create_swap, set_pmbr, authentication_method, None, sql, self._callback)
await install(destination_disks, set_pmbr, authentication_method, None, sql, self._callback)
except InstallError as e:
await dialog_msgbox("Installation Error", e.message)
return False
Expand Down
10 changes: 0 additions & 10 deletions truenas_installer/swap.py

This file was deleted.

0 comments on commit b5bde33

Please sign in to comment.