Are you sure you want to cancel your subscription?

If you cancel, your subscription will remain active through the paid term. You will be able to reactivate the subscription until that date.

Sorry to see you go

Your subscription will remain active until . If you change your mind, you may rectivate your subscription anytime before that date.

Are you sure you want to reactivate?
Welcome Back!

Your subscription has been reactivated and you will continue to be charged on .

Reactivate Subscription

Thank you for choosing to reactivate your subscription. In order to lock in your previous subscription rate, you owe: .

Your Subscription term is from - .

Questions? Call Sales.

541-284-5522
Payment Due:

OK
Auto-Renew Subscription

To auto-renew your subscription you need to select or enter your payment method in "Your Account" under Manage Payments.

Click continue to set up your payments.

CBT Nuggets License Agreement


Unless otherwise stated all references to “training videos” or to “videos” includes both individual videos within a series, entire series, series packages, and streaming subscription access to CBT Nuggets content. All references to CBT or CBT Nuggets shall mean CBT Nuggets LLC, a Delaware limited liability company located at 44 Country Club Road, Ste. 150, Eugene, Oregon.


A CBT Nuggets license is defined as a single user license. Accounts may purchase multiple users, and each user is assigned a single license.


  • GRANT OF LICENSE. CBT Nuggets grants you a non-transferable, non-exclusive license to use the training videos contained in this package or streaming subscription access to CBT content (the “Products”), solely for internal use by your business or for your own personal use. You may not copy, reproduce, reverse engineer, translate, port, modify or make derivative works of the Products without the express consent of CBT. You may not rent, disclose, publish, sell, assign, lease, sublicense, market, or transfer the Products or use them in any manner not expressly authorized by this Agreement without the express consent of CBT. You shall not derive or attempt to derive the source code, source files or structure of all or any portion of the Products by reverse engineering, disassembly, decompilation or any other means. You do not receive any, and CBT Nuggets retains all, ownership rights in the Products. The Products are copyrighted and may not be copied, distributed or reproduced in any form, in whole or in part even if modified or merged with other Products. You shall not alter or remove any copyright notice or proprietary legend contained in or on the Products.
  • TERMINATION OF LICENSE. Once any applicable subscription period has concluded, the license granted by this Agreement shall immediately terminate and you shall have no further right to access, review or use in any manner any CBT Nuggets content. CBT reserves the right to terminate your subscription if, at its sole discretion, CBT believes you are in violation of this Agreement. CBT reserves the right to terminate your subscription if, at its sole discretion, CBT believes you have exceeded reasonable usage. In these events no refund will be made of any amounts previously paid to CBT.
  • DISCLAIMER OF WARRANTY AND LIABILITY. The products are provided to you on an “as is” and “with all faults” basis. You assume the entire risk of loss in using the products. The products are complex and may contain some nonconformities, defects or errors. CBT Nuggets does not warrant that the products will meet your needs, “expectations or intended use,” that operations of the products will be error-free or uninterrupted, or that all nonconformities can or will be corrected. CBT Nuggets makes and user receives no warranty, whether express or implied, and all warranties of merchantability, title, and fitness for any particular purpose are expressly excluded. In no event shall CBT Nuggets be liable to you or any third party for any damages, claim or loss incurred (including, without limitation, compensatory, incidental, indirect, special, consequential or exemplary damages, lost profits, lost sales or business, expenditures, investments, or commitments in connection with any business, loss of any goodwill, or damages resulting from lost data or inability to use data) irrespective of whether CBT Nuggets has been informed of, knew of, or should have known of the likelihood of such damages. This limitation applies to all causes of action in the aggregate including without limitation breach of contract, breach of warranty, negligence, strict liability, misrepresentation, and other torts. In no event shall CBT Nuggets’ liability to you or any third party exceed $100.00.
  • REMEDIES. In the event of any breach of the terms of the Agreement CBT reserves the right to seek and recover damages for such breach, including but not limited to damages for copyright infringement and for unauthorized use of CBT content. CBT also reserves the right to seek and obtain injunctive relief in addition to all other remedies at law or in equity.
  • MISCELLANEOUS. This is the exclusive Agreement between CBT Nuggets and you regarding its subject matter. You may not assign any part of this Agreement without CBT Nuggets’ prior written consent. This Agreement shall be governed by the laws of the State of Oregon and venue of any legal proceeding shall be in Lane County, Oregon. In any proceeding to enforce or interpret this Agreement, the prevailing party shall be entitled to recover from the losing party reasonable attorney fees, costs and expenses incurred by the prevailing party before and at any trial, arbitration, bankruptcy or other proceeding and in any appeal or review. You shall pay any sales tax, use tax, excise, duty or any other form of tax relating to the Products or transactions. If any provision of this Agreement is declared invalid or unenforceable, the remaining provisions of this Agreement shall remain in effect. Any notice to CBT under this Agreement shall be delivered by U.S. certified mail, return receipt requested, or by overnight courier to CBT Nuggets at the following address: 44 Club Rd Suite 150, Eugene, OR 97401 or such other address as CBT may designate.

CBT Nuggets reserves the right, in its sole discretion, to change, modify, add, or remove all or part of the License Agreement at any time, with or without notice.

