Note

The Funtoo Linux project has transitioned to "Hobby Mode" and this wiki is now read-only.

Successful booting with UUID

From Funtoo
Revision as of 04:47, June 11, 2019 by Dutch-master (talk | contribs) (Finishing setting up the page, adding examples, commands and notes.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Guide to use UUID for consistent booting.

Guide to use UUID for consistent booting.
   Support Funtoo!
Get an awesome Funtoo container and support Funtoo! See Funtoo Containers for more information.


Introduction

When your system boots, the kernel looks at the fstab file to learn which partitions are available and where these should be mounted in the tree. Since the dawn of time, Unix time anyway, the convention was to list each partition from /dev. This works quite alright if you have only a single disk in your system, but modern computers, servers included, have an increasing amount of disks connected to their hardware and with that, the chance of 'getting it wrong' increases significantly. The result is a kernel panic! Fortunately, Linux has a solution: UUID or Unified Universal IDentification. It works this way: each time a partition is created, the partitioning tool also creates a random, large, unique number for it and assigns this to the partition. Due to its size, it's highly unlikely another partition in the machine will have the exact same number assigned to it. By using this UUID number in fstab the kernel can locate the correct partition to mount in the tree at the correct place and do so consistently. So, it's a good idea to use this UUID stuff, right? But how? Well, that's exactly the purpose of this guide.

Preparing your system

As is common in Linux, everything is a file (except for networking stuff, but that's beyond the scope of this guide) and so is the /etc/fstab file. To be safe, copy the contents of this file to a backup location.

root # cp /etc/fstab /etc/fstab.bak

Next, obtain the UUID's of each partition in your system. For that, we have the blkid command:

root # blkid /dev/sd* >> /etc/fstab

Next thing is to edit the fstab file so it resembles this example:

   /etc/fstab - /etc/fstab
#/dev/sda1                                      /boot	jfs	defaults	1 2
UUID=4fec87f4-b4ad-4707-a1ef-3dd2dd0108c5	/boot	jfs	defaults	1 2
#/dev/sda2	                                /	jfs	defaults	0 1
UUID=95ca00ac-d0a4-4a80-ba44-4a615a6dc6a4	/	jfs	defaults	0 1
#/dev/sda5	                                none	swap	sw      	0 0
UUID=4ab5f71d-a26a-4438-b66f-beee4d9c61a7	none	swap	sw      	0 0
#/dev/sda6	                                /home	jfs	user,noauto	0 2
#UUID=10fa710a-9cbc-4cc4-b4d1-fc1d6b4d4ff6	/home	jfs	user,noauto	0 0

Obviously, the UUID numbers will differ on your system and most likely so is the partitioning and perhaps the file system (jfs in this example) used. As you've noticed, both methods of designating partitions are present, shown for comparison only, with the /dev/sdX entries commented out. Once you've established your Funtoo system works with the UUID entries, you can remove the /dev/sdX lines. But it won't hurt if you leave them in place, just make sure they remain commented out.

Double-check the entries and syntax are correct, then reboot. When your Funtoo system boots, congrats! You now have a system that always mounts the partitions in the tree consistently and correctly.

Expanding your system

If you add more drives to your system, updating /etc/fstab is fairly straightforward. First, obtain which drive designation (following the /dev/sdX convention) the new drive has:

root # dmesg

Assuming your new hard drive is sdb, run the blkid command again:

root # blkid /dev/sdb >> /etc/fstab

Then edit /etc/fstab as before, making sure the directory where you want to mount it in the tree exists.

   Note

The guide assumes you use SATA drives in your system, which is the de-facto standard on modern systems. If you're still using older IDE drives, you'll need to change the sdX references to hdX.



   Note

Browse all our available articles below. Use the search field to search for topics and keywords in real-time.

Article Subtitle
Article Subtitle
Awk by Example, Part 1 An intro to the great language with the strange name
Awk by Example, Part 2 Records, loops, and arrays
Awk by Example, Part 3 String functions and ... checkbooks?
Bash by Example, Part 1 Fundamental programming in the Bourne again shell (bash)
Bash by Example, Part 2 More bash programming fundamentals
Bash by Example, Part 3 Exploring the ebuild system
BTRFS Fun
Funtoo Filesystem Guide, Part 1 Journaling and ReiserFS
Funtoo Filesystem Guide, Part 2 Using ReiserFS and Linux
Funtoo Filesystem Guide, Part 3 Tmpfs and Bind Mounts
Funtoo Filesystem Guide, Part 4 Introducing Ext3
Funtoo Filesystem Guide, Part 5 Ext3 in Action
GUID Booting Guide
Learning Linux LVM, Part 1 Storage management magic with Logical Volume Management
Learning Linux LVM, Part 2 The cvs.gentoo.org upgrade
Libvirt
Linux Fundamentals, Part 1
Linux Fundamentals, Part 2
Linux Fundamentals, Part 3
Linux Fundamentals, Part 4
LVM Fun
Making the Distribution, Part 1
Making the Distribution, Part 2
Making the Distribution, Part 3
Maximum Swappage Getting the most out of swap
On screen annotation Write on top of apps on your screen
OpenSSH Key Management, Part 1 Understanding RSA/DSA Authentication
OpenSSH Key Management, Part 2 Introducing ssh-agent and keychain
OpenSSH Key Management, Part 3 Agent Forwarding
Partition Planning Tips Keeping things organized on disk
Partitioning in Action, Part 1 Moving /home
Partitioning in Action, Part 2 Consolidating data
POSIX Threads Explained, Part 1 A simple and nimble tool for memory sharing
POSIX Threads Explained, Part 2
POSIX Threads Explained, Part 3 Improve efficiency with condition variables
Sed by Example, Part 1
Sed by Example, Part 2
Sed by Example, Part 3
Successful booting with UUID Guide to use UUID for consistent booting.
The Gentoo.org Redesign, Part 1 A site reborn
The Gentoo.org Redesign, Part 2 The Documentation System
The Gentoo.org Redesign, Part 3 The New Main Pages
The Gentoo.org Redesign, Part 4 The Final Touch of XML
Traffic Control
Windows 10 Virtualization with KVM