Installed on nvme0, but renamed nvme1 : what if second nvme removed?

First, i installed leap16.0 on a samsung drive who used to be called nvme0 by the system, and i decided to re-install it on a faster sandisk drive, but keeping the samsung on the second nvme plug.
During install, the installer called new sandisk nvme0 and the odler samsung nvme1.
I didn’t check how and where the boot section (mbr,efi, grub or anything ) would be installed.
Now i realize that the names have been switched : sandisk has become nvme1 and samsung is nvme0.
Maybe because the installer found a boot partition already installed on samsung ? Or maybe because of the laptop bios ? I don’t know, but that’s not the problem.
The problem is that i want to remove the older samsung because i copied all i wanted to copy and the risk is that there is no more boot partition, and moreover, /etc/fstab will be totally wrong…
So, i am asking for your help to find a safe way not loose hours of hard work.

After the install, move the drive and it will be fine as it mounts via UUID.

In the “Storage” section installer just make sure you select in “Find Space” select the Custom option and whatever you don’t want touched, click “Do not modify” for that partition…

https://share.google/aimode/o6p60cxATl4Unyzfc

Q:

how does the Linux kernel name NVME drives? is it by hardware channel numbers?

A: AI Overview

No, the Linux kernel does not name NVMe drives by hardware channel numbers. Instead, it names them dynamically based on the order in which they are discovered and initialized by the kernel during the boot process.

Because this discovery order can change slightly from boot to boot—especially if hardware response times vary—NVMe drive names are not guaranteed to be persistent.

So you can rely only on persistent IDs like UUIDs, Part-UUIDs or partition/filesystem labels.

I like to give each of my partitions a unique label. This makes disks portable between systems, and adding or removing disks does not pose a problem with a different order of discovery.

I prefer them to UUIDs or part-UUIDs because the labels are human readable, unlike the UUIDs. Of course you have to make sure manually that the labels are unique among all disks on the system.

[sh @ meteor] ~ 8 % cat /etc/fstab                             
# 
#  [sh @ meteor] % lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINTS,UUID
#
#  NAME          SIZE FSTYPE      LABEL    MOUNTPOINTS     UUID
#
#  nvme0n1     953.9G                                      
#  ├─nvme0n1p1   512M vfat        efi-boot /boot/efi       DCEA-F8DD
#  ├─nvme0n1p2     2G swap        swap     [SWAP]          1eed3f64-cafc-4977-b8d7-e8ccb6a9857f
#  ├─nvme0n1p3   100G ext4        root-01  /               8f206b58-5422-40cd-b561-d3ee1dd4d110
#  ├─nvme0n1p4   100G ext4        root-02  /alternate-root 5969e673-2daa-4904-9d62-8f6d475121d7
#  ├─nvme0n1p5   200G crypto_LUKS                          771f09d1-0b53-4537-9e0a-3afb40430e3c
#  │ └─crypto    200G ext4        crypto   /crypto         da9c1758-e4e9-4256-8bc4-7273d6fb6f3b
#  └─nvme0n1p6 551.4G ext4        work     /work           ba3949fe-98db-4d09-926d-c8ed50e07132
#

LABEL=swap      swap             swap  defaults                  0  0
LABEL=root-01   /                ext4  defaults                  0  1
LABEL=root-02   /alternate-root  ext4  data=ordered              0  2
LABEL=crypto    /crypto          ext4  user,noauto,data=ordered  0  2
LABEL=work      /work            ext4  data=ordered              0  2
LABEL=efi-boot  /boot/efi        vfat  utf8                      0  2

Notice that the LABEL=xy part could also be written as /dev/disk/by-label/xy:

[sh @ meteor] ~ 14 % ls -l /dev/disk/by-label
total 0
lrwxrwxrwx 1 root root 15 Sep 10 13:46 efi-boot -> ../../nvme0n1p1
lrwxrwxrwx 1 root root 15 Sep 10 13:46 root-01 -> ../../nvme0n1p3
lrwxrwxrwx 1 root root 15 Sep 10 13:46 root-02 -> ../../nvme0n1p4
lrwxrwxrwx 1 root root 15 Sep 10 13:46 swap -> ../../nvme0n1p2
lrwxrwxrwx 1 root root 15 Sep 10 13:46 work -> ../../nvme0n1p6

Those symlinks are generated dynamically by the kernel based on existing filesystem labels.

1 Like

Thanks, but, the install is already made and i did a lot of work since the install, so i don’t want to re-install

Thanks, i’m gonna check that. Sorry if my question was a bit “archeologic” : i learned linux >25 yrs agos and the /dev/hda and /dev/hdb stories were quite tricky at that time