Billing Agreement


  • By entering into a Billing Agreement with CBT Nuggets, you authorize CBT Nuggets to use automatic billing and to charge your credit card on a recurring basis.
  • You agree to pay subscription charges on a monthly basis, under the following terms and conditions:
    • CBT Nuggets will periodically charge your credit card each monthly billing cycle as your subscription charges become due;
    • All payments are non-refundable and charges made to the credit card under this agreement will constitute in effect a "sales receipt" and confirmation that services were rendered and received;
    • To terminate the recurring billing process and/or arrange for an alternative method of payment, you must notify CBT Nuggets at least 24 hours prior to the end of the monthly billing cycle;
    • You will not dispute CBT Nugget’s recurring billing charges with your credit card issuer so long as the amount in question was for periods prior to the receipt and acknowledgement of a written request to cancel your account or cancel individual licenses on your account.
  • You guarantee and warrant that you are the legal cardholder for the credit card associated with the account, and that you are legally authorized to enter into this recurring billing agreement.
  • You agree to indemnify, defend and hold CBT Nuggets harmless, against any liability pursuant to this authorization.
  • You agree that CBT Nuggets is not obligated to verify or confirm the amount for the purpose of processing these types of payments. You acknowledge and agree that Recurring Payments may be variable and scheduled to occur at certain times.
  • If your payment requires a currency conversion by us, the amount of the currency conversion fee will be determined at the time of your payment. You acknowledge that the exchange rate determined at the time of each payment transaction will differ and you agree to the future execution of payments being based on fluctuating exchange rates.

CBT Nuggets reserves the right, in its sole discretion, to change, modify, add, or remove all or part of the Billing Agreement at any time, with or without notice.

LPI Linux LPIC-1 101 and CompTIA Linux+

Maintain the Integrity of Filesystems

This video is only available to subscribers.
Start your 7-day free trial today.

A free trial includes:

  • Unlimited 24/7 access to our entire IT training video library.
  • Ability to train on the go with our mobile website and iOS/Android apps.
  • Note-taking, bookmarking, speed control, and closed captioning features.

LPIC1 & CompTIA Linux+ Intro

Hardware Settings

Boot the System

Change Runlevels and Reboot or Shutdown the System

Design Hard Disk Layout

Install a Boot Manager

Manage Shared Libraries

Debian Package Management

RPM & YUM Package Management

Work on the Command Line

Process Text Streams Using Filters

Perform Basic File Management

Use Streams, Pipes, and Redirects

Create, Monitor, and Kill Processes

Process Priorities

Search Text Files with Regular Expressions

Perform Basic File Editing Operations Using vi

Create Partitions and Filesystems

Maintain the Integrity of Filesystems

