CompTIA Linux+ XK0-005 – Unit 06 – System Configuration Part 2

  • By
  • August 3, 2023
0 Comment

11. parted – Partition Editor

So one of the other optional tools that you can use for creating a partition is a tool called Parted. Now Parted we say, is text mode, which just means it’s a command line tool. Now, you won’t find it on every single distribution of Linux. It’s not automatically there, fdisc is, which is why we talked about it first. It’s also a very old program and it takes extra steps. Now, the syntax for Parted is pretty straightforward word. You type in the command Parted, you’ll have some options. Now, I’m not going to go through and tell you all of the different options. Use your help files, use the man page to see what those options are. But some of the things you do have to tell me of course, is information about the type of device.

Remember, those device files are found in the dev directory. So you tell me the type of device that I’m creating, then what you choose as an alternate command or a part of the command is the type of file system you want me to use. So that’s what’s nice about this tool is I don’t just make the partition, then run the command make FS for creating the file system. I can put it all into one. So Parted, tell me the device file that I’m using to tell me about the device, the make FS command, tell me the type of file system you want and then give me the start and stop range of addresses so I know how big of a partition that I need to make. So it’s a pretty straightforward program that you can let you do it all in one.

12. GParted

Some of you don’t like the command line. I’ve said that over and over again, and that’s fine. I’m kind of a command line person because that’s how I grew up in this technology. But there is another choice you have, like Parted, called G Parted. Now it stands for the Ghana Parted program, which should be a part of the Ganon desktop environment. It is the graphically going to do what Parted did for you, but because of the graphical nature, it’s probably going to be a lot easier to not only see existing partitions, but to make options to choose all the cool things that I told you on the command line. If you don’t know the options, go look at the man pages, go look at the help. This will just show you the options that you have.

And that’s the nice thing about a Gui.The downside, of course, though, is you can’t script the GUI. You can’t schedule it to run. I’m not saying that I’m going to schedule my partition stuff to run all the time, but I can certainly script it so that as new systems come in, I could just run that as a script and then be done. Anyway. Again, I’m trying to give you both sides. G partner is a great tool to do the same thing. You tell me the type of partition you want to make, how it’s going to be formatted, what sizes it’s going to be, and it handles handles that for you right there on the spot. And it makes life pretty straightforward and easy to add new volumes, to create new partitions, or to do whatever you need.

13. Demo – Exploring Partitions with fdisk

All right, we’re back to my backtrack, my KDE, and we’re going to take a look at some of the fdisc commands and we’re going to do a little Fdisc help here to see some of the options. And the Fdiscl, as I see here, is designed to list all the partitions that I have or give the size and blocks if I use the US. And changing partition tables. Well, I just want to see what we have. So I’m going to do Fdisc L. And if you remember, this is a virtual machine environment. So I have a virtual drive that I said originally it was supposed to be four gigs in size when I put it together. And so it’s showing up here. It looks like SDA. And really, I haven’t done anything with it to partition it or anything else. This is actually running in the memory of the virtual machine.

So I actually haven’t installed this to the hard drive and if I had, it would be there and ready to use all the time. But anyway, I’ve got this four gig hard drive and I haven’t done anything with it. So let’s actually run the Fdisc against that device, the SDA. And there it says M for help. So I’m going to hit the letter M and watch out. Bam. Across the screen comes all of these commands. So I’m going to do L to list the partition types. You can see that I can support Fat, fat 32, fat twelve, Nobel. I mean, I can support a lot of different hard drive types. I’ll do the M again. And now let’s take a look and see if we can look at what kind of partitions we have. And right now, we actually don’t have any partitions because we saw that when we did the original F disk.

So I could try V to verify the partition table. But I have all of these unallocated sectors. It means I’ve just done nothing to it. So what I’m going to do is I’m going to add a new partition. I’m going to create the new one N, and we’re going to make it a primary partition. I’ll make it partition number one. And the first cylinder by default will be the first one of one. And the last cylinder that I’m going to use, it says I can make a choice. The default is 522. That would be the last cylinder I have. Or it says I can use the plus size, the plus size M or the K to make a change. I’ll take the default 522 and now I’ll click M for help and let’s see if we can list the partitions that I have on there. Basically, I’ve added that partition and I could try to P for printing the partition table.

And there is my partition. It looks like it says that it starts at cylinder one, goes to cylinder 522, and has the number of blocks that I’m using. The only thing I have to do is actually write that if I want to. And once I write that, syncing the disk, now I’m out of there. So let’s do the fdisc again, L, and we can see that I have a partition. Now, I haven’t actually gone out of my way to format the thing, but at this point, I was able to create a primary partition. I made one primary partition, and I did it on this virtual drive that I have. So the idea was just to kind of take you through a little list of how I can go through and put things together, and hopefully it made some sense to you that you can use Fdisc to make partition changes.

The good news is that I didn’t have anything on that partition because, again, it may sound a bit confusing, but technically I have a Ram drive that is running the actual virtual machine from the installation. So I didn’t have any operating system to wipe out on this one drive that I have in this environment. I don’t think that if you had a permanent installation on the drive you’d want to do the things I just did, it would, in effect, probably destroy your installation installation. That is, if you wrote over any existing partitions that you’re using to boot from. All right, so I just have kind of the drives up and ready to go if I ever did want to format it. But that was working with Fdisc and the command line.

