I just spend 3 hours fighting with a reboot that would fail over and over again...
The problem with the newer systems (I'm on 24.04 now,) is that they want to make everything graphical. So when it fails, good luck finding the error on your totally black screen. Sad, if you ask me. A console with an error makes it so much easier to fix problems quickly.
In my case, I wanted to move my /var to a different, safer drive (instead of the boot which I consider unsafe, no RAID-1, SSD... what can go wrong?!)
So I used the blkid command to get the UUID like so:
$ sudo blkid /dev/mapper/users-var
/dev/mapper/users-var: UUID="95e5e925-1f92-4578-a79a-b3b7cd508a73" BLOCK_SIZE="4096" TYPE="ext4"
and used that UUID in my fstab like so:
UUID="95e5e925-1f92-4578-a79a-b3b7cd508a73" /var ext4 default 0 1
I even made sure I could mount that way before rebooting:
$ mkdir test-mount
$ sudo mount UUID="95e5e925-1f92-4578-a79a-b3b7cd508a73" test-mount
$ ls test-mount
<expected files / directories from /var>
Then I tried to reboot...
$ sudo init 6
But before rebooting on my normal system, I start a Live version of Ubuntu to make sure I had the latest from the /var from the SSD copied to that new partition, using rsync:
$ mkdir var var2
$ sudo mount /dev/sda2 var
$ sudo mount UUID="95e5e925-1f92-4578-a79a-b3b7cd508a73" var2
$ sudo rsync --partial --info=progress2 -a /var/ /var2
Finally, rebooted from the Live version and tested the new setup.
It failed.
I got a black screen of death. Absolutely no feedback. Luckily, I have sshd setup and could connect from another computer and noticed two issues:
- the
graphical.target was failing, looking at the reason, it said "dependency missing"
- looking for a failure, I found that the
var.mount unit did not work; the necessary dependency which was missing
Note: to find those issues, I primarily used systemd-analyze and systemctl list-units.
So I verified my fstab file, I had two issues, although I do not think that the second one would have been a problem: i.e. I was still mounting the var partition to /var2 (as I was testing things, made backups, etc. and mounting the same partition twice is not possible—also that was my first fix and an intermediate reboot still failed). To do that first one, I rebooted the Live version of Ubuntu, and used the chroot trick to update the fstab and grub properly.
Since my home partition uses an LVM name entry:
/dev/users/users /home ext4 defaults 0 2
and it has been working for years, I decided to change the /var to also still use the LVM name instead of the UUID:
/dev/users/var /var ext4 defaults 0 1
Ran the necessary commands to make sure it would be taken in account:
$ sudo update-initramfs -u
$ sudo update-grub
and finally tried to reboot one more time:
$ sudo init 6
and that time it worked.
So result is clear to me: DO NOT USE UUIDs when mounting /dev/mapper/... partitions or you could end up breaking your boot process.