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

How to actually describe MBR partition table? #889

Open
RadxaYuntian opened this issue Nov 21, 2024 · 6 comments
Open

How to actually describe MBR partition table? #889

RadxaYuntian opened this issue Nov 21, 2024 · 6 comments
Labels
question Not a bug or issue, but a question asking for help or information

Comments

@RadxaYuntian
Copy link

Amlogic based devices must use MBR partition table, as their bootloader will overlap with GPT partition table. However, when I used type = "table", I got the infamous read-only error. What option do I have here?

(Yes this layout is mirroring GPT EFI layout because U-Boot will boot EFI bootloader found on a MBR disk.)

{
  disko.devices = {
    disk = {
      main = {
        device = "/dev/disk/by-id/TARGET-DEVICE";
        type = "disk";
        content = {
          type = "table";
          format = "msdos";
          partitions = [
            {
              name = "ESP";
              start = "16M";
              end = "516M";
              bootable = true;
              content = {
                type = "filesystem";
                format = "vfat";
                mountpoint = "/boot";
              };
            }
            {
              name = "root";
              start = "516M";
              end = "100%";
              content = {
                type = "filesystem";
                format = "btrfs";
                mountpoint = "/";
                mountOptions = [ "compress=zstd" ];
              };
            }
          ];
        };
      };
    };
  };
}
@iFreilicht iFreilicht added the question Not a bug or issue, but a question asking for help or information label Nov 21, 2024
@ppenguin
Copy link

I'm in a similar boat, but not with Uboot, but just an old BIOS (HP Microserver Gen8) where I want to use disko but need to use legacy partition for boot too.

@Mic92
Copy link
Member

Mic92 commented Dec 17, 2024

Does maybe hybrid gpt works? https://github.com/nix-community/disko/blob/a08bfe06b39e94eec98dd089a2c1b18af01fef19/example/hybrid-mbr.nix#L21C37-L21C41

@ppenguin
Copy link

Does maybe hybrid gpt works? https://github.com/nix-community/disko/blob/a08bfe06b39e94eec98dd089a2c1b18af01fef19/example/hybrid-mbr.nix#L21C37-L21C41

@Mic92 Thanks for chiming in so (very!) fast 😉

Would I still need this one in that case (I suppose it's the "container" for the hybrid attribute?) and would it be ok to make it "symbolic" size (say 1M)? I guess the initrd and kernel will be on the separate /boot anyway?

@altsalt
Copy link

altsalt commented Dec 17, 2024

I was able to install on non-EFI hardware by specifying a boot partition of type "EF02" and setting boot.loader.grub.efiSupport = false.

Here's the disko-config file
{
  disko.devices = {
    disk = {
      main = {
        device = "/dev/vda";
        type = "disk";
        content = {
          type = "gpt";
          partitions = {
            boot = {
              size = "1M";
              type = "EF02"; # for grub MBR
            };
            root = {
              end = "-1G";
              content = {
                type = "filesystem";
                format = "ext4";
                mountpoint = "/";
                mountOptions = [
                  "defaults"
                ];
              };
            };
            swap = {
              size = "100%";
              content = {
                type = "swap";
                discardPolicy = "both";
                resumeDevice = true; # resume from hiberation from this device
              };
            };
          };
        };
      };
    };
  };
}

@Mic92
Copy link
Member

Mic92 commented Dec 17, 2024

Does maybe hybrid gpt works? https://github.com/nix-community/disko/blob/a08bfe06b39e94eec98dd089a2c1b18af01fef19/example/hybrid-mbr.nix#L21C37-L21C41

@Mic92 Thanks for chiming in so (very!) fast 😉

Would I still need this one in that case (I suppose it's the "container" for the hybrid attribute?) and would it be ok to make it "symbolic" size (say 1M)? I guess the initrd and kernel will be on the separate /boot anyway?

Maybe?

@ppenguin
Copy link

ppenguin commented Dec 17, 2024

@altsalt I did that on my first try, but it appears I have an additional complication on my Microserver Gen8: when not using HW RAID and not using one of the 4 bays for the boot drive (but a separate SSD in the CD ROM bay), I can't boot from that but need the on-board SD card for (at least?) the MBR. So I'll be adding that to the disco config and see what happens...

EDIT:
Thanks guys 🤟

That did the trick. Thanks to those tricks (and praise the lord for iLO 🚀 ) I ended up with this config working (me being lazy I just have MBR + boot on the SD card, should be good to reboot a few times per decade on this server 😉 ):

disk-config.nix
{
  disko.devices = {
    disk = {
      main = {
        type = "disk";
        device = "/dev/disk/by-id/ata-TS128GSSD230S_023331F2E08571140568"; # SSD 120G (formerly sdc)
        content = {
          type = "gpt";
          partitions = {
            plainSwap = {
              size = "16G";
              content = {
                type = "swap";
                discardPolicy = "both";
              };
            };
            primary = {
              size = "100%";
              content = {
                type = "lvm_pv";
                vg = "pool";
              };
            };
          };
        };
      };
      sdcard = {
        type = "disk";
        device = "/dev/disk/by-id/usb-HP_iLO_Internal_SD-CARD_000002660A01-0:0"; 
        content = {
          type = "gpt";
          partitions = {
            MBR = {
              size = "1M";
              type = "EF02"; # for grub MBR
            };
            boot = {
              size = "500M";
              type = "EF00";
              content = {
                type = "filesystem";
                format = "vfat";
                mountpoint = "/boot";
                mountOptions = [
                  "defaults"
                ];
              };
            };
          };
        };
      };
    };
    lvm_vg = {
      pool = {
        type = "lvm_vg";
        lvs = {
          root = {
            size = "30G";
            content = {
              type = "filesystem";
              format = "ext4"; 
              mountpoint = "/";
              mountOptions = [
                "defaults"
              ];
            };
          };
          var = {
            size = "100%FREE";
            content = {
              type = "filesystem";
              format = "ext4"; 
              mountpoint = "/var";
              mountOptions = [
                "defaults"
              ];
            };
          };
        };
      };
    };
  };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Not a bug or issue, but a question asking for help or information
Projects
None yet
Development

No branches or pull requests

5 participants