14. Demo – Exploring Partitions via the GUI

So we’re going to take a look at exploring the partitions with the graphical user interface. Now, I know that we talked a bit about one called G Parted, but there are many different types of devices out there that are or programs that are utilities that you can run in a graphical environment. And in this particular case, the Fedora that I’m using doesn’t have G Parted, but it has this pallet set. I don’t even know how to pronounce it honestly, but it’s their version of the disk utility and it’s just as good as any other that you can use out there. And if you wanted to, you could load G Parted as a package and probably install that just fine. All right, so I do have two virtual drives that I’ve set up and each one that I created was four gigs in size.

So I like what I’m seeing here that I see the two drives being set up for me. And this one tells me I have a file system that’s 210 megabytes in size. And this is kind of what it says is file system partition one. And then I have over here file system partition two. Now the question then becomes is why do I have these two partitions? Well, if you remember that one of the goals of having these partitions or of doing any of the formatting is that you end up with partitions for different variety of reasons. In this case, I have a partition that says mounted at the boot and it can be edited. It is a bootable partition and it’s not very big. In fact, it’s roughly equal to the amount of memory that I have.

Then I have this big physical volume here that says the different type of version that it is and that it’s the Linux physical volume. And it tells me how it’s been set up. Basically, in the types of file systems you can see a number of different options with the file systems. Okay? So remember, we were supposed to have two partitions, one for my swap, one for the rest of my files and that’s how this first hard drive has been broken down. Now on this particular hard drive here, this one says it’s 4. 3 gig hard drive has 4. 3 gigs available space. It has that because it is not being used, I have yet to format it. So we’ll wait a little later on and try some of the commands like the make FS to do that. Also notice that it’s listed as SDB under devices.

When I come back to the first one, it is listed as SDA. All right? So when I click on the free allocated space, you see I have some options that open up, allowing me to create a label to use a type of file system, even encrypting the underlying information. And then finally, I also have CDROM drive that it does recognize, but I have no CDs in there. So there’s nothing for it to detect. All right, so I know it’s kind of a quick little tour, but the idea here is I don’t want to mess with the partitions that I have for my operating system. If we wanted to try to create a new array because we have multiple drives, but that’s an option here as well. I can’t necessarily unmount this or do any other quick work with this particular setup, but I can partition the free space that I have.

So there are some options out there, and you can see that you can check file systems if you want to do some help. Let’s take a look here. Let’s go to this file system here. And I can even erase things if I’m not careful. That might also be just a bit dangerous, so I’m going to quit and jump out of that particular application. But it’s just nice to see that you can move around and you can do a lot of cool things as you’re playing with some of these applications. And again, it might not be called G parted, but certainly you have different programs, different Gui’s that you can use depending on your distribution to accomplish pretty much the same variety of tasks.

15. Formatting

Now, as I said, formatting with the FDIs command doesn’t occur. You have to do that manually. There is a straightforward command. In fact, it was one we added with the parted command, which is called make FS or mkfs. Basically it’s just saying make this file system and then use the dash t to tell me the type and you choose the type. Again, the extended file system, whatever you want to do. And of course then tell me which device that I’m going to do that with.

There are some other types of programs as well that you can use to verify that the file system was done well. The fsck is the file system check or you can check it for errors. And its job was to verify basically that your file system not only was created, but it looks like it’s running and that’s error free. Always a good choice because again, a hardware device like a hard drive doesn’t necessarily mean it isn’t without its own errors, its own bad sectors. So you can kind of do all of that after you do the formatting.

16. Demo – Formatting a Partition with mkfs

Well, I have an entire hard drive, virtual drive, but the machine thinks it’s a hard drive. It has four gigs in size and we’re going to use the mkfs to basically partition it, or not partition it, but to format it. So we’re going to use the T and we’ll use the extended file system, the third extended file system, and it was the SDB drive. And what’s going to happen here is that I have it set up with no partitions. So it’s telling me it’s going to be the entire device. Do I want to proceed? So I’m going to say yes, go ahead and do that. And there you can see that it’s done and created the INO tables. It created the Journal Superblocks file system, automatically checked every 31 mounts.

And basically I have finished and I now have that information done and ready to go. Now, one of the things I didn’t do is I didn’t actually look to see if I should have mounted it, but I’ll look at that in just a second. In fact, we could do an Lsdevsdb, see what we have on there and nothing on there, so it’s pretty empty as far as a location. But one of the next things we’ll do is we’re going to look to see if we can make some changes, if we can check to make sure everything else looks good. So we’re going to take a look at the file system check. Let’s see if this command is supported here. All right, so now what we’re going to do is we’re going to look at some of the options.