Thanks, i’m gonna check that. Sorry if my question was a bit “archeologic” : i learned linux >25 yrs agos and the /dev/hda and /dev/hdb stories were quite tricky at that time

You don’t need to reinstall for any of this. You can assign labels to each of the filesystems with the respective tool for the filesystem type, and change /etc/fstab accordingly. If you are using full disk encryption, though, that’s more complicated.

  • e2label for ext4
  • btrfs filesystem label for Btrfs
  • swaplabel for swap
1 Like

I checked my fstab and saw no reference to /dev/nvme*** . Does it mean that i can safely just remove the old samsung and the sandisk will be automatically renamed from nvme1 to nvme0 without any trouble ?

Do i have to check if the boot partition is written on the /boot/efi partition on the sandisk ?

Tell me about it. It’s a moving target ever since I started it with SunOS / Solaris in the 1990s and with Linux in the late 1990. :smiley:

i don’t use fde , no important info to encrypt, and the test of this fde feature was disapointing beacause too slow

Yes, exactly that. The Agama installer (as well as the old YaST installer) uses only UUIDs by default for generating /etc/fstab, the main reason being that kernel device names may change according to hardware detection order.

Yes, that would be very much recommended. It won’t do any good on a disk that is removed.

1 Like

Use the lsblk command from my /etc/fstab sample above to find out what partitions are on what disk and on what position:

lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINTS,UUID
1 Like

Thank you, but, how can i make sure that i still have a boot partition if i remove the old samsung ? There is no more yast utility to install some grub anywhere, so, how do i proceed to install some grub on the new sandisk ?

First you need to make some space on the new disk for the EFI System Partition (ESP, mounted as /boot/efi). I don’t know your partitions layout, but you’ll probably have to resize the last partition on that disk (unless you have some spare disk space which I doubt). First resize the filesystem on that last partition, then the partition itself. gparted is good at that; it can do both in one step.

I use grub2-efi which doesn’t need a lot of disk space. Should you decide to go with systemd-boot, you’ll need more; enough for all the initrds and kernels that you want to keep in parallel (including old kernels!).

Then create a new ESP (which has its own partition type!) with type VFAT (preferably also with gparted), reconfigure the bootloader to use that new ESP and reinstall the bootloader there.

And of course don’t forget to tell your BIOS that this is the new boot disk.

Thank you. I already have /boot/efi partition on the new sandisk . And i wonder why the installer never used it. Anyway, Its size is 512MB and it’s vfat file system.
Do you think i can just run grub2-efi to configure this already present partition as the boot partition ?

My /etc/sysconfig/bootloader says :

Blockquote
LOADER_TYPE=“grub2-efi”
SECURE_BOOT=“yes”
TRUSTED_BOOT=“no”
UPDATE_NVRAM=“yes”

So, grub2-efi is my bootloader, but no indication of where it is saved by default. An since there is no more yast2-bootloader module, should i run some grub-efi cli to put it on my new /boot/efi partition, on the new disk instead of the old one ?

Looking up the file system for some consistent files, i found this one : /boot/efi/EFI/opensuse , whose content is :

Blockquote
set btrfs_relative_path=“yes”
search --no-floppy --fs-uuid --set=root d502c197-186d-4682-8157-21d4eb733ba4
set prefix=(${root})/boot/grub2
source “${prefix}/grub.cfg”

Since d502c197-186d-4682-8157-21d4eb733ba4 is the uid of my new partition / for the newly installed leap16.0 on the new disk, shall i conclude that i am ok, and just unplug the old samsung after shutdown and just start with the new sandisk without problem ?

The problem is that the /boot/efi partition ont the new sandisk seems to contain only 6.6MB on the total 540MB (according to cockpit client), which is worryingly little compared to the /boot/efi partition on the old samsung…

Leap 16.0 is currently using grub2-efi, I use 4GB for my /boot/efi partitions in case it does change somewhere down the track.

A leap 16.0 example;

du -sh /boot/efi
6.1M	/boot/efi

lsblk -f /dev/nvme0n1p1
NAME      FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
nvme0n1p1 vfat   FAT32 ESP   F658-C15C                                 4G     0% /boot/efi

A Tumbleweed and systemd-boot example;

du -sh /boot/efi
578M	/boot/efi

lsblk -f /dev/sda1
NAME FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda1 vfat   FAT32 ESP   4FEA-283B                               3.4G    14% /boot/efi

Thank you for your answer.
Do you mean that a very low 6.6MB of usage on /boot/efi partition is fine ? (Because your /boot/efi shows 6.1MB du on your example)