00:00:00 - Welcome to Nugget 104.2 where we talk about maintaining
00:00:04 - the integrity of filesystems. Filesystems like those we made
00:00:08 - in the last nugget. Now there's three main objectives that we
00:00:11 - have to do. We have to learn how to check the integrity of a
00:00:14 - filesystem, monitor their free space or inodes, I'm going to
00:00:17 - talk about inodes a little bit so we can understand those
00:00:20 - and then how to repair simple problems. Now this is the order
00:00:24 - they are listed in the objectives, but really I'd like to talk about
00:00:27 - monitoring free space and inodes so we actually know
00:00:30 - what inodes are when we learn about checking integrity and repairing, all right.
00:00:34 - So let's actually start with the middle one and then
00:00:36 - we'll do the other two after that. Let's look at the command line.
00:00:41 - The first command we're going to learn is df for disk free.
00:00:44 - And basically it's pretty simple. You type df and press enter
00:00:48 - and it gives us a bunch of information. Now, it measures
00:00:52 - every mounted filesystem. Now, a lot of these are done by Ubuntu
00:00:56 - for things like oudev is something you'll learn about.
00:01:01 - You learned about it a little bit in the early nuggets, but we'll learn about it
00:01:04 - a lot later in different LPIC exams. But basically you can
00:01:08 - look for things that look familiar here to know
00:01:11 - that they are actual filesystem in a block device. For example,
00:01:14 - /dev/sda1, this is our small 10-gigabyte drive and it shows
00:01:19 - you the output in one-kilobyte blocks. I prefer to actually
00:01:22 - use the the df-h for human readable flag, because what
00:01:27 - that does it prints out the information in
00:01:30 - numbers that make sense to us like 9.4 gigabytes
00:01:34 - instead of, you know, 9835552 one-kilobyte
00:01:39 - blocks, okay. So df-h is what I usually use and it
00:01:43 - shows us a few things. It shows us where the filesystem is,
00:01:47 - yu know, like what the block device is. So like this is our drive A.
00:01:50 - This is the one that we formatted in the last nugget.
00:01:53 - It shows us how big it is, how much is used, how much is available.
00:01:57 - If you do the math, this plus this should equal this.
00:02:02 - It shows us a percentage of what's used and then where it's mounted.
00:02:05 - Now, what I mean by mounted is where it's mounted in
00:02:08 - the filesystem. We're going to learn about mounting and unmounting in
00:02:11 - a couple of nuggets. But right here is the place that it exists
00:02:15 - in the filesystem, okay. And the same thing with this one down here,
00:02:18 - /dev/sdb1 that we formatted,
00:02:22 - it exists in the filesystem under /mnt for mount drive 2.
00:02:27 - That's just arbitrarily the place that I mounted it, okay.
00:02:30 - So we, we can see that it is an 18-gig partition with
00:02:35 - 173 megs in use and 17 gigabytes available.
00:02:40 - Now, df will show one more thing. If we do df-i,
00:02:46 - it will show us inodes. And now I want to explain inodes a little bit.
00:02:50 - Basically like we have this filesystem, you know.
00:02:53 - This is our root directory, you see, mounted on the root directory. And there are a
00:02:58 - total of 624,624
00:03:01 - inodes on this partition, okay. Of that, there's
00:03:06 - 123.000 used. There are about
00:03:09 - 500,000 free. So the inode usage is 20%.
00:03:13 - Now, if you look up here, the space on the drive is almost 30% full,
00:03:17 - but that inode usage is only 20%. So what
00:03:22 - does that mean? Basically every file on your computer has or takes
00:03:27 - an inode. It's kind like it's a bookmark or something,
00:03:30 - however you want to think of it, but it tells, it's how the computer
00:03:33 - finds those files, okay. So every single file, whether it's a tiny
00:03:38 - little text file or a huge DVD ISO image, it has one inode, all right?
00:03:43 - So on this filesystem we can only have 624,624
00:03:48 - files in existence.
00:03:51 - And after that we cannot create another file, because our inodes
00:03:54 - would all be used up, okay. Now there are some filesystems
00:03:58 - like XFS does dynamic inode creation, but this is
00:04:03 - ext3 or ext4 and this basically you have that many inodes,
00:04:06 - that's what you have and that's how files you can
00:04:09 - have period, all right. It's usually pretty good about creating
00:04:13 - the correct number of inodes when it's partitioning your drive
00:04:17 - or when it's formatting your partition I mean. And, you know, for our
00:04:21 - example here, there's still a lot left, right. We still have
00:04:24 - 80% of the inodes available. And that's one of the
00:04:27 - reasons that they don't just put, you know,
00:04:30 - 11 billion inodes, is because an inode takes up space by
00:04:34 - itself on the hard drive, right. Because look down here,
00:04:38 - /dev/sdb1,
00:04:40 - there are 1.2 almost million inodes.
00:04:45 - Of those, only 10 of them are used, right?
00:04:48 - Inode usage is 1%. But if you look up here,
00:04:55 - now you'll notice there's nothing in that drive. Let's do an ls,
00:04:59 - ls -a /mnt/drive2.
00:05:04 - See, there's nothing on that entire drive and yet
00:05:08 - 173 megabytes are used. Well, what is taking
00:05:12 - up 173 megabytes? Well, there's a couple of
00:05:15 - things that are taking up space even though there's no files.
00:05:18 - There are almost 1.2 million inodes that are
00:05:22 - on there and that journal. Remember we talked about journaling. Well right
00:05:27 - now it has an ext3 filesystem on it and the journal takes
00:05:31 - up space on there as well. So even though there's no files, there's already
00:05:35 - 173 megabytes that are used. So that's
00:05:38 - important to know. You know if you don't have any
00:05:40 - files, it doesn't mean there's zero usage on the drive. But anyway,
00:05:44 - that's what inodes are. It's one per file and you can use df
00:05:48 - to see how many inodes you have left. This especially becomes
00:05:51 - a problem if you have like a file server with hundreds
00:05:55 - of thousands of tiny files like user's home directories or something.
00:05:58 - But generally the formatting, the make-fs tool
00:06:03 - that we used the last nugget is good at estimating an
00:06:06 - abundance of a inodes so you won't run out. It's not very common
00:06:09 - to run out of inodes, although it is possible, all right?
00:06:15 - The next tool I want to show you is similar to df. It's du.
00:06:18 - So du is a command that shows disk usage of individual folders.
00:06:23 - Now, if you just type du it will show you the size of the folders
00:06:28 - in your current directory. Now, just like with the df, I like
00:06:31 - to use the du -h flag to make that a little more human
00:06:35 - readable, because right here again these are blocks, but I actually
00:06:39 - want to see how many kilobytes or megabytes those are, okay.
00:06:43 - And now what it does it even shows hidden files as you'll see here, not
00:06:46 - files, I'm sorry, folders. And I'm glad I made that mistake because now I'm going to
00:06:50 - clarify it. This only shows folders. You'll notice there are
00:06:54 - no files listed here. And if you thought these were files, just
00:06:57 - know that these are only folders. So du you will show you how
00:07:00 - much space the files inside of a folder are taking up, but it won't
00:07:04 - actually tell you how many files there are or how many or how
00:07:09 - big the files in there are. Like for example, this folder test contains
00:07:12 - 7.3 megabytes of data, but that's all we know, okay.
00:07:16 - It will go recursively through the folders to make
00:07:20 - sure that it finds them all.
00:07:22 - For example, if we go down here, we can see that the.thumbnails
00:07:26 - folder takes up 112K. The.thumbnails/normal
00:07:29 - folder takes up 108K.
00:07:33 - See, it will go through every one and show you and then in the end,
00:07:37 - for example, the.gconf folder
00:07:41 - contains a total of 376 kilobytes
00:07:44 - worth of data.
00:07:46 - Now, in there, each one of these, for example the apps folder
00:07:50 - has 304 kilobytes and inside the apps folder,
00:07:53 - gnome-terminal folder, has 16K. So see, it adds them all up,
00:07:57 - but it only shows folders. Now if that's a little confusing, just know
00:08:01 - that it's a way to look for file usage per folder, but not
00:08:05 - actually see how big a file is, okay. Again, that's a little confusing.
00:08:09 - Now if you just type, you know, like du -h
00:08:13 - and then tell it where you want to look like the
00:08:16 - root directory, it will go through and show you every single folder
00:08:20 - in the entire hard drive. Now I don't want to do that. I'm going to hit
00:08:24 - control C because it will just keep going and keep going recursively
00:08:27 - through all the folders. Generally what you want to
00:08:30 - do is something like du -h and then tell it like
00:08:34 - the home directory. And I'm going to say star. You can use globbing here.
00:08:38 - I wanna see each folder inside there. I wouldn't have to do that
00:08:43 - because it will search recursively. I see home and then there
00:08:46 - is my account and then this guy named Bobby and
00:08:50 - another guy named Scooby, right? But let's say we just wanted to
00:08:54 - know this information without all of the other junk, you know.
00:08:59 - We don't want to look inside everybody's folder. We just want to see,
00:09:01 - we know somebody on the system is using up too much space.
00:09:05 - Well usually if I use the du command, I'll use -h so that the
00:09:10 - numbers make sense to me and then I'll use the summarize command.
00:09:15 - Now summarize just goes one level from where you tell it. So if we do
00:09:20 - home and I want to summarize each folder inside the home directory,
00:09:25 - see, I can use that glob to say summarize
00:09:29 - each folder inside the directory I'm telling you. So if we do that,
00:09:33 - we only get each folder, but no deeper. See, it just summarizes where
00:09:38 - you tell it to. It doesn't, you know, go through the whole recursive
00:09:41 - looking through every folder. So in here we know that the three
00:09:45 - users, Bobby, Scooby, and Spowers or Shaun Powers, me, I'm the one that's using
00:09:50 - the most data. Now granted 8.5 megabytes isn't that
00:09:53 - much data, but we know that that's where we want to concentrate
00:09:57 - if we're looking for who's using, you know, the most
00:10:00 - data or the most drive space. And then you can continue from there.
00:10:04 - Let's say we want to say, all right, now we want to look at Shaun Powers,
00:10:08 - summarize his folder and everything inside his folder.
00:10:12 - Okay, we can see that I have two folders in there. Now again
00:10:16 - it's not going to show us any files, just the name of folders.
00:10:19 - You can see that this Docs folder only has 8 kilobytes,
00:10:23 - but there's 7.3 megabytes in home/spowers/test.
00:10:28 - Well let's do an ls /home/spowers/test and see what's
00:10:32 - in there. Oh, there's two files here, okay. There's file2 and file.
00:10:36 - All right, if we do
00:10:40 - ls -l,
00:10:42 - we can see, oh, there it is, File2 is big, right? It's 7.5 megabytes
00:10:47 - for that one file. So we've determined
00:10:52 - who is the hog of all the disk space
00:10:56 - on the drive. It was me with this one file, file2.txt.
00:10:59 - And we used du with the summarize flag to come up with
00:11:02 - that information, okay?
00:11:05 - So now that we know how to monitor free space and we kind of
00:11:08 - understand what inodes are, I want to talk about how we check
00:11:11 - the integrity of a formatted filesystem, all right. So we're going to
00:11:15 - do that back at the command line. But just so you know this
00:11:18 - part is now over. We understand how to monitor that and I explained
00:11:21 - what inodes are so you'll know what we're talking about.
00:11:25 - So if you've rebooted your computer many, many times or you
00:11:28 - happened to reboot your Linux system often, you'll probably notice
00:11:31 - every once in a while it tells you that it needs to check the
00:11:35 - filesystem. And to do that on our own manually, what we run
00:11:39 - is a tool called fsck.
00:11:40 - It's generally pronounced fsck anyway, F-S-C-K,
00:11:44 - filesystem check. And basically, you run that on the partition
00:11:49 - that you want to check.
00:11:50 - So we will do, where did we put it?
00:11:54 - It's /dev/sdb1 is the hard drive we want to check. And now, I'm going to
00:11:59 - press enter and then explain a bunch of things, okay.
00:12:02 - First of all, I'm going to say no
00:12:05 - and we'll go over what happened here, all right. Now what it did,
00:12:10 - fsck detected that this is an ext3 filesystem, okay.
00:12:14 - So then it loaded the e2fsck program
00:12:17 - to actually do the checking, all right.
00:12:22 - If you just run fsck, it does its best to try to detect what
00:12:25 - sort of filesystem is on there. Now, it does that a couple of ways.
00:12:28 - It will look in the et cetera fstab file which we'll
00:12:32 - talk about in another nugget or two or it just tries to detect it by
00:12:37 - looking at the partition. Now here it did correctly identify
00:12:40 - that it's in ext3 partition, so it tried to load
00:12:44 - the e2fsck program which actually does the checking.
00:12:49 - Fsck is a program that loads a different program
00:12:53 - to do the work if that makes any sense, all right. So if
00:12:57 - it doesn't detect it or you know that it's detecting it wrong,
00:13:00 - you can force it.
00:13:02 - Just like we did with mkfs, you can do fsck-t
00:13:07 - for type, ext3 /dev/sdb1, okay.
00:13:15 - Now again I'm going to say no, because the other thing that
00:13:19 - it told us is warning, warning, danger, Will Robinson.
00:13:24 - I'm running e2fsck on a mounted filesystem may cause severe file damage,
00:13:28 - filesystem damage. And it's not kidding, okay. You never want
00:13:32 - to run fsck
00:13:33 - on a mounted filesystem. Now again, mounting is a later nugget,
00:13:37 - but really quickly I'll show you that the umount tool is
00:13:41 - what we do to unmount /mnt/drive2.
00:13:47 - Oh, I'm not root. You have to be root to do that.
00:13:51 - Sudo unmount
00:13:55 - and the umount command is umount. There's no n in there,
00:13:59 - make sure you know that. And now if we try to run
00:14:03 - fsck and now there is one more way. Again, you can
00:14:07 - do the same thing, so many ways in Linux. Now I've showed you
00:14:10 - two ways. You can run fsck on its own and it will
00:14:13 - probably detect it or you can do the -t ext3 or
00:14:20 - you can do.ext3. Now this should look familiar.
00:14:23 - Remember when we did mkfs.ext3? The same thing
00:14:26 - with fsck,
00:14:31 - fsck.ext3 /dev/sdb1.
00:14:36 - And again, if you learn anything from this series your going to learn
00:14:40 - that you have to be root to do many of these things and that
00:14:43 - I often forget. So sudo fsck.ext3 /dev/sdb1.
00:14:50 - Press enter and it goes through and it tells us it's clean,
00:14:54 - meaning it didn't find any errors. There were
00:14:57 - 10 files or 10 inodes out of 1.18 million
00:15:02 - are used. And this is how many blocks are free.
00:15:07 - Again, these are one-kilobyte blocks that are free, okay. So it ran through.
00:15:11 - It didn't find any errors. So that's awesome. Now if it did find errors,
00:15:15 - generally what it does, yes it checks although the inodes.
00:15:18 - It checks the directory structure on a filesystem.
00:15:23 - And then it checks the subdirectories. Then it checks about how
00:15:27 - many times inodes are referencing files. It does a bunch of
00:15:30 - things and then offers to repair it, all right. So fsck does all
00:15:34 - those things and we'll work with that a little bit more in a minute.
00:15:37 - But I want to show you, let's say that it was not an
00:15:41 - ext3 filesystem.
00:15:45 - Okay, what I've done, I've used the tools that we learned in the last nugget
00:15:48 - to format the partition as XFS, okay.
00:15:51 - So now if we try to run fsck,
00:15:55 - remember, as a root,
00:16:00 - fsck /dev/sdb1, it will tell us this. It will say, okay,
00:16:06 - I detected an XFS filesystem. So therefore, I can't do
00:16:09 - anything, all right. If you want to actually check and repair XFS,
00:16:13 - you have to use different tools. Now this is nice because if
00:16:16 - you run fsck, it at least tells you. It doesn't just say, oh, I can't do that.
00:16:19 - It actually tells you what you're supposed to use, all right.
00:16:23 - So sudo xfs_check
00:16:25 - /dev/sdb1
00:16:29 - and it didn't find any problems. If it did find problems
00:16:31 - we would run sudo xfs_repair
00:16:35 - /dev/sdb1.
00:16:38 - And it's like, okay, I fixed it. But, you know, we know there is really
00:16:42 - nothing wrong, but it still went through the process to show us what it was doing.
00:16:45 - It looked for the superblock. It searched the log.
00:16:49 - It searched all these different things to check for duplicate blocks.
00:16:51 - It rebuilt the stuff. It checked for making sure all the inodes were
00:16:54 - connected to files. And it repaired a perfectly fine disk.
00:16:58 - But those are the tools that you use to fix that if it's XFS,
00:17:02 - my goodness. All right, it's very similar to when
00:17:07 - we were making a filesystem. I'll go really quick. If it was
00:17:11 - an ext2 filesystem,
00:17:15 - sudo mkfs.ext2
00:17:20 - /dev/sdb1,
00:17:22 - okay, so I just reformatted, then you would type
00:17:28 - fsck.ext2 /dev/sdb1,
00:17:33 - and unlike me, you would remember as root. So it checked it.
00:17:40 - It was clean. That's good. Now what else could we do?
00:17:43 - Sudo fsck -t ext2 /dev/sdb1.
00:17:47 - Same thing, right, same command.
00:17:54 - Or we could even do sudo e2fsck /dev/sdb1.
00:17:59 - And the same thing, okay. So regardless
00:18:04 - of how we invoke the command, it's going to do the same thing.
00:18:08 - And let's see, just for completion sake, why don't we do
00:18:13 - sudo mkfs, we'll do it this way,
00:18:18 - reiserfs /dev/sdb1.
00:18:21 - Are you sure. You'll lose data. Yes, we did this before.
00:18:25 - Okay, so now we have a reiserFS partition and the same thing,
00:18:28 - we do
00:18:30 - fsck.reiserfs /dev/sdb1
00:18:35 - and we're going to do it
00:18:39 - as root.
00:18:41 - And it's going to say, whoa, you are going to check the consistency
00:18:46 - of this and it will put the log in here so it's a little bit different.
00:18:49 - Do you want to run this program? Yes or no.
00:18:52 - Yes. Okay, so we checked it.
00:18:56 - And when it did,
00:18:58 - if it found any error, let's go back up there. Actually I'll run
00:19:02 - it again so we can,
00:19:04 - oop, okay. So basically we are using the later reiserfs programs,
00:19:10 - but will read-only check consistency of this file. So it's only
00:19:15 - going to check the consistency of it and it will put the log
00:19:18 - info into sdout. Now what does stdout standard out?
00:19:23 - That's just the output on the screen, right. So it's just going to show what
00:19:26 - it finds right here.
00:19:30 - And again, it found no problems, no transactions, actually no files
00:19:33 - at all on there. But that's how you run it there. So it's a little
00:19:35 - bit different regarding, you know, regarding how it actually works
00:19:40 - based on the filesystem type. And then last but not least,
00:19:43 - we would do the same, fsck, sudo fsck.vfat
00:19:50 - on /dev/sdb1
00:19:54 - if this were DOS formatting, but it's not so it's just going
00:19:59 - to complaint. It's going be like, whoa, there's something wrong. It's just not right.
00:20:04 - Because it's not, right? How was it formatted? It's reiserfs right now, okay.
00:20:07 - So I'll pause this. I'll format the drive really
00:20:11 - quick, all right, with the magic of pausing while I record. What I did,
00:20:15 - I started fdisk I and then I formatted the, the partition that I properly labeled.
00:20:20 - I formatted it to vfat. Just so that I could show you,
00:20:23 - fsck.vfat /dev/sdb1
00:20:26 - as root.
00:20:31 - And now you'll see if it's a properly formatted vfat filesystem.
00:20:35 - It will look through zero files one out of so many clusters is
00:20:39 - what it's called in
00:20:41 - the FAT32 filesystem or in the vfat filesystem. So this
00:20:46 - uses the dosfsck command. Remember, the other one
00:20:50 - actually invoked that e2fsck command, but this one invokes dosfsck
00:20:55 - and that's basically all there is to file checking.
00:20:59 - Again, you don't want to do this with the filesystem mounted.
00:21:03 - So if it's something like your root partition that you're trying
00:21:06 - to check, what you'll have to do is boot to a live CD so that your
00:21:10 - hard drive isn't actually mounted at all and that's how you
00:21:13 - would fix a problem with your, with your root partition, all right.
00:21:16 - That should make sense because you can't unmount the partition
00:21:19 - that you're currently using because it's in use, right. You can't unmount it.
00:21:23 - And we'll learn more about mounting in a bit.
00:21:26 - Okay, so we learned how to check the integrity of different filesystems
00:21:30 - using the fsck command or the XFS tools
00:21:34 - to the same thing. But remember, fsck even shows you how to do that.
00:21:37 - Now, the last thing we have to do is actually there's one thing I have to,
00:21:41 - don't let me forget this. Before we quit I have to tell you one more thing.
00:21:45 - I was just going to leave that as an asterisk. But we have to repair simple problems
00:21:49 - in our filesystems and of course we do that again on the command line
00:21:51 - so let's go there real quick.
00:21:53 - The LPIC exam specifically mentions a handful of tools that
00:21:57 - you can use on your filesystems. Now most of them are specifically
00:22:02 - for the ext-based filesystems, ext2, ext3, ext4. So we're
00:22:07 - going to look at one right now. It's called the debugfs.
00:22:11 - So we'll type sudo debugfs. And now if you actually
00:22:16 - want to make changes, you use the write flag, okay, so -w
00:22:20 - for writable and then the partition that you want to edit, /dev/sdb1,
00:22:25 - the same partition. I actually went back and reformatted
00:22:28 - this to ext2 format so that we can use the debugfs tool.
00:22:31 - Okay, if you just want to look at stuff, but don't
00:22:34 - want to change it, leave off this -w flag and then it's, you're
00:22:38 - doing it in a read-only mode. But we want to be big and bad and
00:22:42 - do it like this. Now basically all you get is this debugfs prompt, okay.
00:22:46 - It's not a tool that gives you a menu or anything
00:22:50 - like that. If you want to see some of the things you can do, feel free to
00:22:53 - type help and it will show you screens and screens of things
00:22:57 - that you can do, okay. So looking through all these
00:23:02 - different commands. You don't need to know every one of these for
00:23:05 - the LPIC-1 exam. You just need to know that debugfs
00:23:08 - is a tool you can use to do some actually kind of scary
00:23:12 - things on your drive. You can really mess up a hard drive
00:23:15 - using debugfs. But we'll type ls and we'll see on this drive
00:23:22 - is only one file, okay. On this filesystem there's only one file.
00:23:26 - It's document.txt, all right. So type Q to quit. What I'm going to do
00:23:31 - is I'm actually going to delete this file just like with
00:23:36 - the regular command prompt. If we type rm document.txt,
00:23:41 - it removed that document. So if we type ls again, you'll see
00:23:45 - that it doesn't show that file there anymore, but there's still data.
00:23:49 - Now we know that there's a file that's been deleted that
00:23:52 - we really want. So you can probably imagine this scenario where
00:23:56 - you might want to use debugfs, right. You would immediately unmount
00:24:00 - the drive partition or power off your system so it doesn't
00:24:04 - get overwritten, but you want to save this document.
00:24:08 - Well that's where a nice little tool, you can type lsdel
00:24:13 - inside the debugfs prompt
00:24:15 - and what it shows us here are all the files that have been deleted, okay.
00:24:21 - And it tells us some really neat things. Inode number 11,
00:24:25 - remember there's one idone per file, owner is, it talked about
00:24:30 - the owner, the mode of the file, meaning if it's executable or if it's,
00:24:35 - you know, readable or writable. How big it is? Now zero is correct. It actually
00:24:39 - is just an empty file that I created, but this would be, you know, any
00:24:43 - size, however big it is. How many blocks it's using? Again the bigger
00:24:46 - the size, the more blocks it will use. And then the time that
00:24:50 - it was deleted, okay. So how would you go about restoring that file?
00:24:55 - So we press Q to get out of here and then we use the
00:25:00 - undel or undelete command. Now in order to do that, in brackets,
00:25:06 - or not brackets, I'm sorry, inside the angle brackets here,
00:25:10 - you would be put the inode number, remember it was inode 11
00:25:14 - and then you have to put a file name, doc.txt.
00:25:18 - Now the reason you have to specify a file name, the name of the file
00:25:22 - is stored in what was deleted, right. So we deleted the name
00:25:25 - of the file and now it doesn't know what the name is,
00:25:28 - so have to tell it what the name of the file is. So press enter.
00:25:33 - And then if we type ls, we'll see sure enough our file is back,
00:25:36 - doc.txt, and we're in good shape, okay. So again there's
00:25:42 - a lot more things you can do, look in the help commands,
00:25:45 - that are outside of the scope of the LPIC-1 exam, but you
00:25:48 - can do a lot of things to your hard drive if you're using debugfs
00:25:52 - with that w flag, remember. So we can write to it.
00:25:57 - Otherwise, it's just a read-only situation. So anyway, that's
00:26:01 - debugfs.
00:26:03 - Type quit to get out of here and now we'll show you another command specifically
00:26:07 - for the ext-based filesystems like ext2 and ext3.
00:26:11 - And that program is called
00:26:15 - dumpt, oh, not dumpt,
00:26:18 - dumpe2fs, okay. So dumpe2fs and you tell it what filesystem.
00:26:24 - Again for us it's /dev/sdb1.
00:26:28 - And let's see, it's just going to direct to the
00:26:32 - screen which I guess is fine. It will just do it to standard output
00:26:36 - and we'll just look at it right here. And it's given us all kinds
00:26:39 - of information. So I'm going to have to scroll up so that we can see all that information
00:26:43 - and there is a whole bunch of it, in fact more than my scroll back
00:26:48 - buffer will allow. So I'm going to run that command again, but I'm going to
00:26:51 - redirect the output into out, oh, output.txt. We've done
00:26:57 - this before, it's nothing new, right. So we've redirected standard
00:27:01 - output into output.txt and there it is right there.
00:27:04 - So I'm going to run the less command. It's just a way
00:27:07 - that we can look at it,
00:27:09 - output.txt, and now we can just scroll up and down in here
00:27:12 - without having a problem, okay. So it tells us a bunch
00:27:16 - of things like we, it goes into lots of details about the different
00:27:20 - inode groups and the blocks that they represent and all kinds of information.
00:27:24 - But right at the top it shows us a lot of interesting things, okay.
00:27:27 - This dumps all the information about the entire hard drive.
00:27:31 - So it tells us things like we have not named the volume.
00:27:36 - It doesn't say when it was last mounted because I haven't mounted it, right.
00:27:39 - I just formatted it, so it really hasn't been mounted.
00:27:43 - The filesystem unique or universal unique identifier, this
00:27:47 - is just so we could, we're going to learn about the UUID when
00:27:50 - it comes to mounting later on. We've learned about that in
00:27:53 - earlier nuggets what that means, but filesystem magic number is
00:27:57 - a number specific to the drive. And there's just all these different
00:28:01 - things that it tells us. Like it's, you know, the operating system
00:28:05 - is Linux. The filesystem state is clean.
00:28:08 - It hasn't detected any problems. There's all sorts
00:28:12 - of things. Let's see, there's going to be something about journaling.
00:28:16 - Oh, actually, this is not journal. This is ext2,
00:28:20 - so it doesn't say that it's a journaled filesystem, right.
00:28:23 - But that's something that it would say, press Q to get out of here.
00:28:28 - If we were to mkfs.ext3
00:28:34 - /dev/sdb1,
00:28:38 - we're going to make this a journal filesystem,
00:28:42 - okay, which it is now It's creating the journal. And now if we
00:28:45 - do that same program or that same command, dumpe2fs,
00:28:51 - in this partition that we just made a journaled filesystem into output.txt.
00:28:55 - And then we look at it again,
00:28:59 - we're going to see something a little bit different, right.
00:29:02 - So it still doesn't have a name and it still hasn't been mounted
00:29:05 - because again we just formatted it. But it says some filesystem
00:29:09 - features now like has_journal, see. So we know that this is
00:29:13 - a journaled filesystem now. And a lot of the other information is the same.
00:29:17 - It's still clean. It didn't detect any errors. Linux operating system.
00:29:22 - All these different things that tells us about it.
00:29:24 - But this is more of an information tool. This doesn't actually edit your
00:29:27 - drive at all, it just dumps information. Ifyou actually want to change
00:29:32 - things about the drive, the dumpe2fs command shows you
00:29:37 - the information, but there's a program called
00:29:40 - tune2fs and that is actually how to change those features
00:29:46 - that a drive may have. For example, switching ext2
00:29:50 - to ext3 can be done with tune2fs. So let's
00:29:55 - actually start over. Mk, sudo mkfs.ext2
00:30:00 - so we know it's not journaled
00:30:04 - /dev/sdb1.
00:30:07 - Okay, so now we're reformatting this drive from scratch. You know how to
00:30:10 - do that, right. You'll notice here it says if you want to change
00:30:13 - how often it mounts, you can use tune2fs to do that.
00:30:17 - But when it comes to actually changing between a journaled or
00:30:21 - not journaled, the only difference between ext2 and ext3
00:30:24 - is that ext3 is journaled. Now we looked and let's do this,
00:30:29 - let's do
00:30:33 - dumpe2fs
00:30:37 - /dev/sdb1
00:30:41 - as root
00:30:43 - and we're going use grep features
00:30:46 - because what this will do, it will just pull this one line up, okay.
00:30:50 - And you see, these are all the features that this drive currently supports, okay.
00:30:53 - All of these different things that support, you'll notice
00:30:57 - it doesn't say has journal. So if you want to do that, you would
00:31:01 - use sudo tune2fs.
00:31:05 - Now, just to add a journal, you can use the -j flag.
00:31:09 - But more importantly, I want to show you how to use
00:31:16 - the -O flag. Minus capital O adds a feature. So let's
00:31:23 - say we want and the feature has_journal
00:31:28 - /dev/sdb1.
00:31:30 - And now,
00:31:33 - oop, it wasn't quite done, if we run that dumpe2fs command
00:31:38 - again, it's going to have added that feature to the drive.
00:31:42 - So now, with that simple command, we actually changed it from an ext2
00:31:46 - to an ext3 drive. And we can do exactly the same thing
00:31:51 - if we put the caret symbol, shift 6, that removes it from the features
00:31:58 - of the drive, so we do that.
00:32:02 - And now, if we look at the dumpe2fs, see, it's no longer journaled.
00:32:06 - So it's a powerful set of tools that you can use to
00:32:10 - add and remove features. Now tune2fs,
00:32:16 - tune2fs, you want to look at the man page, because it does a lot of things.
00:32:19 - It can change how many times it will mount
00:32:23 - before auto-fscking. And you can add journal. You can add
00:32:27 - journal options, how big of a journal you want, et cetera, et cetera.
00:32:30 - There's a lot of things you can do with tune2fs, but I just wanted
00:32:33 - to give you a taste of how the program actually works.
00:32:37 - Now there is one last filesystem we need to look at. What I've done,
00:32:41 - I've formatted this partition that we've been working on.
00:32:44 - I formatted it with the XFS filesystem. Now if you want to,
00:32:49 - remember sudo so your root, if you want to look at info,
00:32:53 - xfs_info /dev/sdb1,
00:32:56 - this basically, and my password, just gives us basic information
00:33:02 - about the drive itself, okay. It talks about, you know, it
00:33:06 - says how many blocks are there. It says the size of the sectors. It says
00:33:10 - et cetera, et cetera, just some general information about the drive.
00:33:14 - Now if something is going wrong,
00:33:17 - XFS gets a little bit funky on how you can actually do things.
00:33:21 - For example, you need to, oh, one more thing. This only
00:33:26 - works if it's mounted. That's exactly the opposite of like ext2
00:33:30 - and ext3 partitions. This only will work if it's mounted.
00:33:35 - Look, I actually, df -h, see, I have this mounted on mnt/drive2.
00:33:41 - If I unmount this
00:33:44 - and then I try to run sudo xfs_info, it's going to say,
00:33:54 - well, it's not allowed to. I can't look at it. So that's just an interesting
00:33:57 - quirk that it actually has to be mounted in order to run xfs_info.
00:34:01 - The other command with the XFS filesystem that is mentioned
00:34:05 - in the LPIC and CompTIA exam is this command,
00:34:10 - sudo xfs_metadump /dev/sdb1
00:34:17 - and the name of a file. We're going to call this dump.db.
00:34:23 - Because what this does, you'll see, it makes this file. And this is a binary file.
00:34:27 - It's not just like a text report that we can look at
00:34:30 - and there are some other tools that are way outside of the scope
00:34:33 - of this nugget and even the LPIC-1 exam that you need to use
00:34:37 - to look at this meta info dump on the XFS filesystem,
00:34:42 - on the partition that we just dumped. But that's how
00:34:45 - you would get a metadump from an XFS filesystem. And then
00:34:49 - you would use tools like xfsdb in order to look inside
00:34:54 - this and see what's going on. But again, that's outside of the
00:34:56 - scope of this nugget. This is pretty much all you need to
00:35:00 - know about this nugget apart from remember that asterisk?
00:35:04 - Yeah, let's go look at that.
00:35:06 - Remember I said I had an asterisk down here that I wanted you to remind me about?
00:35:09 - Well we did this. We learned how to repair simple problems.
00:35:13 - We learned how to get information on it. But for some reason,
00:35:17 - the LPIC exams and I suspect it's a typo and maybe by the
00:35:20 - time you watch this they will have fixed it.
00:35:22 - But they included mke2fs
00:35:28 - as a command that you need to know for this
00:35:35 - section, this nugget. And why I think it's
00:35:38 - a typo is because this is one of the commands, the same thing
00:35:42 - as if you typed mkfs.ext2, right.
00:35:47 - So I don't understand exactly why they
00:35:53 - would want us to do that. You can also do ext3 with this.
00:35:57 - Again, it's just a matter of command line flags. But again,
00:36:01 - this is just a way to make an ext-based filesystem which
00:36:05 - should have been in the last nugget and we covered it there.
00:36:07 - But I included it because doggone it, it says that it's part of 104.2 lesson.
00:36:10 - So we have included that for clarity's sake.
00:36:16 - I hope that this has been informative for you and I'd like to thank
00:36:19 - you for viewing.

