- Let's talk about persistent naming.
Now, block device names are subject to change.
I'll show you in a bit.
And because block devices are subject to change,
using a solution for persistent naming is recommended.
Because you know what's happening if your sdb7
is suddenly sdb6.
Well if you reboot, you'll get emergency mode.
The solution, most common solution, is the UUID,
the Universal Unique ID.
This is assigned to all block devices
that have some type of file system on it.
As an alternative, administrators can manually
assign labels for persistent naming.
You can use the blkid utility to get an overview
of currently assigned UUIDs or labels.
If you want to manually set the label,
you can use tune2fs minus L
for ext4,
or xfs admin
minus L for xfs.
Let's go check it out.
Alright, so I need to prepare my demo a little bit.
Mkdir slash xfs
slash ext4
minus minus mode
700.
You can note that this option even exists.
Look, ls minus ld on xfs
and ext4 has created a directly
in a set of permission mode as all.
Not that it's needed for this demo, but I thought,
let me show you something cool.
Next I'm going to use mkfs dot ext4
on dev sdb5
and I'm going to use mkfs dot xfs on dev
sdb6.
Obviously we need to put it in etc fstab to
automatically mount it.
So vim on etc fstab
where dev sdb5 is mounted on slash ext4.
File system type is ext4.
And we use defaults,
zero zero.
And dev sdb6 is mounted on slash xfs.
File system type is xfs and defaults and zero zero.
I choose mount minus a and everything is mounted.
Lsblk is still the easiest way to verify,
and there you can see that these partitions
are mounted correctly.
So let me also create a file on both directories.
So on ext4,
I'm creating extfile
and on xfs, I'm creating xfsfile.
That makes it easier to identify the mount points
once I'm done with this demo, because here it comes.
Now, what is going to happen?
Well I decided that I want to remove sdb5.
Let me do that clearly,
you mount dev sdb5 to disconnect it.
Then back to etcfstab.
In an fstab,
I'm going to comment out this line, sdb5.
Can always remove it later, right?
And then, I'm going to fdisk dev sdb,
because that's what I want.
I want to delete the partition.
Ignore the warning.
This warning is for people
that don't know what they're doing.
We know what we are doing, don't we?
So I'm using D for delete.
5 for Partition number five.
W for write, and uh oh,
it's telling me kernel still uses all partitions.
New table will be used at next reboot.
So I'm going to reboot.
So here we have the boot procedure and you can already see
that it's getting stuck on mounting something.
It is mounted slash boot.
It is mounted slash my data.
And I don't see anything else anymore.
What is going on?
Well, I can tell you what is going on.
We used sdb5 and sdb6.
These are logical partitions.
Logical partitions get a device, device fail.
But these device fails
are generated at the moment of booting.
And the first logical partition will get sdb5,
the second logical partition will get sdb6, and so on.
Now what is happening, if you delete sdb5
like we've just done, and you reboot
well then the partition previously known
as sdb6 will now have become sdb5.
And that is why we see this error message.
Start job is running for dev sdb6.
That's not going to work.
The point I'm making here is that due
to external circumstances, you may find that device names
on Linux are changing.
And that is why you want to use
either UUID
or a label
and that's what I'm going to show you
once we are in the emergency mode.
So the password for the emergency mode, here we go.
And I'm using blkid, block id,
which allows you to see the labels,
and let me filter it out.
You can already see sdb5. We don't have an sdb6 anymore.
It's the sdb5 that we need.
So I'm going to use blkid pipe grep sdb5.
Let me put it on top of the screen and there we can see
in the second column we have this, this UUID.
I'm going to mount it by UUID.
So let me do an
awk print
dollar two,
which is the UUID.
And now let me use a double grade then
to append to etc fstab
I mean, I'm in command line mode, I can't copy paste here.
So I need a smart solution to get this UUID,
which is pretty difficult to handle, in etc fstab.
Do mind. The double grade then, you know that's append.
If you use a single grade, then you don't have
an etc fstab anymore, and that's pretty critical.
Now I can go to my etc fstab.
And in my etc fstab, I can comment out Dev sdb6
and replace dev sdb6 with the string
that is now on the last line.
So we are going to mount on slash xfs.
The file system type is xfs.
Then we get our defaults and our zero and zero
And that should be doing it.
So mount minus a if you want,
just to verify
and control + D to quit the troubleshooting shell.
And that's how we have used the UUID.
So let me log in, so that I can also show you labels.
(computer keys clicking)
So once again blkid is showing sdb5.
There we go. Oops, this is the one.
That's what we are using right now.
Lsblk, lsblk is showing that sdb5 is mounted on xfs.
Lsblk does not include the blkid information.
Now instead of using UUID, you can also use labels.
That's pretty easy.
Xfs underscore admin
minus uppercase L myfs.
Oops. Am I missing something?
Yes, I absolutely am missing something.
I need to specify the device name as well.
So xfs admin minus L myfs on dev sdb5.
And there we go, xfs admin is telling me
dude, you can't change it on the mounted file system.
So I need to umount my dev sdb5.
And now I can set it.
And then as an alternative, I can edit etc fstab.
And in etc fstab instead of using this UUID,
I can use the label.
So label is myfs.
We mount it on slash xfs.
File system type is xfs.
Defaults and zero zero.
As I just unmounted it.
I can now use mount minus a.
Mount minus a is not giving any complaints,
so it should be happy.
The quick fix, well ls on xfs,
you can see the xfs file that I created before.
So all of this is working as expected.