coreos / ignition

First boot installer and configuration tool
https://coreos.github.io/ignition/
Apache License 2.0
832 stars 245 forks source link

Disk label changes on reboot #1843

Closed bkrajendra closed 4 months ago

bkrajendra commented 5 months ago

Bug

I understand this might not be directly related to CoreOS setup, but issue i am facing is related to the way setup works.

Operating System Version

Fedora CoreOS: v39.2024030

Ignition Version

version: 1.5.0

Environment

What hardware/cloud provider/hypervisor is being used to run Ignition? Bare Metal - Dell PowerEdge server

Expected Behavior

Setup should work as documented. The virtual disk name should not change on reboot.

Actual Behavior

I am installing a Fedora CoreOS 39 on a bare metal system (PowerEdge server) through a iDRac interface. The install step works ok, but after reboot the virtual disk name changes which fail the setup.

Reproduction Steps

  1. First I am botting into Fedora LiveISO (virtual cd-rom) and perform the install step: coreos-installer install /dev/sda --ignition-url http://filepath.ign once file system is copied, it reboots to perform the installation. at this stage the lsblk shows: error1

  2. After reboot, when installation proceeds, it throws error related to disk not found. My issue is when I first time boot the system with liveCD, it shows up my two-disk label as sda and sdb, but when system reboots for second phase those disk label changes to sdb and sdc. The reason is this step1 creates some temporary partition which sits at sda. This how lsblk looks after reboot: error2

Because of this, setup fails with error "Problem opening /dev/sda"

How can I make sure the disk name does not change on reboot. What wrong i am doing here?

Ignition file content

variant: fcos
version: 1.5.0
passwd:
  users:
    - name: myuser
      groups:
        - docker
        - wheel
        - sudo
      # password_hash: hash
      ssh_authorized_keys:
        - ssh-key
storage: 
  disks: 
    - device: /dev/sdb
      wipe_table: true
      partitions:
        - label: root
          type_guid: 0fc63daf-8483-4772-8e79-3d69d8477de4
          size_mib: 200000

    - device: /dev/sda
      wipe_table: true
      partitions:
        - label: data2
          number: 1
          size_mib: -1
          type_guid: 0fc63daf-8483-4772-8e79-3d69d8477de4

  filesystems:
    - device: /dev/disk/by-partlabel/data1
      path: /data1
      label: data1
      format: xfs
      wipe_filesystem: true
    - device: /dev/disk/by-partlabel/data2
      path: /data2
      label: data2
      format: xfs
      wipe_filesystem: true
ananthb commented 4 months ago

Let's clear up some terminology first. sda, sub, etc are disk names and not labels.

You've actually used partition labels in your ignition correctly, and those are not directly related to disk names.

Instead of specifying disks by name can you try specifying them by id instead?

Like this:

...
storage: 
  disks: 
    - device: /dev/disk/by-id/disk-id-goes-here
      wipe_table: true
      partitions:
        - label: root
          type_guid: 0fc63daf-8483-4772-8e79-3d69d8477de4
          size_mib: 200000
...
bkrajendra commented 4 months ago

Hi @ananthb, thank for the reply, yes, I figured that out quickly after posting on another platform and forgot to update here. I have corrected it here.

I understand that I need to use "by-id" and use disk guid in ignition, but I was unable to get a disk guid with following commands: lsblk -o NAME,UUID

NAME   UUID
sda    
sdb    
├─sdb1 
├─sdb2 DC4A-011A
├─sdb3 0e545f8b-1920-4b7a-b7bb-2ebec3cfe40e
└─sdb4 0627cdff-f6a1-4590-9518-a5796f5937b2

Just FYI, i have to disks [SSD/1TB/sdb] and [HDD/2TB/sda] I can see that I do get ids for partitions but not for the disks and I do not have any partition when I run ignition for the first time.

Can elaborate more about this?

ananthb commented 4 months ago

Disks don't have GUIDs because those belong to GPT partition tables.

You can list disks by id by running ls -l /dev/disk/by-id.

Also this isn't an ignition bug and it's getting pretty off topic.

I suggest reading up about disks and partitions some more because this information is publicly available.

jlebon commented 4 months ago

Note that for the boot disk itself on which CoreOS is installed (where you want to size the rootfs), you can use /dev/disk/by-id/coreos-boot-disk. See also https://docs.fedoraproject.org/en-US/fedora-coreos/storage/#_referencing_block_devices_from_ignition.

If you need to configure partitions/filesystems on secondary disks on many machines with varying disk names and a generic Ignition config, it might be easier to do this during the live boot and remove that section from your config. A middleground approach is to only create the partition during the live boot (using e.g. sgdisk) and giving the partition a label that you then reference in your Ignition config to set up the filesystem on top.

jlebon commented 4 months ago

I'm going to close this since it's not strictly an Ignition bug. Feel free to open a thread on https://discussion.fedoraproject.org/ if you have more questions!