We’re going to do the dash P to do an automatic repair with no questions should there be any problems. And we’re going to do that with the file system that we just created. So we’re going to do the file system CHECKP and the device was SDB, and because we said to do so without any input from us and if there’s any problems, just to do it. And it looks like it’s clean. It gave me a good report. All right, so the next thing I’m going to do then is look to see if I can make a new directory. And what I’m going to do basically is make a directory for that device that I have, the SDV. And actually I’m going to call it, let’s see, I don’t want it to be exactly that path. I actually want to put it in the mount directory and I’m going to call it Ken’s Drive.

Let’s just give it a nice big name so I can now do an Lsmnt. And there’s that in the mount folder. Anyway, ken’s Drive, which is what I wanted to have. So I have my folder or my file, as we would say. The next thing I’m going to do is mount and the dash T, we made it an extended or third extension and it’s the device SDB and we’re going to put it in the slash mount Kensdrive. And now that we have that in there, we can try to do an LS of what’s in that drive. And really, there’s nothing in there other than lost and found that was created by mounting that in. Okay, so just like that, we’ve done a little bit of work. If I wanted to, I could start adding files into that particular drive because it is formatted, it is mounted, and I have a path to be able to get there.

Of course, I did the LS, and there’s nothing in at this particular time, but I could certainly CD mount KENS drive and LS in there. And again, just lost and found is all I see. LSL capital F tells you that it’s a folder, and it’s ready for me to make any other file that I wanted to touch my file. Boom. LSL capital F. And it looks just like a regular hard drive. So there we formatted it. We mounted it into the mount folder called that Ken’s drive. It acts like a file itself, even though it is a hard drive that’s four gigs in size. And we can begin to create our files just like any other location.

17. The /etc/fstab File

Now, once you make this partition, you format it and mount the thing you’re not done, because when you reboot, it appears to be gone. Now, it doesn’t mean that you have to make the partition again and reformat it again. In fact, if you did that, you would destroy the partition you had, the formatting would erase the record of the files you had stored, and until you went into a forensic exam M, you would not be able to get that stuff back. So that’s not a good thing. What it means is if you reboot the system, you just have to remount the drive that you know is already there.

That also can be very annoying. So in the Etsy directory is a file called FS tab. Basically, that’s keeping track of all the file systems. And you can define which file system you want mounted or basically predetermine, which are going to be mounted at the reboots. And that’s what you put into this file. So open up the FS tab and you say, here’s the device, here’s the file system. Basically, you’re putting the mount command in so that when you boot up, all that work you’ve done is right there, ready to go.

18. The fstab with New Drives

Again, the FS tab can also be used with new drive. So let’s say you’ve not rebooted. You’ve got this new drive and you want it to be automatically detected. Well, you can also put information into FS tab for your new drive so that when you do get ready to mount the thing, that it can read that information, know what it needs for the command, and kind of help you in the automation process. Now, you’ll see some examples as we go through, and we do some of that work for you. But we talked about this before, again, about these files in the Etsy drive, in the Etsy directory. Anyway, that can help you with the automatic configurations. So we can have help with making new drives by having it previously created, having a template of how to create it. And we can help you in making sure when you reboot that it’s still there.

* The most recent comment are at the top

Interesting posts

IBM Certified Data Scientist: Building a Career in Data Science

In today’s digital age, data is the new oil, driving decision-making and innovation across industries. The role of a data scientist has become one of the most sought-after positions in the tech world. If you’re considering a career in data science, obtaining the IBM Certified Data Scientist certification can be a game-changer. This certification not… Read More »

How to Balance Work and Study While Preparing for IT Certification Exams

Balancing work and study while preparing for IT certification exams can feel like an uphill battle. Juggling a full-time job and intense study sessions requires careful planning, discipline, and creativity. The pressure of meeting job responsibilities while dedicating time and energy to study can be overwhelming. However, with the right strategies and mindset, you can… Read More »

10 Highest Paying IT Certifications

In the ever-evolving world of information technology, certifications are more than just a feather in your cap – they’re a ticket to higher salaries and advanced career opportunities. With the tech landscape constantly shifting, staying updated with the most lucrative and relevant certifications can set you apart in a competitive job market. Whether you’re aiming… Read More »

Strategies for ISACA Certified Information Systems Auditor (CISA) Exam

Are you ready to take your career in information systems auditing to the next level? The ISACA Certified Information Systems Auditor (CISA) exam is your ticket to becoming a recognized expert in the field. But let’s face it, preparing for this comprehensive and challenging exam can be daunting. Whether you’re a seasoned professional or just… Read More »

Preparing for Juniper Networks JNCIA-Junos Exam: Key Topics and Mock Exam Resources

So, you’ve decided to take the plunge and go for the Juniper Networks JNCIA-Junos certification, huh? Great choice! This certification serves as a robust foundation for anyone aiming to build a career in networking. However, preparing for the exam can be a daunting task. The good news is that this guide covers the key topics… Read More »

Mastering Microsoft Azure Fundamentals AZ-900: Essential Study Materials

Ever wondered how businesses run these days without giant server rooms? That’s the magic of cloud computing, and Microsoft Azure is a leading cloud platform. Thinking about a career in this exciting field? If so, mastering the Microsoft Certified: Azure Fundamentals certification through passing the AZ-900 exam is the perfect starting point for you. This… Read More »