1 00:00:00,810 --> 00:00:05,790 In this video, we will learn how to create a new storage partition. 2 00:00:05,790 --> 00:00:09,000 That new storage and mounted on your Linux system. 3 00:00:10,020 --> 00:00:14,610 To create or add a new storage to your Linux virtual machine. 4 00:00:14,610 --> 00:00:21,020 The first thing you have to do is power off your virtual machine and add a new disk for this video. 5 00:00:21,020 --> 00:00:26,970 If you're going to add a two gigabyte of disk from our virtualization software, our virtualization 6 00:00:26,970 --> 00:00:29,160 software is an Oracle VirtualBox. 7 00:00:29,160 --> 00:00:30,480 So I could show you real quick. 8 00:00:30,480 --> 00:00:35,190 By the way, I have already added a disk to save some time. 9 00:00:35,190 --> 00:00:39,060 So here is my Oracle Virtual Machine software. 10 00:00:39,930 --> 00:00:41,100 I go to setting. 11 00:00:42,530 --> 00:00:51,200 And then go to storage and select the controller Zeta and you will see you have your first discovery 12 00:00:51,200 --> 00:00:52,020 added here. 13 00:00:52,040 --> 00:00:57,860 Now, you could add a new disk here, right here, which I have already added by clicking this add new 14 00:00:57,860 --> 00:00:58,850 storage attachment. 15 00:00:58,850 --> 00:01:03,920 But right now you can see it's grayed out because my virtual machine is powered on. 16 00:01:04,220 --> 00:01:08,750 Make sure your virtual machine is powered off in order to add a new disk. 17 00:01:09,170 --> 00:01:09,470 All right. 18 00:01:09,470 --> 00:01:11,750 So once you go through it, it's very simple. 19 00:01:11,750 --> 00:01:12,930 It's a simple visitor. 20 00:01:12,950 --> 00:01:16,790 Just follow the prompts and add two gig of disk and then click. 21 00:01:16,790 --> 00:01:17,330 Okay. 22 00:01:18,290 --> 00:01:18,550 All right. 23 00:01:18,560 --> 00:01:25,400 Make sure also it's good practice that you take a snapshot just in case you make a mistake and you have 24 00:01:25,400 --> 00:01:26,690 to come back again. 25 00:01:26,690 --> 00:01:29,300 And this way you don't lose your virtual machine. 26 00:01:29,700 --> 00:01:29,930 All right. 27 00:01:29,930 --> 00:01:38,810 So once that is done, the next thing we have to do is we will use ported and mount module to run that 28 00:01:38,810 --> 00:01:40,160 in the playbook. 29 00:01:40,490 --> 00:01:49,010 Now, if you have an distribution, the basic one, sometimes it does not come with part, part it and 30 00:01:49,010 --> 00:01:50,690 mount module. 31 00:01:51,020 --> 00:01:58,430 So in that case, you have to install them and in order to install them you will have to run this command 32 00:01:58,430 --> 00:01:59,210 as well. 33 00:01:59,250 --> 00:02:07,250 Dash Galaxy Space Collection Space Installed Space Community General This command will install ported 34 00:02:07,820 --> 00:02:10,880 or part d module for you. 35 00:02:11,450 --> 00:02:18,260 Then you would run similar command ansible galaxy space collection, space install and this time ansible 36 00:02:18,540 --> 00:02:19,760 pos pos. 37 00:02:20,630 --> 00:02:23,840 This will install your mount module. 38 00:02:24,620 --> 00:02:24,980 All right. 39 00:02:24,980 --> 00:02:34,070 So if you do not have part or mount module, then you define these modules and your playbook. 40 00:02:34,340 --> 00:02:40,190 Then most likely you will get an error which going to be like this error couldn't resolve module action 41 00:02:40,190 --> 00:02:44,600 mount or module action ported. 42 00:02:44,870 --> 00:02:49,820 This often indicates a misspelling, mis collection or incorrect module path. 43 00:02:50,330 --> 00:02:54,500 So if you're getting this error message, it means you have to run these two commands. 44 00:02:54,680 --> 00:03:02,690 Now, I have already taken the liberty and ran these two commands in my Linux control node, my Ansible 45 00:03:02,690 --> 00:03:07,790 control node and I do have ported and mount modules. 46 00:03:08,030 --> 00:03:08,330 All right. 47 00:03:08,330 --> 00:03:15,050 So once that is the basic requirement is done, then we'll go ahead and create our playbook, which 48 00:03:15,050 --> 00:03:22,100 will create our partition and then mount that partition to our directory. 49 00:03:22,100 --> 00:03:23,630 Let's see how it's going to go. 50 00:03:24,350 --> 00:03:24,770 All right. 51 00:03:24,770 --> 00:03:25,880 Here we have a playbook. 52 00:03:25,880 --> 00:03:28,550 We'll create a playbook with the name new storage. 53 00:03:28,700 --> 00:03:30,440 YAML will define that. 54 00:03:30,440 --> 00:03:31,760 It's a YAML file. 55 00:03:31,790 --> 00:03:35,300 We'll define the name, create and mount new storage. 56 00:03:35,630 --> 00:03:36,080 All right. 57 00:03:36,080 --> 00:03:38,570 Host Okay, it is right here. 58 00:03:38,570 --> 00:03:45,260 It says all, but we will create that on local host so you could change that while you're writing it. 59 00:03:45,710 --> 00:03:49,430 Then we'll define the tasks and the task. 60 00:03:49,430 --> 00:03:55,310 The very first task of this play is to create a new partition and to create a new partition. 61 00:03:55,310 --> 00:03:58,340 We will be using new module which is ported. 62 00:03:58,790 --> 00:04:05,180 Now once that module is defined, then you have to define the parameters, which is name what will be 63 00:04:05,180 --> 00:04:05,690 the name. 64 00:04:05,690 --> 00:04:07,730 Is this the file or is a swap file? 65 00:04:07,730 --> 00:04:08,630 What is that? 66 00:04:08,630 --> 00:04:13,640 It's files because we will be using that for a file system then label. 67 00:04:13,640 --> 00:04:15,710 We have to define label as GPT. 68 00:04:15,740 --> 00:04:21,590 This is the label for our partition table, not the file system label. 69 00:04:21,980 --> 00:04:25,880 Then the device slash dev slash SDB. 70 00:04:25,910 --> 00:04:34,490 Because when we added the new partition through our Oracle virtual box, it created a new disk and the 71 00:04:34,490 --> 00:04:37,070 new disk is slash dev slash SDB. 72 00:04:37,190 --> 00:04:38,660 I can show you right now. 73 00:04:39,720 --> 00:04:45,000 I'm logged into my control node through a putty client. 74 00:04:45,000 --> 00:04:51,810 If you do not have a putty client, you could actually just go simply to the Linux console, the Ansible 75 00:04:51,810 --> 00:04:52,470 console. 76 00:04:52,830 --> 00:05:01,590 All right, so if I do f desc minus L, you will notice that it has the main disk slash def slash SDA, 77 00:05:01,590 --> 00:05:07,290 which is 20 gig and it has two partitions as to one and ACA two. 78 00:05:07,770 --> 00:05:16,680 Now, when I added a new storage from Oracle VirtualBox, it gave me this new disk dev SDB and its size 79 00:05:16,680 --> 00:05:17,280 is two gig. 80 00:05:17,280 --> 00:05:19,080 That's the one I specified. 81 00:05:19,110 --> 00:05:20,070 All right, good. 82 00:05:20,160 --> 00:05:23,220 Now, let's go back to our playbook, then. 83 00:05:23,220 --> 00:05:25,970 We have to start with the device number. 84 00:05:25,980 --> 00:05:30,150 So we wanted to give it the partition number as SDB one. 85 00:05:30,150 --> 00:05:33,950 So we have to specify number one, the state present. 86 00:05:33,960 --> 00:05:35,880 Of course, we don't want to create it. 87 00:05:35,880 --> 00:05:37,860 So we are creating with the present. 88 00:05:37,860 --> 00:05:43,440 If you want to delete it, then you will do absent or part. 89 00:05:43,440 --> 00:05:46,080 Underscore start the number you wanted to start. 90 00:05:46,080 --> 00:05:48,180 This is the size of your partition. 91 00:05:48,180 --> 00:05:52,040 You'll start with one megabyte and you end with one gigabyte. 92 00:05:52,050 --> 00:05:58,830 Now if you wanted to use the entire two gig of space, you can, but you cannot specify exactly to gigabyte. 93 00:05:58,830 --> 00:06:06,300 You have to be some a few numbers below it because some of the storage is needed to create this partition. 94 00:06:06,300 --> 00:06:12,270 So anyway, just for the purpose of this lab, this video, I'm just picking one gig out of that two 95 00:06:12,270 --> 00:06:12,660 gig. 96 00:06:13,290 --> 00:06:13,770 All right. 97 00:06:13,980 --> 00:06:22,500 Now, this this task or display within that task is going to create my new partition. 98 00:06:22,500 --> 00:06:24,600 Now, the next task. 99 00:06:25,300 --> 00:06:29,770 All of this play is to create a ZFS file system. 100 00:06:29,920 --> 00:06:36,070 Now the partition is created, so now we have to define that this partition is ZFS. 101 00:06:36,070 --> 00:06:39,820 For that we'll use the module file system. 102 00:06:40,420 --> 00:06:42,160 The file system module is used. 103 00:06:42,160 --> 00:06:44,140 Then you have to define the device. 104 00:06:44,140 --> 00:06:46,920 Where are you putting that XFL file system? 105 00:06:46,930 --> 00:06:54,700 You're putting it in dev SDB one, the partition we created in the earlier task and then the name of 106 00:06:54,700 --> 00:06:57,580 the file system FS type ZFS. 107 00:06:57,580 --> 00:07:01,900 If you're putting in, let's say SD four, then you put it down XD for here. 108 00:07:02,440 --> 00:07:06,850 All right, then task three, then create mount directory. 109 00:07:07,450 --> 00:07:12,550 Now of course, once the partition is created, it's labeled, it has a file system ZFS. 110 00:07:12,730 --> 00:07:14,560 Now you have to mount it somewhere. 111 00:07:14,560 --> 00:07:19,150 Now in order to mount it, you've got to have a directory that's already created, or you could create 112 00:07:19,150 --> 00:07:20,890 it within this playbook. 113 00:07:21,250 --> 00:07:25,480 So we'll create it in this playbook and we'll use the module file. 114 00:07:25,690 --> 00:07:32,890 The path is slash data, state is directory because you always mount file system on a directory. 115 00:07:33,400 --> 00:07:35,590 Then the fourth one is a mount. 116 00:07:35,590 --> 00:07:40,990 The actual def file system for that will use the module mount. 117 00:07:41,140 --> 00:07:48,880 The source will be slash def slash SDB one and the file system type we will be x FS. 118 00:07:48,880 --> 00:07:54,910 These are parameters that you have to specify and the state mounted because that's what you want to 119 00:07:54,910 --> 00:07:59,170 do and the last thing you will do is we will run this playbook. 120 00:07:59,740 --> 00:08:00,280 All right. 121 00:08:00,820 --> 00:08:04,180 Let's go right into our control node. 122 00:08:04,270 --> 00:08:06,970 That's where we are creating this playbook. 123 00:08:06,970 --> 00:08:13,450 So as I said, I am logged in through putty because this way it will give me a bigger screen. 124 00:08:13,450 --> 00:08:15,850 Let's clear the screen once again. 125 00:08:15,850 --> 00:08:23,110 If you do not have putty or you do not know how to log into putty, you could just simply go to your. 126 00:08:24,250 --> 00:08:27,540 Control node through gooey right here. 127 00:08:27,550 --> 00:08:32,050 This is the Google login and you could do the same thing over there from the console. 128 00:08:32,290 --> 00:08:33,580 All right, here. 129 00:08:34,180 --> 00:08:38,110 I'm logged in as ID root. 130 00:08:38,140 --> 00:08:39,040 Which directory? 131 00:08:39,040 --> 00:08:39,430 Amen. 132 00:08:39,430 --> 00:08:39,910 Amen. 133 00:08:39,910 --> 00:08:41,080 At console playbook. 134 00:08:41,080 --> 00:08:42,970 That's where I'm keeping all my playbooks. 135 00:08:43,270 --> 00:08:43,810 All right. 136 00:08:43,810 --> 00:08:48,100 I have already created this playbook earlier to save some time. 137 00:08:48,100 --> 00:08:51,190 So let's go over it and see how I did it. 138 00:08:51,190 --> 00:08:56,620 So, bam, I named it new storage hit enter here. 139 00:08:56,620 --> 00:09:00,130 You notice I put it in local host, so make sure you put local hosts. 140 00:09:00,130 --> 00:09:05,080 But anyway, if you wanted to create that same partition to your client, you could do that. 141 00:09:05,080 --> 00:09:12,970 But of course, then you have to create or add that storage to your client, not to your control node. 142 00:09:13,210 --> 00:09:15,880 All right, then we come down to task. 143 00:09:16,000 --> 00:09:18,070 The first task is create new partition. 144 00:09:18,070 --> 00:09:19,360 We already covered that. 145 00:09:19,360 --> 00:09:26,170 Everything is defined, make sure the indentation is set up correctly, then create XFL file system. 146 00:09:26,170 --> 00:09:32,800 File system is the module and the device is dev SDB one and FS type is ZFS. 147 00:09:33,100 --> 00:09:36,580 Now we'll create the third one to create Mount Directory. 148 00:09:36,580 --> 00:09:42,640 It will create the path in slash data and the state is to create, not file actually directory. 149 00:09:42,640 --> 00:09:45,670 And the last one is to mount the file system. 150 00:09:45,850 --> 00:09:47,020 Beautiful. 151 00:09:47,050 --> 00:09:49,330 All right, now let's go ahead and save it. 152 00:09:51,660 --> 00:09:52,060 Okay. 153 00:09:52,080 --> 00:09:57,870 And by the way, this news story, diameter file I have already uploaded in the handout. 154 00:09:57,870 --> 00:10:06,600 So you could just simply download that and copy that over to your YAML file or into your Linux machine. 155 00:10:06,990 --> 00:10:08,970 All right, now it's time. 156 00:10:08,970 --> 00:10:09,860 A moment of truth. 157 00:10:09,870 --> 00:10:11,130 Let's run the command. 158 00:10:11,130 --> 00:10:18,390 But by the way, before I run the command, you notice once again F disk minus l you notice this disk. 159 00:10:18,390 --> 00:10:21,430 The one we are going to partition does not have any partition. 160 00:10:21,450 --> 00:10:24,660 Once we do the partition, you will see the partition right here. 161 00:10:24,900 --> 00:10:31,590 Also another thing, let's clear the screen D minus H, which will give us all the disk partitions mounted. 162 00:10:31,710 --> 00:10:41,010 You will see it does not have SDB mounted and neither it is mounted on any data and we do not have data 163 00:10:41,010 --> 00:10:42,600 created either. 164 00:10:42,960 --> 00:10:45,210 So it will do it everything for us. 165 00:10:45,210 --> 00:10:47,160 So let's clear the screen and run the command. 166 00:10:47,160 --> 00:10:48,930 Ansible dash. 167 00:10:48,930 --> 00:10:49,950 Playbook. 168 00:10:50,370 --> 00:10:51,480 Neo Storage. 169 00:10:52,200 --> 00:10:52,790 Enter. 170 00:10:54,020 --> 00:10:54,620 Right. 171 00:10:54,620 --> 00:10:56,330 Create and mount storage. 172 00:10:56,330 --> 00:10:57,950 This is the name of the playbook. 173 00:10:57,980 --> 00:10:59,360 Going to a local host. 174 00:10:59,360 --> 00:11:05,420 Local host, create XFL, done, create mount directory, done, created the created mount the file 175 00:11:05,420 --> 00:11:05,810 system. 176 00:11:05,810 --> 00:11:06,620 Done change. 177 00:11:06,620 --> 00:11:07,580 Beautiful. 178 00:11:07,880 --> 00:11:08,480 Excellent. 179 00:11:08,480 --> 00:11:09,170 So it worked. 180 00:11:09,290 --> 00:11:11,780 We didn't get any error messages. 181 00:11:11,780 --> 00:11:13,760 So now let's confirm it. 182 00:11:13,760 --> 00:11:14,990 Let's clear the screen. 183 00:11:15,140 --> 00:11:19,190 Let's do F disk first to see if it created the file system. 184 00:11:19,670 --> 00:11:20,780 Yes, it did. 185 00:11:20,780 --> 00:11:21,350 Right here. 186 00:11:21,350 --> 00:11:32,030 So you see, this was the storage and this is the partition SDB one, and it is created size 1023, 187 00:11:32,030 --> 00:11:34,190 which is almost one gig. 188 00:11:34,670 --> 00:11:38,420 Now let's see if it has created a directory. 189 00:11:38,420 --> 00:11:41,030 So we created a directory in slash. 190 00:11:41,030 --> 00:11:43,550 So let's do ls minus l t r. 191 00:11:44,410 --> 00:11:46,540 The worst order to see it created the data director. 192 00:11:46,540 --> 00:11:48,560 Yes, it did look right. 193 00:11:48,580 --> 00:11:51,430 So now let's clear the screen again. 194 00:11:52,030 --> 00:11:55,180 Let's do DF minus H to see if it mounted. 195 00:11:55,210 --> 00:11:56,530 That's the biggest thing. 196 00:11:57,370 --> 00:11:58,900 All right, beautiful. 197 00:11:58,900 --> 00:12:00,640 It did mount right here. 198 00:12:00,640 --> 00:12:05,250 The SDB one is mounted on data, and the last thing will verify. 199 00:12:05,260 --> 00:12:13,960 Did it create an ZFS file system for that will do DF minus T and right here tells you the device is 200 00:12:13,960 --> 00:12:15,490 dev SDB one. 201 00:12:15,940 --> 00:12:21,370 The file system type is ZFS the size and it's mounted on slash data. 202 00:12:21,670 --> 00:12:22,480 Excellent. 203 00:12:22,480 --> 00:12:25,360 So if you have followed it through, perfect. 204 00:12:25,360 --> 00:12:29,110 If you're getting error, just make sure you have correct indentation. 205 00:12:29,110 --> 00:12:34,690 Everything is typed correctly and you will be able to create and mount new storage.