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

fix: correctly retrieve the last partition of the installation disk #36

Merged
merged 1 commit into from
Sep 1, 2023

Conversation

runcom
Copy link
Member

@runcom runcom commented Aug 31, 2023

grepping /proc/partitions the way we're doing doesn't account for devices with more numbers according to our grep command. Devices like nvme0n1 would just return "0" as the last partition but that's wrong as what gets executed is:

grep -c nvme0n1[0-9] /proc/partitions

which just returns 0 but it's obviously not the last partition. Fix the above by using the sys filesystem as it provides better heiraical nature of paritions within a drive without accounting for its string format.

grepping /proc/partitions the way we're doing doesn't account for
devices with more numbers according to our grep command. Devices like
nvme0n1 would just return "0" as the last partition but that's wrong as
what gets executed is:

grep -c nvme0n1[0-9] /proc/partitions

which just returns 0 but it's obviously not the last partition.
Fix the above by using the sys filesystem as it provides better
heiraical nature of paritions within a drive without accounting for its
string format.

Signed-off-by: Antonio Murdaca <[email protected]>
@runcom
Copy link
Member Author

runcom commented Aug 31, 2023

/test-9

Copy link
Member

@miabbott miabbott left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I successfully tested the new logic for determining the last partition on a device with an NVMe drive (/sys/block/nvme0n1) and a device with an SD card (/sys/block/mmcblk0)

LGTM

Copy link
Collaborator

@7flying 7flying left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM too 👍

@nullr0ute
Copy link

LGTM 👍

@runcom
Copy link
Member Author

runcom commented Sep 1, 2023

tests are stuck because of the kernel bug for qemu, we're testing this manually

@runcom
Copy link
Member Author

runcom commented Sep 1, 2023

Manually restarting the vm with /dev/vda works as expected and the partition is indeed extended

image

also, manually tweaking virt-install to use an nvme drive works as expected again

image

I'll wait for Mario to confirm it works on real hardware and we should be good

@mcattamoredhat
Copy link

The generated iso has been tested in Onlogic HX401 bare-metal device. After tweaking disk device name from /dev/vda /dev/nvme0n1 the root file system has grown to the proper size.

[admin@localhost ~]$ lsblk
NAME                                          MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINTS
nvme0n1                                       259:0    0 119.2G  0 disk  
├─nvme0n1p1                                   259:1    0     1M  0 part  
├─nvme0n1p2                                   259:2    0   127M  0 part  /boot/efi
├─nvme0n1p3                                   259:3    0   384M  0 part  /boot
└─nvme0n1p4                                   259:4    0 118.7G  0 part  
  └─luks-fb0a1ad5-a3e5-42f5-b2ba-19ac54926ea5 253:0    0 118.7G  0 crypt 
    └─rootvg-rootlv                           253:1    0     9G  0 lvm   /var
                                                                         /sysroot/ostree/deploy/redhat/var
                                                                         /usr
                                                                         /etc
                                                                         /
                                                                         /sysroot
[admin@localhost ~]$ sudo rpm-ostree status 
State: idle
Deployments:
● rhel-edge:rhel/9/x86_64/edge
                  Version: 9.3 (2023-09-01T08:40:53Z)
                   Commit: 35333670b90079783ece1f268d3920cf1454f71aad8b5c55929bd2ccfab1ad00
[admin@localhost ~]$ uname -a
Linux localhost.localdomain 5.14.0-362.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Aug 28 18:48:22 EDT 2023 x86_64 x86_64 x86_64 GNU/Linux

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

Successfully merging this pull request may close these issues.

5 participants