Control Mounting and Unmounting of Filesystems

Manage Disk Quotas

Manage File Permissions and Ownership

Create and Change Hard and Symbolic Links

Find System Files and Place Files in the Correct Location

This forum is for community use – trainers will not participate in conversations. Share your thoughts on training content and engage with other members of the CBT Nuggets community. For customer service questions, please contact our support team. The views expressed in comments reflect those of the author and not of CBT Nuggets. We reserve the right to remove comments that do not adhere to our community standards.

comments powered by Disqus
Community Standards

We encourage you to share your wisdom, opinions, and questions with the CBT Nuggets community. To keep things civil, we have established the following policy.

We reserve the right not to post comments that:
contain obscene, indecent, or profane language; contain threats or defamatory statements; contain personal attacks; contain hate speech directed at race, color, sex, sexual orientation, national origin, ethnicity, age, religion, or disability; contributes to a hostile atmosphere; or promotes or endorses services or products. Non-commercial links, if relevant to the topic, are acceptable. Comments are not moderated, however, all comments will automatically be filtered for content that might violate our comment policies. If your comment is flagged by our filter, it will not be published.

We will be continually monitoring published comments and any content that violates our policies will be removed. Users who repeatedly violate our comments policy may be prohibited from commenting.

Course Features

Speed Control

