Linux Foundation LFCS – Domain No. 6 – Storage Management

  1. Disk partitions

Hello started the very last section of our entire course, which is called Storage Management. And in this we get to learn how to create how to list create delete partitions on MBR and GPT kind of disks. So a disk can be used as a simple entity or broken up into one or more partitions that generally call dev SDA or dev SDB, et cetera in physical servers or Escalate, even though they’ve got IDs at our SAS interfaces and deva ordev et cetera. In virtual machines, partitions get their names from the disk name itself and add a number string at one starting at one dev SDA, one ordevsda two, et cetera, ordeva one ordevda two for virtual machines. A partition table is a special structure containing partitions organization. So no recent disks or the nearly used disks used 512 byte sectors anymore.

And the MBR partition table MBR stands for Mass addition, allows for four primary partitions only. If you want more than that, you need to create an extended partition using one of the four primary slots and then create logical partitions inside. More frustrating part of that is on disk with capacity greater than two terabyte space above this limit is not available to work around all these limitations. Recent disks are 40 96 byte sectors and the GPT partition table GPT, by the way, stands for Guid Global Unique Identifier Partition Table. Historically, two commands exist to manipulate disks and partitions in their Fdisc and parted. As the Fdisc command doesn’t handle GPT partition tables, it is not advisable to use it anymore. Recently, a new tool called Gdisc has been created to deal with GPT partition tables offering an alternate to the parted command.

  1. SWAP partition

Hello students. In this lecture we are going to learn how to add swap space on a Centaus or Red Hat Seven machine. So one of the easiest ways to make your server more responsive and guard against OutOfMemory errors in your application is to add some swap space. Swap is an area on a storage drive live where the operating system can temporarily store data that it can no longer hold in memory. This gives you the ability to increase the amount of information that your server can keep in its working memory. With some caveats reading from and writing to soft is slower than using memory, but it can provide a good safety net for when your service is low on memory. Without a swap, a server that runs out of memory may start killing applications to free up memory or even crash. This can cause you to lose unsafe data or experience downtime.

To ensure reliable data access, some applications require swap to function. So in order to configure swap, you have to have root access, of course, to the machine. So before we begin, we should take a look at our services storage to see if you already have some swap space available. While we can have multiple swap files or soft partitions, one should generally be enough. We can see if the system has enough configured swap by using swap on. So it’s swap on and if we do a dash S, it’ll show us a summary. And this is our swap partition 104 megabyte. Sorry, 104 gigabyte. So if this command returns nothing, then the summary was empty and no soft file exists. Another way to checking for soft space is with the free utility.

So you can type in free M. This will show us free megabyte available. Now, if you want to check the available disk space, you do a DFH and it’ll show you the disk space that you have available on your system. So the H flag simply tells DH to output drive information in a human friendly reading format. For example, instead of outputting the raw number of memory blocks in a partition, DFH will tell us the space usage and availability in megabytes or gigabytes. As you can see on the first line, our storage partition has 930gb out of which 2. 2 gigabyte is used and 928gb is still available. Okay, now let’s create a soft file. So type in pseudo. Oh, sorry, we don’t have to do so because we already route. We’ll do fall allocate l 4GB. Suppose if you want to do four gigabyte and the file is swap file. Okay, after entering your command, we can verify that it’s created or not LS swap file. And as you can see, our four gigabyte swap file has been created. Okay, so so far our system is not aware that we have created a swap file, so it’s not going to account for it. So in order to do that, first we need to change the permissions on this chmod 60 zero soft file.

Basically, if you remember our file permission lecture, this is basically stopping other users from writing or executing anything on the soft file. I’m going to go into the history and as you can see, if you compare the two permissions before, the others had read access. Now they have none. Only the owner has read write X. So that’s what our gem at 600 did and now we can tell our system to actually use it so we’ll do MK swap for make swap file now just to double check and verify swap on swap file on S. It shows the total swap that we have available on this machine. We can also confirm this from free m and if we want to make our swap file permanent vcnvi Betsy’s tab. And we can add this line here. Oh. And then swap file swap SW. Basically we are telling the system to use the soft file that we have just created. And another way you can test if your soap has been added is run a cat on Procsisvm Sloppiness and it’ll give you a 50 because 40 we just added and ten it already has.

  1. LVM – Logical Volume Manager

