1 00:00:00,000 --> 00:00:02,939 This lesson is about adding and extending 2 00:00:03,029 --> 00:00:05,969 disk using logical volume management. 3 00:00:06,029 --> 00:00:08,579 Now, why do we need to extend a disk. So 4 00:00:08,609 --> 00:00:11,279 if we have a disk already in our system, 5 00:00:11,279 --> 00:00:13,799 in our Linux system, and let's say if 6 00:00:13,799 --> 00:00:18,419 that disk becomes full, it's 100%, so 7 00:00:18,419 --> 00:00:21,419 you have this disk that is mounted on 8 00:00:21,419 --> 00:00:25,409 /oracle. And the disk space of that 9 00:00:25,409 --> 00:00:29,099 oracle is one gigabyte. And now after, 10 00:00:29,129 --> 00:00:31,379 let's say, six months or a year, the 11 00:00:31,379 --> 00:00:33,539 database administrator comes back to you 12 00:00:33,539 --> 00:00:37,619 and says, Hey, I need more disk space 13 00:00:37,709 --> 00:00:40,199 for /oracle. Because we've been 14 00:00:40,199 --> 00:00:42,809 doing a lot of work, the productivity 15 00:00:42,809 --> 00:00:45,269 has been increasing every day, the data 16 00:00:45,269 --> 00:00:47,459 is increasing every day. So of course, 17 00:00:47,459 --> 00:00:49,769 eventually, the databases gets bigger 18 00:00:49,769 --> 00:00:52,529 and bigger. So /oracle gets bigger. 19 00:00:52,739 --> 00:00:56,309 So what options do you have? Well, we 20 00:00:56,309 --> 00:00:58,949 can look at a few options. Number one 21 00:00:58,949 --> 00:01:00,869 would be like delete some of the older 22 00:01:00,869 --> 00:01:03,209 files to free up disk space, right? 23 00:01:03,209 --> 00:01:05,938 That's what the basic thing is. So if 24 00:01:05,938 --> 00:01:08,909 you have your room that is fully 25 00:01:08,909 --> 00:01:10,679 cluttered, and you don't have a room to 26 00:01:10,679 --> 00:01:12,479 walk around, what do you do? You take 27 00:01:12,479 --> 00:01:14,129 out the oldest stuff and throw it away, 28 00:01:14,129 --> 00:01:18,149 right? I hope so alright. Okay, so the other 29 00:01:18,149 --> 00:01:20,849 options that we have is, add a new 30 00:01:20,849 --> 00:01:23,549 physical disk and mount it to slash 31 00:01:23,579 --> 00:01:26,489 oracle2, meaning that if you have a 32 00:01:26,489 --> 00:01:29,939 physical system, then you could add a 33 00:01:29,939 --> 00:01:33,449 new disk in this physical system, if and 34 00:01:33,449 --> 00:01:36,689 only if, you have the slot, an extra slot 35 00:01:36,689 --> 00:01:39,689 to add an extra disk to that physical 36 00:01:39,689 --> 00:01:42,419 system. If you have it, perfect. You 37 00:01:42,419 --> 00:01:44,579 could partition it, you could configure 38 00:01:44,579 --> 00:01:48,059 it at your RAID level. And then you can 39 00:01:48,059 --> 00:01:53,099 mount it on slash or /oracle2, or 40 00:01:53,129 --> 00:01:56,039 if you have a virtual environment, which 41 00:01:56,039 --> 00:01:59,039 is the perfect scenario. And that's why 42 00:01:59,069 --> 00:02:00,629 I love virtual environment, because you 43 00:02:00,629 --> 00:02:03,179 don't really have to actually pull your 44 00:02:03,749 --> 00:02:06,269 server out, open the top and add a new 45 00:02:06,269 --> 00:02:08,369 disk. So if you have a virtual disk, all 46 00:02:08,369 --> 00:02:11,699 you have to do is go to your VM and add 47 00:02:11,788 --> 00:02:14,699 a new disk. And it takes literally a few 48 00:02:14,699 --> 00:02:18,569 seconds to do that. So, and then, once 49 00:02:18,569 --> 00:02:22,317 you add that, you do the same thing /oracle2. 50 00:02:22,317 --> 00:02:26,682 Now I want to extend my /oracle, 51 00:02:26,682 --> 00:02:28,919 I don't want to create another 52 00:02:28,919 --> 00:02:31,259 partition or other another mount point 53 00:02:31,409 --> 00:02:34,529 like oracle2, then what do I do? Well, 54 00:02:34,529 --> 00:02:38,009 you will be out of luck, if you had not 55 00:02:38,039 --> 00:02:41,909 used LVM initially. If you have, then 56 00:02:41,909 --> 00:02:43,859 my friend you are in luck, then you 57 00:02:43,859 --> 00:02:46,829 would extend your /oracle through 58 00:02:46,829 --> 00:02:49,619 logical volume manager. So no matter how 59 00:02:49,619 --> 00:02:53,009 many disk you attach, external disk or 60 00:02:53,039 --> 00:02:54,479 internal, this doesn't really matter, 61 00:02:54,479 --> 00:02:56,219 all you have to do is create a partition 62 00:02:56,219 --> 00:02:59,669 of the disk, and then attach that disk 63 00:02:59,849 --> 00:03:02,579 within the same group that you created 64 00:03:02,699 --> 00:03:06,209 for /oracle mount point. Now how 65 00:03:06,209 --> 00:03:08,519 does it work? Let's get into our Linux 66 00:03:08,519 --> 00:03:10,409 machine and we'll find out. Now before 67 00:03:10,409 --> 00:03:13,229 we get into a Linux machine, let's add, 68 00:03:13,679 --> 00:03:16,589 let's assume that we don't have a disk 69 00:03:16,589 --> 00:03:19,349 space. And we want to add a new disk to 70 00:03:19,349 --> 00:03:22,238 our virtual machine. So let's go to our 71 00:03:22,238 --> 00:03:24,362 [No audio] 72 00:03:24,362 --> 00:03:26,369 our machine powered off, of course, make 73 00:03:26,369 --> 00:03:27,809 sure it's powered off every time you 74 00:03:27,809 --> 00:03:30,809 have to add a new disk or add resources. 75 00:03:31,079 --> 00:03:36,029 Go to Setting, go to Storage, and then 76 00:03:36,029 --> 00:03:38,879 you will see you have three disks. The 77 00:03:38,879 --> 00:03:42,659 first one you have is about your own 78 00:03:42,659 --> 00:03:45,539 Linux operating system disks that you 79 00:03:45,569 --> 00:03:48,299 created initially, I think it's like 10 80 00:03:48,299 --> 00:03:51,809 gig. The second one you have is about 81 00:03:51,809 --> 00:03:54,179 the data disk, and the third one we added 82 00:03:54,209 --> 00:03:58,559 oracle, dataoracle which is one gig. So 83 00:03:58,589 --> 00:04:00,329 let's click here, and you will notice 84 00:04:00,329 --> 00:04:03,809 right here, the virtual disk size is one 85 00:04:03,809 --> 00:04:06,239 gig, but of course it is running out of 86 00:04:06,239 --> 00:04:08,969 space, we could extend it. Now remember 87 00:04:08,969 --> 00:04:12,329 one thing, other virtual environment like 88 00:04:13,679 --> 00:04:16,469 enterprise level VMware or even Oracle 89 00:04:16,469 --> 00:04:18,478 or Redhat virtual environment, you will 90 00:04:18,478 --> 00:04:21,869 be able to extend this disk space right 91 00:04:21,869 --> 00:04:24,659 here by right clicking and clicking on 92 00:04:24,899 --> 00:04:27,298 extend disk, but I believe since this is 93 00:04:27,899 --> 00:04:30,959 a PC version, personal version of 94 00:04:30,959 --> 00:04:33,869 virtual environments, you cannot extend 95 00:04:33,869 --> 00:04:35,339 that. So what do you have to do? You 96 00:04:35,339 --> 00:04:37,679 click on your Controller, add a new 97 00:04:37,679 --> 00:04:44,309 disk, Add Hard Disk, Create new disk, VDI, 98 00:04:44,489 --> 00:04:47,759 Next, Dynamically allocated, Next, and 99 00:04:47,759 --> 00:04:50,009 the Name, you could just name the same 100 00:04:50,009 --> 00:04:55,619 way as the other one, dataoracle, and 101 00:04:55,619 --> 00:04:57,899 put one here because of course sorry, 102 00:04:57,899 --> 00:04:59,639 you cannot name the exact same because 103 00:04:59,639 --> 00:05:02,249 it will conflict. So now this is the 104 00:05:02,249 --> 00:05:05,069 second disk. You know what, it's better 105 00:05:05,069 --> 00:05:07,319 you put 2, so this way it's easier to 106 00:05:07,319 --> 00:05:09,089 differentiate the first one and the 107 00:05:09,089 --> 00:05:11,819 second one. So this is a two, and I want 108 00:05:11,819 --> 00:05:14,789 to give it another extra one gig. Select 109 00:05:14,819 --> 00:05:17,849 one gig, and click Create. So it has 110 00:05:17,849 --> 00:05:20,369 created two disks. So basically what we 111 00:05:20,369 --> 00:05:22,409 are doing here is, we are combining 112 00:05:22,409 --> 00:05:26,249 Oracle data, sorry dataoracle with our 113 00:05:26,279 --> 00:05:29,129 dataoracle2. So that is done, now click 114 00:05:29,129 --> 00:05:34,589 OK, go ahead and hit power on or Start. 115 00:05:34,589 --> 00:05:45,389 [No audio] 116 00:05:45,389 --> 00:05:48,510 Okay, so we have logged into our Linux machine. Go 117 00:05:48,510 --> 00:05:53,040 ahead and become root. Now, let's run 118 00:05:53,040 --> 00:05:56,010 the df -h command, and the disk 119 00:05:56,010 --> 00:05:57,990 space or the partition that we are 120 00:05:57,990 --> 00:06:01,860 trying to extend is this right here. So 121 00:06:01,860 --> 00:06:04,200 if you look at it right now, this 122 00:06:04,980 --> 00:06:07,380 partition is mounted on /oracle. 123 00:06:07,770 --> 00:06:11,220 And the disk size is 997, which is like a 124 00:06:11,220 --> 00:06:14,850 1 gig, used is 33 meg, and available is 125 00:06:14,850 --> 00:06:18,810 965. Now, we are assuming, that right now 126 00:06:18,810 --> 00:06:22,080 the usage is instead of 4, it's 100%. 127 00:06:22,350 --> 00:06:24,840 So once we are going to add additional 128 00:06:24,840 --> 00:06:28,170 disk space to it, instead of 997 129 00:06:28,440 --> 00:06:33,000 megabyte it would become two gig. So let's go 130 00:06:33,000 --> 00:06:37,830 to our command fdisk -l, let's 131 00:06:37,830 --> 00:06:41,010 pipe it to more, and let's see what are 132 00:06:41,010 --> 00:06:43,950 the disk we have available, /dev/sda, 133 00:06:43,950 --> 00:06:47,250 which is the root disk, where we did 134 00:06:47,250 --> 00:06:51,420 installation, sdb is where we did, we 135 00:06:51,420 --> 00:06:56,520 created our data disk, then we have sdc, 136 00:06:56,730 --> 00:07:00,630 which is the Oracle disk that we used. 137 00:07:00,690 --> 00:07:02,790 So now we should also have the new one, 138 00:07:02,790 --> 00:07:06,780 which we just created with the label sdd. 139 00:07:06,780 --> 00:07:08,220 So let's see, hit Enter. 140 00:07:08,220 --> 00:07:10,350 [No audio] 141 00:07:10,350 --> 00:07:11,640 See, you're here, 142 00:07:11,970 --> 00:07:13,710 you're just have to be very careful, 143 00:07:13,740 --> 00:07:15,690 because sometimes it throws so much 144 00:07:15,690 --> 00:07:17,910 information on the screen, you can't 145 00:07:17,910 --> 00:07:20,490 really see where your disk is, anyway, so 146 00:07:20,490 --> 00:07:24,060 that's the disk, sdd, this is our new 147 00:07:24,060 --> 00:07:25,710 disk with one gigs. And now we're going 148 00:07:25,710 --> 00:07:28,230 to do, we're going to partition that 149 00:07:28,230 --> 00:07:30,750 disk, the same way we partition any other 150 00:07:30,750 --> 00:07:33,840 disk whenever we create a new one. So to 151 00:07:33,840 --> 00:07:40,096 partition the disk, you run fdisk /dev/sdd. 152 00:07:40,096 --> 00:07:43,530 And this is going to 153 00:07:43,530 --> 00:07:46,740 be your new disk, hit n for new, p for 154 00:07:46,740 --> 00:07:50,250 primary disk, hit Enter for default, or 155 00:07:50,250 --> 00:07:54,510 just hit one, whatever you like, hit 2048, 156 00:07:54,510 --> 00:07:57,930 or just hit enter to default. Hit enter 157 00:07:57,930 --> 00:08:01,350 again for default value, p for permission, 158 00:08:01,350 --> 00:08:03,300 you will see right here it says Empty. 159 00:08:03,900 --> 00:08:06,960 As soon as I assign 8e to it, it will 160 00:08:06,960 --> 00:08:12,240 see Linux LVM so hit t again, and l again, 161 00:08:12,240 --> 00:08:14,520 and you'll see this is a list of all the 162 00:08:14,520 --> 00:08:18,660 available file types that are assigned 163 00:08:18,660 --> 00:08:22,740 to it. So we just pick 8e again 164 00:08:22,740 --> 00:08:25,740 for Linux LVM, hit enter again, and now 165 00:08:25,740 --> 00:08:30,360 you'll see Linux LVM. Now this is the 166 00:08:30,360 --> 00:08:34,470 system that's using its type of file 167 00:08:34,470 --> 00:08:37,140 it's going to be assigning it to. Now you 168 00:08:37,140 --> 00:08:43,500 hit w to create that partition. So that 169 00:08:43,500 --> 00:08:47,004 partition is created, the partition is sdd1, 170 00:08:47,004 --> 00:08:49,860 you could do fdisk again, hit l 171 00:08:49,919 --> 00:08:53,280 and do pipe it to more, and you will see 172 00:08:53,460 --> 00:08:59,400 sdd1. So right here sdd1 it is 173 00:08:59,400 --> 00:09:04,350 created, perfect. Alright so now you 174 00:09:04,350 --> 00:09:08,100 could just reboot the system real quick. 175 00:09:08,430 --> 00:09:12,630 So it is updated to in the system again. 176 00:09:12,630 --> 00:09:17,610 [No audio] 177 00:09:17,610 --> 00:09:19,890 Okay, once you have your system back 178 00:09:19,890 --> 00:09:24,140 online, you will log back in and become root. 179 00:09:24,140 --> 00:09:27,711 [No audio] 180 00:09:27,711 --> 00:09:31,500 Do fdisk -l again, and this 181 00:09:31,500 --> 00:09:34,530 time just type /dev/sdd1, just to make 182 00:09:34,530 --> 00:09:37,830 sure it's there. It's there. Now it's 183 00:09:37,830 --> 00:09:40,783 time to extend the file system slash dev 184 00:09:40,783 --> 00:09:48,165 /dev/mapper/oracle_vg-oracle_lv. 185 00:09:48,165 --> 00:09:49,740 We are extending this one. 186 00:09:50,070 --> 00:09:53,010 So the file system gets bigger. So first 187 00:09:53,010 --> 00:09:57,000 we do pvdisplay, this will show us 188 00:09:58,410 --> 00:10:00,450 which group is associated with 189 00:10:00,450 --> 00:10:04,020 which disk. So our concern is right here, 190 00:10:04,050 --> 00:10:09,930 this one sdc1, and it is associated 191 00:10:09,930 --> 00:10:14,220 with group oracle_vg. You could 192 00:10:14,220 --> 00:10:17,070 also run pvs, it will also give you the 193 00:10:17,070 --> 00:10:19,170 same, pretty much the same information, 194 00:10:19,710 --> 00:10:22,410 this disk is associated with this group. 195 00:10:22,410 --> 00:10:26,880 So we want to add a new disk within this 196 00:10:26,880 --> 00:10:29,610 group. And once we add that new disk 197 00:10:29,610 --> 00:10:33,390 that we created, sdd, then we will 198 00:10:33,420 --> 00:10:35,700 extend the group and we will extend the 199 00:10:35,700 --> 00:10:42,361 logical volume as well. So, let's do vgdisplay, 200 00:10:42,361 --> 00:10:49,041 and let's do on our oracle_vg, 201 00:10:49,041 --> 00:10:50,640 this is our group. So you 202 00:10:50,640 --> 00:10:53,100 will see it also tells you the volume 203 00:10:53,100 --> 00:10:55,560 group size is worth 1020 megabytes, 204 00:10:55,590 --> 00:10:58,560 which again, of course is one gig. So 205 00:10:58,560 --> 00:11:01,855 now let's create physical volume. So 206 00:11:01,855 --> 00:11:07,500 pvcreate /dev/sdd1 because 207 00:11:07,500 --> 00:11:09,210 we always have to create physical 208 00:11:09,210 --> 00:11:13,500 volume. So, it is successfully created. 209 00:11:13,560 --> 00:11:19,560 Now we do in vgextend, we are extending 210 00:11:19,710 --> 00:11:22,020 the group with, what is a group name, 211 00:11:22,080 --> 00:11:23,039 oracle 212 00:11:23,039 --> 00:11:25,950 [Author typing] 213 00:11:25,950 --> 00:11:33,270 _vg, and we are associating that 214 00:11:33,270 --> 00:11:39,990 to /dev/sdd1. 215 00:11:39,990 --> 00:11:41,909 [No audio] 216 00:11:41,909 --> 00:11:45,389 Okay, so now it is extended with that 217 00:11:45,389 --> 00:11:47,519 disk partition because if you just say 218 00:11:47,519 --> 00:11:50,309 vgextend oracle_vg, it 219 00:11:50,309 --> 00:11:52,769 will say hey, I will extend it, that's 220 00:11:52,769 --> 00:11:56,879 fine. But which disk I should leverage 221 00:11:56,939 --> 00:12:00,329 on or step on or include that disk 222 00:12:00,329 --> 00:12:02,579 within me to extend, so you have to 223 00:12:02,579 --> 00:12:07,970 define that the disk is /dev/sdd1. 224 00:12:07,970 --> 00:12:10,949 Okay, so now that is done. 225 00:12:11,009 --> 00:12:15,659 Now let's do logical volume extended. So 226 00:12:15,659 --> 00:12:18,329 logical volume extent is right here. So 227 00:12:18,359 --> 00:12:21,569 you have to specify the size, which is, 228 00:12:21,659 --> 00:12:25,739 the command is -l, and plus the 229 00:12:25,739 --> 00:12:30,839 size so 1024, which is one gig, so just 230 00:12:30,839 --> 00:12:35,429 put meg here, and then you specify /dev/mapper, 231 00:12:35,429 --> 00:12:39,870 [Author typing] 232 00:12:39,870 --> 00:12:41,370 which is right here. 233 00:12:41,370 --> 00:12:45,360 [No audio] 234 00:12:45,360 --> 00:12:48,300 What I would do is, I will just move that, 235 00:12:48,300 --> 00:12:53,220 go up to our fdisk command, and I will 236 00:12:53,220 --> 00:12:56,730 just copy this entire thing. So I won't 237 00:12:56,730 --> 00:12:58,950 make a mistake, because this is the 238 00:12:58,950 --> 00:13:02,220 logical volume that eventually we want 239 00:13:02,220 --> 00:13:06,090 to extend. And now we come down and 240 00:13:06,090 --> 00:13:09,540 paste it right here. Okay, so now we 241 00:13:09,540 --> 00:13:12,120 have extended and it says logical volume 242 00:13:12,150 --> 00:13:15,920 oracle_vg/oracle_lv 243 00:13:15,920 --> 00:13:19,530 successfully resized, awesome. Let's 244 00:13:19,530 --> 00:13:22,290 extend the file system and the command 245 00:13:22,290 --> 00:13:31,583 to extend the file system is xfs_growfs. 246 00:13:31,583 --> 00:13:36,810 And then you hit Paste, hit enter, and that should 247 00:13:36,810 --> 00:13:41,100 grow your filesystem. df -h, and now 248 00:13:41,100 --> 00:13:45,270 you will say /dev/mapper/ 249 00:13:45,270 --> 00:13:51,870 oracle_vg, 2 gig, 33. oracle is now 250 00:13:51,870 --> 00:13:55,050 two gig. Remember we had it one gig, now 251 00:13:55,050 --> 00:13:58,230 is two gig. That's how you extend a file 252 00:13:58,230 --> 00:14:00,720 system. Once you extend it, you go back 253 00:14:00,720 --> 00:14:03,720 to your Oracle guy, tell him you have 254 00:14:03,720 --> 00:14:06,450 added a new storage to your existing 255 00:14:07,140 --> 00:14:10,597 mount point, you did not have to create /oracle2. 256 00:14:10,597 --> 00:14:11,904 [No audio]