1 00:00:07,050 --> 00:00:09,480 - Let's talk about persistent naming. 2 00:00:09,480 --> 00:00:12,360 Now, block device names are subject to change. 3 00:00:12,360 --> 00:00:14,490 I'll show you in a bit. 4 00:00:14,490 --> 00:00:17,160 And because block devices are subject to change, 5 00:00:17,160 --> 00:00:21,120 using a solution for persistent naming is recommended. 6 00:00:21,120 --> 00:00:23,850 Because you know what's happening if your sdb7 7 00:00:23,850 --> 00:00:25,740 is suddenly sdb6. 8 00:00:25,740 --> 00:00:29,193 Well if you reboot, you'll get emergency mode. 9 00:00:30,090 --> 00:00:33,270 The solution, most common solution, is the UUID, 10 00:00:33,270 --> 00:00:35,970 the Universal Unique ID. 11 00:00:35,970 --> 00:00:37,860 This is assigned to all block devices 12 00:00:37,860 --> 00:00:39,933 that have some type of file system on it. 13 00:00:40,920 --> 00:00:43,320 As an alternative, administrators can manually 14 00:00:43,320 --> 00:00:46,020 assign labels for persistent naming. 15 00:00:46,020 --> 00:00:49,200 You can use the blkid utility to get an overview 16 00:00:49,200 --> 00:00:52,380 of currently assigned UUIDs or labels. 17 00:00:52,380 --> 00:00:54,480 If you want to manually set the label, 18 00:00:54,480 --> 00:00:56,940 you can use tune2fs minus L 19 00:00:56,940 --> 00:00:58,380 for ext4, 20 00:00:58,380 --> 00:01:00,060 or xfs admin 21 00:01:00,060 --> 00:01:02,610 minus L for xfs. 22 00:01:02,610 --> 00:01:03,813 Let's go check it out. 23 00:01:06,060 --> 00:01:09,900 Alright, so I need to prepare my demo a little bit. 24 00:01:09,900 --> 00:01:13,290 Mkdir slash xfs 25 00:01:13,290 --> 00:01:15,480 slash ext4 26 00:01:15,480 --> 00:01:16,750 minus minus mode 27 00:01:17,610 --> 00:01:19,140 700. 28 00:01:19,140 --> 00:01:21,780 You can note that this option even exists. 29 00:01:21,780 --> 00:01:25,320 Look, ls minus ld on xfs 30 00:01:25,320 --> 00:01:28,590 and ext4 has created a directly 31 00:01:28,590 --> 00:01:31,230 in a set of permission mode as all. 32 00:01:31,230 --> 00:01:33,810 Not that it's needed for this demo, but I thought, 33 00:01:33,810 --> 00:01:35,970 let me show you something cool. 34 00:01:35,970 --> 00:01:40,290 Next I'm going to use mkfs dot ext4 35 00:01:40,290 --> 00:01:42,730 on dev sdb5 36 00:01:45,120 --> 00:01:49,470 and I'm going to use mkfs dot xfs on dev 37 00:01:49,470 --> 00:01:50,303 sdb6. 38 00:01:54,600 --> 00:01:57,360 Obviously we need to put it in etc fstab to 39 00:01:57,360 --> 00:01:59,340 automatically mount it. 40 00:01:59,340 --> 00:02:01,360 So vim on etc fstab 41 00:02:05,790 --> 00:02:10,790 where dev sdb5 is mounted on slash ext4. 42 00:02:11,130 --> 00:02:13,260 File system type is ext4. 43 00:02:13,260 --> 00:02:15,333 And we use defaults, 44 00:02:17,550 --> 00:02:18,930 zero zero. 45 00:02:18,930 --> 00:02:23,160 And dev sdb6 is mounted on slash xfs. 46 00:02:23,160 --> 00:02:27,543 File system type is xfs and defaults and zero zero. 47 00:02:29,670 --> 00:02:33,870 I choose mount minus a and everything is mounted. 48 00:02:33,870 --> 00:02:36,450 Lsblk is still the easiest way to verify, 49 00:02:36,450 --> 00:02:38,130 and there you can see that these partitions 50 00:02:38,130 --> 00:02:39,333 are mounted correctly. 51 00:02:40,470 --> 00:02:44,100 So let me also create a file on both directories. 52 00:02:44,100 --> 00:02:45,393 So on ext4, 53 00:02:47,820 --> 00:02:49,300 I'm creating extfile 54 00:02:50,580 --> 00:02:53,853 and on xfs, I'm creating xfsfile. 55 00:02:54,840 --> 00:02:57,630 That makes it easier to identify the mount points 56 00:02:57,630 --> 00:03:01,530 once I'm done with this demo, because here it comes. 57 00:03:01,530 --> 00:03:03,120 Now, what is going to happen? 58 00:03:03,120 --> 00:03:06,900 Well I decided that I want to remove sdb5. 59 00:03:06,900 --> 00:03:08,310 Let me do that clearly, 60 00:03:08,310 --> 00:03:12,570 you mount dev sdb5 to disconnect it. 61 00:03:12,570 --> 00:03:14,970 Then back to etcfstab. 62 00:03:14,970 --> 00:03:15,803 In an fstab, 63 00:03:15,803 --> 00:03:20,253 I'm going to comment out this line, sdb5. 64 00:03:21,480 --> 00:03:23,790 Can always remove it later, right? 65 00:03:23,790 --> 00:03:27,330 And then, I'm going to fdisk dev sdb, 66 00:03:27,330 --> 00:03:28,410 because that's what I want. 67 00:03:28,410 --> 00:03:30,303 I want to delete the partition. 68 00:03:32,250 --> 00:03:33,840 Ignore the warning. 69 00:03:33,840 --> 00:03:34,920 This warning is for people 70 00:03:34,920 --> 00:03:36,000 that don't know what they're doing. 71 00:03:36,000 --> 00:03:37,620 We know what we are doing, don't we? 72 00:03:37,620 --> 00:03:39,360 So I'm using D for delete. 73 00:03:39,360 --> 00:03:41,280 5 for Partition number five. 74 00:03:41,280 --> 00:03:43,740 W for write, and uh oh, 75 00:03:43,740 --> 00:03:46,290 it's telling me kernel still uses all partitions. 76 00:03:46,290 --> 00:03:49,440 New table will be used at next reboot. 77 00:03:49,440 --> 00:03:50,673 So I'm going to reboot. 78 00:03:52,890 --> 00:03:55,530 So here we have the boot procedure and you can already see 79 00:03:55,530 --> 00:03:58,050 that it's getting stuck on mounting something. 80 00:03:58,050 --> 00:03:59,280 It is mounted slash boot. 81 00:03:59,280 --> 00:04:00,750 It is mounted slash my data. 82 00:04:00,750 --> 00:04:02,850 And I don't see anything else anymore. 83 00:04:02,850 --> 00:04:04,620 What is going on? 84 00:04:04,620 --> 00:04:07,200 Well, I can tell you what is going on. 85 00:04:07,200 --> 00:04:09,870 We used sdb5 and sdb6. 86 00:04:09,870 --> 00:04:12,270 These are logical partitions. 87 00:04:12,270 --> 00:04:15,930 Logical partitions get a device, device fail. 88 00:04:15,930 --> 00:04:17,310 But these device fails 89 00:04:17,310 --> 00:04:20,010 are generated at the moment of booting. 90 00:04:20,010 --> 00:04:22,650 And the first logical partition will get sdb5, 91 00:04:22,650 --> 00:04:26,610 the second logical partition will get sdb6, and so on. 92 00:04:26,610 --> 00:04:29,910 Now what is happening, if you delete sdb5 93 00:04:29,910 --> 00:04:33,090 like we've just done, and you reboot 94 00:04:33,090 --> 00:04:36,420 well then the partition previously known 95 00:04:36,420 --> 00:04:39,660 as sdb6 will now have become sdb5. 96 00:04:39,660 --> 00:04:42,750 And that is why we see this error message. 97 00:04:42,750 --> 00:04:45,480 Start job is running for dev sdb6. 98 00:04:45,480 --> 00:04:47,730 That's not going to work. 99 00:04:47,730 --> 00:04:50,070 The point I'm making here is that due 100 00:04:50,070 --> 00:04:53,760 to external circumstances, you may find that device names 101 00:04:53,760 --> 00:04:55,920 on Linux are changing. 102 00:04:55,920 --> 00:04:57,390 And that is why you want to use 103 00:04:57,390 --> 00:04:58,390 either UUID 104 00:04:59,280 --> 00:05:00,490 or a label 105 00:05:02,070 --> 00:05:03,570 and that's what I'm going to show you 106 00:05:03,570 --> 00:05:06,303 once we are in the emergency mode. 107 00:05:08,520 --> 00:05:11,610 So the password for the emergency mode, here we go. 108 00:05:11,610 --> 00:05:15,240 And I'm using blkid, block id, 109 00:05:15,240 --> 00:05:17,790 which allows you to see the labels, 110 00:05:17,790 --> 00:05:20,010 and let me filter it out. 111 00:05:20,010 --> 00:05:24,030 You can already see sdb5. We don't have an sdb6 anymore. 112 00:05:24,030 --> 00:05:27,000 It's the sdb5 that we need. 113 00:05:27,000 --> 00:05:31,923 So I'm going to use blkid pipe grep sdb5. 114 00:05:33,180 --> 00:05:35,850 Let me put it on top of the screen and there we can see 115 00:05:35,850 --> 00:05:39,840 in the second column we have this, this UUID. 116 00:05:39,840 --> 00:05:43,050 I'm going to mount it by UUID. 117 00:05:43,050 --> 00:05:45,904 So let me do an 118 00:05:45,904 --> 00:05:47,860 awk print 119 00:05:49,560 --> 00:05:50,433 dollar two, 120 00:05:52,350 --> 00:05:53,397 which is the UUID. 121 00:05:53,397 --> 00:05:56,400 And now let me use a double grade then 122 00:05:56,400 --> 00:05:59,190 to append to etc fstab 123 00:05:59,190 --> 00:06:02,280 I mean, I'm in command line mode, I can't copy paste here. 124 00:06:02,280 --> 00:06:05,820 So I need a smart solution to get this UUID, 125 00:06:05,820 --> 00:06:10,410 which is pretty difficult to handle, in etc fstab. 126 00:06:10,410 --> 00:06:14,610 Do mind. The double grade then, you know that's append. 127 00:06:14,610 --> 00:06:16,530 If you use a single grade, then you don't have 128 00:06:16,530 --> 00:06:20,250 an etc fstab anymore, and that's pretty critical. 129 00:06:20,250 --> 00:06:22,683 Now I can go to my etc fstab. 130 00:06:23,610 --> 00:06:28,610 And in my etc fstab, I can comment out Dev sdb6 131 00:06:28,920 --> 00:06:31,560 and replace dev sdb6 with the string 132 00:06:31,560 --> 00:06:33,660 that is now on the last line. 133 00:06:33,660 --> 00:06:37,800 So we are going to mount on slash xfs. 134 00:06:37,800 --> 00:06:40,620 The file system type is xfs. 135 00:06:40,620 --> 00:06:44,130 Then we get our defaults and our zero and zero 136 00:06:44,130 --> 00:06:45,530 And that should be doing it. 137 00:06:49,050 --> 00:06:53,220 So mount minus a if you want, 138 00:06:53,220 --> 00:06:54,300 just to verify 139 00:06:54,300 --> 00:06:58,320 and control + D to quit the troubleshooting shell. 140 00:06:58,320 --> 00:07:00,170 And that's how we have used the UUID. 141 00:07:01,650 --> 00:07:04,683 So let me log in, so that I can also show you labels. 142 00:07:06,132 --> 00:07:09,549 (computer keys clicking) 143 00:07:17,700 --> 00:07:21,570 So once again blkid is showing sdb5. 144 00:07:21,570 --> 00:07:24,360 There we go. Oops, this is the one. 145 00:07:24,360 --> 00:07:26,250 That's what we are using right now. 146 00:07:26,250 --> 00:07:31,250 Lsblk, lsblk is showing that sdb5 is mounted on xfs. 147 00:07:32,220 --> 00:07:35,823 Lsblk does not include the blkid information. 148 00:07:36,750 --> 00:07:40,260 Now instead of using UUID, you can also use labels. 149 00:07:40,260 --> 00:07:41,490 That's pretty easy. 150 00:07:41,490 --> 00:07:44,050 Xfs underscore admin 151 00:07:45,120 --> 00:07:49,230 minus uppercase L myfs. 152 00:07:49,230 --> 00:07:50,610 Oops. Am I missing something? 153 00:07:50,610 --> 00:07:52,440 Yes, I absolutely am missing something. 154 00:07:52,440 --> 00:07:54,960 I need to specify the device name as well. 155 00:07:54,960 --> 00:07:59,340 So xfs admin minus L myfs on dev sdb5. 156 00:08:03,570 --> 00:08:06,360 And there we go, xfs admin is telling me 157 00:08:06,360 --> 00:08:09,360 dude, you can't change it on the mounted file system. 158 00:08:09,360 --> 00:08:12,780 So I need to umount my dev sdb5. 159 00:08:12,780 --> 00:08:14,520 And now I can set it. 160 00:08:14,520 --> 00:08:19,230 And then as an alternative, I can edit etc fstab. 161 00:08:19,230 --> 00:08:24,230 And in etc fstab instead of using this UUID, 162 00:08:24,865 --> 00:08:27,810 I can use the label. 163 00:08:27,810 --> 00:08:30,603 So label is myfs. 164 00:08:31,470 --> 00:08:33,720 We mount it on slash xfs. 165 00:08:33,720 --> 00:08:36,390 File system type is xfs. 166 00:08:36,390 --> 00:08:40,980 Defaults and zero zero. 167 00:08:40,980 --> 00:08:42,550 As I just unmounted it. 168 00:08:42,550 --> 00:08:44,880 I can now use mount minus a. 169 00:08:44,880 --> 00:08:47,220 Mount minus a is not giving any complaints, 170 00:08:47,220 --> 00:08:48,990 so it should be happy. 171 00:08:48,990 --> 00:08:51,267 The quick fix, well ls on xfs, 172 00:08:51,267 --> 00:08:54,600 you can see the xfs file that I created before. 173 00:08:54,600 --> 00:08:57,213 So all of this is working as expected.