Hello students and welcome. In this lecture, we’re going to discuss Logical volume. Manager It’s a very important topic certification wise also in real life Linux system administration. So Logical Volume Manager LVM introduces an extra layer between the physical disks and the file system, allowing file systems to be resized and moved easily and online without requiring a system wide outage. It also uses discontinuous space on the disk so that way there is no wastage of disk space. It gives meaningful names to volumes rather than the usual cryptic device names that people don’t understand. And also it spans multiple physical disks. So there are some LVM concepts that we need to familiarize ourselves with. And as you can see in this picture, this file system logical Volume, Volume Group and Physical Volumes. So Physical Volume each Physical Volume can be a disk partition, a whole disk, a met advice or a loopback file. And we use PV Create to initialize storage for use by LVM.

Initializing a Block device as Physical Volume places a label at the start of the device. Next one is Volume Group. A Volume Group gathers together a collection of logical volumes and physical volumes into one administrative unit. Volume Group is divided into fixed size physical extents. The command VG create creates a new volume group using the Block special device physical Volume Path previously configured for LVM with PV create Volume Groups are made up of physical volumes which in turn are made up of physical extent or PES. The size of PE can differ in different VGS and is defined at the time of creating VGS. The defile size of PE is four megabyte, but you can change it to the value you want at the time of VG creation. Generally, larger the p size, better the performance. Third one is logical volume. A logical Volume is the conceptual equivalent of a dis partition in a non LVM system.

Logical volumes are blocked devices which are created from the physical extents present in the same Volume group. You can use command Lvcreate to create a logical volume in an existing Volume Group. And at last we have file system. File Systems are built on top of logical volumes. The command mkfs can be used to create File System on top of a logical volume. Once the file system is created, we can mount the logical volume as per hour need. Okay, let’s start working on Logical Volume Manager to see how it’s configured. I’m logged into my machine right now.

I’m going to do a switch user to become root user on this machine because all the work will be done as super user. The first command that you’re going to run our machine is LVM Disk Scan and it gives me a rundown of what I have configured so far disk wide and spacewise. So I have ten gigabyte of root partition, 500 megabyte of SDA One under twelve gigabyte of SDA Two, and then a home directory which is 1GB so I have three disks, I have one partition, and I have zero LVM physical Volume whole disks. So first thing we’re going to do is initialize the block devices. Okay? So the first command we’re going to run is Pvcreate. And I’m going to use Slash Dev SDA One to create the physical volume. Physical volume is created successfully. And now we’re going to run PV Display. And we use these commands PV Display or PBS or PV Scan to display the physical volumes that we have just created.

Now we can run a PV scan to scan all the disks we have, and we have an SDA One, which is LVM 2500 gigabyte. And we’re going to run PBS. And that pretty much displays the similar information as well. So these are some of the ways that you can actually display the configuration after you have created the Volume Group, like Physical Volume, not the Volume Group. Now we’re going to create the volume group VG. Create? Well, let’s call it VGO One. As Volume Group Number One. Dev slash SDA One successfully created Volume Group One. And now you display VGS VG one. This is a successfully created volume group. Also, if you were to run VG Display VGO One, give you more details about it, about the format, about the access, read, write the status is resizable Volume Group size, physical Extent Size. So you can activate and deactivate VGS also.

So the way you do it is VG change anvg One. And if you can see on the left hand side it says zero logical volumes in Volume Group VG One not active. So that means it’s been deactivated. Now to activate it again, you’re going to run the same command, except instead of N, we’re going to change. Next, we’re going to create the logical volume. The logical volume can now be created in the Volume Group using the LV Create command. If you do not specify the logical volume name in the command, by default, the LV is given the name L vol and then a number. So normally, if you do not specify which PV to span the LV, logical volume will be created on the PV on a next free basis. To create a logical volume, LVol one of size five gigabyte. This is how we do it. Lvcreate I’m going to create a smaller logical volume. Let’s say 100 met. NL Wall. One. PG. One.

Okay? And the logical volume has been successfully created. And the way you display it is LVS dev VGO one Lalo one. This is our logical volume. And we created 100 megabytes. And that’s what’s showing if we were to do an LV scan at this point. Let’s see. And as you can see, our 100 megabit logical volume that we just created is active now. And now we are at the last step of configuring this. So we’re going to create a file system. So the final step to create a file system on the new logical volume we just created and mounted on our directory to be able to access it and it stored data in it. The command mkfs be used to create logical to create file system on top of the logical volume. So mkfs is a command. We’re going to create an extension four type of file system ext four Devg one lball one killer let’s create a directory call Data One data One. Now we’re going to mount our newly created volume dev BG one l wall one on Data One and we’re going to create in the Etsy FS tab file an entry for this. So we go to shift G to the bottom of the file and then press O to create an empty line. And then we’re going to add slash dev slash VGO one, slash Lalo one and it is mounted on slash Data One. So that way now it’s hard coded and it’ll survive a reboot as well. And if we were to do DF dash H at this point on slash Data One we see that our file is there, our variable volume is there that we just created.

img