Play videos at a faster or slower pace.

Bookmarks

Pick up where you left off watching a video.

Notes

Jot down information to refer back to at a later time.

Closed Captions

Follow what the trainers are saying with ease.

MP3 Downloads

Listen to videos anytime, anywhere

Annual Course Features

Transcender Practice Exams

These practice tests help you review your knowledge and prepare you for exams.
Available only with the annual subscription.
Shawn Powers

Shawn Powers

CBT Nuggets Trainer

Certifications:
LPIC-1; CompTIA Linux+, A+; Cisco CCNA

Area Of Expertise:
Linux

Add training to a playlist
or create a new list
Add to current playlist
or add to an existing list
Add to new playlist
Add New Bookmark

Maintain the Integrity of Filesystems
Bookmark Title:
Whoops

Login is required to access this feature.

Your browser cannot access Virtual Labs
Video Options

This advanced buffering is applied to all streams regardless if you installed the doublespeed control or not. Sometimes the advanced buffering causes the video to hang or behave erratically. If you are experienceing issues with video playback please disable the doublespeed buffer.

Remember to re-enable the buffer if you want to use the doublespeed control.

If you are experiencing problems with our content delivery, please click here to switch to our alternate content delivery network or go to our network FAQ.
For other common video playback issues, including firewall and corporate network issues, please visit our Tech Support forum.