Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore Partitions #533

Open
jacobranson opened this issue Feb 9, 2024 · 3 comments
Open

Ignore Partitions #533

jacobranson opened this issue Feb 9, 2024 · 3 comments

Comments

@jacobranson
Copy link

I think it would be beneficial if there was a way to mark partitions as "ignored", meaning Disko won't touch them in any way. For M1 Macs, there are two partitions that cannot be deleted without rendering the machine unbootable, those being iBootSystemContainer and RecoveryOSContainer, like shown below.

nixos# sgdisk /dev/nvme0n1 -p
Disk /dev/nvme0n1: 244276265 sectors, 931.8 GiB
Model: APPLE SSD AP1024Q                       
Sector size (logical/physical): 4096/4096 bytes
Disk identifier (GUID): 27054D2E-307A-41AA-9A8C-3864D56FAF6B
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 5
First usable sector is 6, last usable sector is 244276259
Partitions will be aligned on 1-sector boundaries
Total free space is 0 sectors (0 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1               6          128005   500.0 MiB   FFFF  iBootSystemContainer
   2          128006       219854567   838.2 GiB   AF0A  Container
   3       219854568       220465127   2.3 GiB     AF0A  
   4       220465128       220590311   489.0 MiB   EF00  
   5       220590312       242965550   85.4 GiB    8300  
   6       242965551       244276259   5.0 GiB     FFFF  RecoveryOSContainer

Alternatively, if there is already a mechanism for something like this, perhaps the examples directory can be updated to include a M1 Mac example configuration.

@Alex0159
Copy link

!!! i tested this on a virtual machine be careful with the real disk !!!

After studying the code a little, I realized that the partition number is set by the variable = _index
And so that the disk is not formatted, you need to use the mode = format

modified example from README.md:

{
...
          partitions = {
            ESP = {
              type = "EF00";
              size = "500M";
              _index = 4;
              content = {
                type = "filesystem";
                format = "vfat";
                mountpoint = "/boot";
              };
            };
            root = {
              size = "100%";
              _index = 5;
...
}
sudo nix --experimental-features "nix-command flakes" run github:nix-community/disko -- --mode format /tmp/disk-config.nix

@Mic92
Copy link
Member

Mic92 commented Jun 16, 2024

I have that such a feature becomes to complex to implement with just the nixos module system and shell scripts.

@Lassulus
Copy link
Collaborator

it should basically work by replicating your current disk layout in disko (using priority for the order of the partitons) and then just running the format script manually (not the disko one, as that one zaps your disks) the format script should not nuke your table if it already exists. so in theory it should just work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants