Skip to content

Partitions not created #159

@marshall-mcmullen

Description

@marshall-mcmullen

Greetings, just found this project and am amazed at what you've built so far. LOVE the idea of being able to partition disks natively inside Go without having to have all the tools installed on a machine and having to shell out. Great stuff.

Problem is that the partitions don't appear to be getting created. Maybe I'm doing something wrong? I'd really love if you can double check how I'm using this and see if anything obvious jumps out at you.

Here's a simplified version of what I'm doing:

numPartitions := 2
drive, err := diskfs.Open("/dev/nvme0n1")
check(err)

table := &gpt.Table{
  Partitions: make([]*gpt.Partition, numPartitions)),
}

table.Partitions[0] = &gpt.Partition{
  Name: "boot",
  Type:   "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
  Size: 104857600
}

table.Partitions[1] = &gpt.Partition{
  Name: "root",
  Type:   "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
  Size: 128027547648,
}

err = drive.Partition(table)
check(err)

log.Info("Drive info POST PARTITIONING", log.Fields{
  "drive": drive,
})

There are NO errors reported. And the log message at the end looks like everything is proper:

{
  "msg": "Drive info POST PARTITIONING",
  "time": "2022-12-02T00:01:07Z"
  "drive": {
    "DefaultBlocks": false,
    "File": {},
    "Info": {},
    "LogicalBlocksize": 512,
    "PhysicalBlocksize": 512,
    "Size": 512110190592,
    "Table": {
      "GUID": "55d819bf-041d-4339-afd5-300e9de6f038",
      "LogicalSectorSize": 512,
      "Partitions": [
        {
          "Attributes": 0,
          "End": 205311,
          "GUID": "CC092F2D-5D89-4962-A63A-9C90BA8B03A1",
          "Name": "boot",
          "Size": 104857600,
          "Start": 512,
          "Type": "C12A7328-F81F-11D2-BA4B-00A0C93EC93B"
        },
        {
          "Attributes": 0,
          "End": 250259115,
          "GUID": "2B421E42-1389-4795-9B98-27525B773CBC",
          "Name": "root",
          "Size": 128027547648,
          "Start": 205312,
          "Type": "0FC63DAF-8483-4772-8E79-3D69D8477DE4"
        }
      ],
      "PhysicalSectorSize": 512,
      "ProtectiveMBR": false
    },
    "Type": 1,
    "Writable": true
  }
}

However, when I exit the Go program above, and try to print the partitions via fdisk they are not there:

/ # fdisk -l /dev/nvme0n1
Disk /dev/nvme0n1: 477 GB, 512110190592 bytes, 1000215216 sectors
488386 cylinders, 64 heads, 32 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Disk /dev/nvme0n1 doesn't contain a valid partition table

This is running inside an Alpine Install ISO with busybox.

Thank you for any help you can provide!!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions