< Return to Video

Mounting Filesystems in Linux! (Linux+ Objective 1.3.3)

  • 0:00 - 0:02
    Hey everybody. I'm Shawn Powers. And in
  • 0:02 - 0:04
    this video, we're continuing our Linux
  • 0:04 - 0:06
    plus certification prep. We're talking
  • 0:06 - 0:09
    about mounting file systems and this is
  • 0:09 - 0:11
    one of those videos where I could go
  • 0:11 - 0:13
    super deep into so many different
  • 0:13 - 0:15
    aspects of mounting file systems but
  • 0:15 - 0:16
    what I'm going to do is I'm going to
  • 0:16 - 0:19
    cover enough that you will understand
  • 0:19 - 0:21
    what you need to know for the exam. And
  • 0:21 - 0:24
    if there are areas that I think might be
  • 0:24 - 0:26
    interesting for you to dive deeper into
  • 0:26 - 0:27
    I'll try to mention it along the way
  • 0:27 - 0:30
    we're currently in objective 1.3 on the
  • 0:30 - 0:33
    Linux plus objectives. I'm calling this
  • 0:33 - 0:36
    1.3.3. This is our third video as we
  • 0:36 - 0:38
    explore this objective and like I said
  • 0:38 - 0:40
    specifically, we're going to look at
  • 0:40 - 0:43
    mounting local and remote file systems
  • 0:43 - 0:45
    or devices and remote devices is
  • 0:45 - 0:47
    important here because we're not talking
  • 0:47 - 0:49
    about remote file systems like over the
  • 0:49 - 0:50
    network. We're going to talk about that
  • 0:50 - 0:53
    over here specifically remote devices
  • 0:53 - 0:55
    are like externally attached like a USB
  • 0:55 - 0:56
    drive that sort of a thing. So we're
  • 0:56 - 0:58
    going to cover the things in here
  • 0:58 - 1:00
    including encryption very briefly, you
  • 1:00 - 1:02
    and that should give us a good feel for
  • 1:02 - 1:04
    what's going on and I don't want to
  • 1:04 - 1:05
    start this video without thanking
  • 1:05 - 1:06
    everybody over here. You might notice
  • 1:06 - 1:08
    it's actually scrolling now because
  • 1:08 - 1:10
    we've had even another person who has
  • 1:10 - 1:12
    decided to be a Patreon supporter of
  • 1:12 - 1:15
    mine. I am so grateful and humbled and it
  • 1:15 - 1:17
    makes me so excited to continue to make
  • 1:17 - 1:19
    more and more content whether it's
  • 1:19 - 1:21
    videos or whatever it is that you might
  • 1:21 - 1:23
    be supporting me for. So anyway, thank you
  • 1:23 - 1:24
    to my Patreon supporters. If that's
  • 1:24 - 1:26
    something you're interested in, link
  • 1:26 - 1:28
    will be down below. But let's get into
  • 1:28 - 1:31
    how we can actually mount file systems
  • 1:31 - 1:34
    on Linux. So just a quick rundown of what
  • 1:34 - 1:37
    I have set up in the folder MNT. I've
  • 1:37 - 1:39
    created just three empty folders or
  • 1:39 - 1:41
    directories called drive one, drive two
  • 1:41 - 1:42
    and drive three. We're going to use those
  • 1:42 - 1:47
    as places to mount our drives or devices.
  • 1:47 - 1:49
    So I have those things created and if we
  • 1:49 - 1:50
    look at LS,
  • 1:50 - 1:54
    BLK. I'm going to do Dash E7 which will
  • 1:54 - 1:58
    filter out all of those Loop devices. It
  • 1:58 - 2:00
    will show us that we have, of course, SDA
  • 2:00 - 2:02
    is our system hard drive. I'm not really
  • 2:02 - 2:04
    going to touch that. That's the, that's
  • 2:04 - 2:06
    what our, our system is installed on,
  • 2:06 - 2:09
    but I have some other devices here too. I
  • 2:09 - 2:13
    have sdb, SDC and sdd. SDR is actually our
  • 2:13 - 2:16
    CD-ROM but I've created a partition on
  • 2:16 - 2:18
    each of these drives. Just one partition
  • 2:18 - 2:21
    that takes up the entire 10 gigabytes,
  • 2:21 - 2:23
    okay. Now if we actually do another
  • 2:23 - 2:27
    command here, Dash f. It will show us what
  • 2:27 - 2:30
    file systems are formatted on there. If
  • 2:30 - 2:33
    there are any so here, you'll see sdb1
  • 2:33 - 2:36
    has an ext4 file system already put on
  • 2:36 - 2:41
    it SDC one has Butter FS BTR FS, the file
  • 2:41 - 2:44
    system is formatted on it and sdd1
  • 2:44 - 2:46
    doesn't have any file system at all. It's
  • 2:46 - 2:48
    just a raw partition. We're going to use
  • 2:48 - 2:50
    that later for encryption. So anyway,
  • 2:50 - 2:53
    these two have things have a file system
  • 2:53 - 2:55
    already installed on it which means we
  • 2:55 - 2:58
    should be able to mount it into our
  • 2:58 - 3:00
    Linux file system. So let's do that for
  • 3:00 - 3:02
    first of all with sdb1, and this is just
  • 3:02 - 3:05
    how we go about doing it manually. So we
  • 3:05 - 3:06
    would say sudo because we need root
  • 3:06 - 3:09
    privilege now I say that it is possible
  • 3:09 - 3:11
    to have something set up so that a user
  • 3:11 - 3:13
    can mount it without root access. That's
  • 3:13 - 3:15
    kind of Beyond where we're going to go
  • 3:15 - 3:16
    today. That's like user mounting options,
  • 3:16 - 3:18
    which has to be set up for individual
  • 3:18 - 3:21
    mounts. We're going to use root access to
  • 3:21 - 3:23
    mount all of these drives onto our
  • 3:23 - 3:25
    system. Because at the end of the day, it
  • 3:25 - 3:27
    requires root access but you can set it
  • 3:27 - 3:30
    up so that a user can initiate the mount
  • 3:30 - 3:32
    anyway we're going to be, we're going to
  • 3:32 - 3:34
    have root access to do this. So sudo
  • 3:34 - 3:36
    Mount and then the device that we want
  • 3:36 - 3:40
    to mount in our case, let's do Dev sdb1
  • 3:40 - 3:43
    and then where we want to mount it.
  • 3:43 - 3:46
    MNT will say drive one. Now, I could add
  • 3:46 - 3:49
    another flag before I do this. I could
  • 3:49 - 3:52
    say Dash t for what type is it and we
  • 3:52 - 3:55
    know that it's ext4, but that is almost
  • 3:55 - 3:58
    always Auto detected. We very rarely have
  • 3:58 - 4:01
    to specify what type of file system it
  • 4:01 - 4:04
    is. And in fact, if it doesn't work if it
  • 4:04 - 4:05
    doesn't Auto detect the file system,
  • 4:05 - 4:07
    chances are there's something wrong and
  • 4:07 - 4:09
    it's not going to mount anyway. So I'm
  • 4:09 - 4:10
    not going to put that on there but if
  • 4:10 - 4:12
    you see somebody specify Dash T and then
  • 4:12 - 4:15
    the file system type. That's why it's a
  • 4:15 - 4:16
    way to tell Mount what kind of file
  • 4:16 - 4:18
    system to expect,
  • 4:18 - 4:20
    but you can see it usually Auto detects
  • 4:20 - 4:22
    it, just fine, if we do it, if we do a DF
  • 4:22 - 4:25
    minus H. We're going to see that now we
  • 4:25 - 4:27
    have this device mounted on MNT drive
  • 4:27 - 4:31
    one, and it's able to be used now on our
  • 4:31 - 4:33
    system. It's part of our file system now
  • 4:33 - 4:35
    mounting things manually is great but
  • 4:35 - 4:37
    it's really not that practical,
  • 4:37 - 4:39
    especially if it's hard drives that you
  • 4:39 - 4:40
    want to have automatically mount when
  • 4:40 - 4:42
    the system boots up. And so generally,
  • 4:42 - 4:45
    what we do is create entries in the ETC
  • 4:45 - 4:49
    FS tab file, which file system tab. So
  • 4:49 - 4:50
    that's what I'm going to show you how to
  • 4:50 - 4:52
    do right now is how you would make
  • 4:52 - 4:54
    amount permanent on the system. So let's
  • 4:54 - 4:57
    unmount this drive and to do that, sudo U
  • 4:57 - 5:00
    Mount it's not on. It's not unmount. It's
  • 5:00 - 5:02
    U mount for unmount, which is a little
  • 5:02 - 5:05
    confusing sometimes but you mount and
  • 5:05 - 5:08
    then MNT drive one . So then it will
  • 5:08 - 5:10
    unmount, if we look it's no longer
  • 5:10 - 5:14
    mounted on our system. So let's look at
  • 5:14 - 5:18
    Etc FS tab, here is where we can make an
  • 5:18 - 5:20
    entry and there is a little cheat sheet
  • 5:20 - 5:22
    up top here. That will explain how you
  • 5:22 - 5:25
    can specify what you wanted to mount
  • 5:25 - 5:27
    when the system starts up. So the first
  • 5:27 - 5:29
    field is what file system and that can
  • 5:29 - 5:31
    be specified in a number of ways. In fact,
  • 5:31 - 5:32
    it's specified a couple ways right here.
  • 5:32 - 5:36
    You can see uuid equals and then this
  • 5:36 - 5:39
    euid that can be how we specify it, we
  • 5:39 - 5:43
    could just use a device like Dev sda2, we
  • 5:43 - 5:46
    could use a label that we have formatted
  • 5:46 - 5:48
    on the partition. So there's a lot of
  • 5:48 - 5:51
    different things that we can specify as
  • 5:51 - 5:53
    what file system is that we want so in
  • 5:53 - 5:56
    this case. Let's actually, I just did the
  • 5:56 - 5:58
    device on the command line. So let's get
  • 5:58 - 6:00
    out of here really quickly and if we do
  • 6:00 - 6:02
    sudo
  • 6:02 - 6:05
    blkid, and I'm going to get rid of all
  • 6:05 - 6:08
    the loopback devices. This will show us
  • 6:08 - 6:09
    all the partitions on our system and the
  • 6:09 - 6:12
    one that we were just looking at is Dev
  • 6:12 - 6:16
    sdb1. And so this has a uuid of this
  • 6:16 - 6:19
    right here. Now, point out right here
  • 6:19 - 6:21
    since we're since we're looking at this
  • 6:21 - 6:24
    block ID information. This is the uuid,
  • 6:24 - 6:28
    this is the unique Universal unique
  • 6:28 - 6:30
    identifier for the file system that is
  • 6:30 - 6:33
    installed. However, there's also the
  • 6:33 - 6:38
    partition uuid which is pointing to the
  • 6:38 - 6:41
    actual partition on the hard drive that
  • 6:41 - 6:43
    the file system is written to. So if you
  • 6:43 - 6:45
    and that if that seems confusing
  • 6:45 - 6:46
    hopefully this will help if we look down
  • 6:46 - 6:50
    here at Dev sdd1, you may remember this
  • 6:50 - 6:52
    is a a partition that does not have a
  • 6:52 - 6:54
    file system put on it yet. And this still
  • 6:54 - 6:57
    has a part uu idea partition uuid but it
  • 6:57 - 7:00
    does not have a uuid because there's no
  • 7:00 - 7:03
    file system formatted on this partition
  • 7:03 - 7:06
    yet, okay. Now the cool thing is we can
  • 7:06 - 7:08
    actually specify in file
  • 7:08 - 7:13
    Etc fstab using either uuid or part uuid.
  • 7:13 - 7:15
    Generally, you'll see this done either by
  • 7:15 - 7:17
    the device which in our case is going to
  • 7:17 - 7:22
    be Dev sdb 1 or the uuid. So let's, let's
  • 7:22 - 7:25
    do this uuid. This is going to be that
  • 7:25 - 7:29
    device copy and now if we do sudo VI Etc
  • 7:29 - 7:33
    FS Tab and now I'm going to paste that.
  • 7:33 - 7:35
    So that's the file system. This is the
  • 7:35 - 7:37
    device this is that first field and then
  • 7:37 - 7:39
    where we want it to Mount. That's just
  • 7:39 - 7:42
    going to be MNT drive 1. The next field
  • 7:42 - 7:45
    is the type. So here we do actually have
  • 7:45 - 7:46
    to put the file type which is or the
  • 7:46 - 7:50
    file system type which is ext4 and then
  • 7:50 - 7:52
    the next one is what options. I'm just
  • 7:52 - 7:54
    going to say defaults. We don't need any
  • 7:54 - 7:56
    specific options in there and then the
  • 7:56 - 7:58
    next two are a little bit confusing dump
  • 7:58 - 8:00
    is very rarely used at all anymore. So
  • 8:00 - 8:02
    we're going to put a zero here. What dump
  • 8:02 - 8:04
    is talking about is you could do like a
  • 8:04 - 8:06
    file system backup, it would like dump
  • 8:06 - 8:09
    the contents of a partition or a mounted
  • 8:09 - 8:10
    device. It's just not done anymore it was
  • 8:10 - 8:12
    dump FS. It's just not done anymore. So
  • 8:12 - 8:14
    zero means like no, we're not going to do
  • 8:14 - 8:17
    that and then pass talks about how often
  • 8:17 - 8:19
    you want to do a file system check.
  • 8:19 - 8:20
    We're going to look at file system check
  • 8:20 - 8:23
    in probably the next video, but there's
  • 8:23 - 8:25
    three options. Let's see there's zero one
  • 8:25 - 8:27
    or two zero means don't do any file
  • 8:27 - 8:30
    system checks one means I want you to do
  • 8:30 - 8:32
    file system checks and this is the root
  • 8:32 - 8:33
    partition. Well this is not the root
  • 8:33 - 8:36
    partition and so two would be I want you
  • 8:36 - 8:38
    to do file system checks, but this is not
  • 8:38 - 8:40
    a root partition all right. So I guess,
  • 8:40 - 8:42
    this would be the way to go either a 2
  • 8:42 - 8:44
    or a zero. I'm just going to leave it at
  • 8:44 - 8:47
    zero then we save this,
  • 8:47 - 8:49
    and now when the system boots up, it will
  • 8:49 - 8:52
    automatically mount that onto mount
  • 8:52 - 8:54
    Drive one. But if you look right now, it's
  • 8:54 - 8:57
    not mounted. So we can say sudo Mount
  • 8:57 - 9:00
    Dash a, which will re-read that FS tab
  • 9:00 - 9:02
    file and mount all the things that are
  • 9:02 - 9:04
    in there. So if we do that and now we
  • 9:04 - 9:06
    look now it's mounted and it will Mount
  • 9:06 - 9:08
    every time the system is rebooted. Now,
  • 9:08 - 9:11
    the Linux plus objective specifically
  • 9:11 - 9:14
    says external devices, which is a little
  • 9:14 - 9:15
    bit of a weird thing. It's not something
  • 9:15 - 9:18
    we do very often and this makes me think
  • 9:18 - 9:20
    of a USB drive. Now if it's like a USB
  • 9:20 - 9:23
    stick most distributions. Especially if
  • 9:23 - 9:24
    they have a GUI installed will just
  • 9:24 - 9:26
    automatically mount it, when you put it
  • 9:26 - 9:27
    in and then you take it out. It's, you
  • 9:27 - 9:30
    know, unmounted however let's say you
  • 9:30 - 9:32
    have a like a really large
  • 9:32 - 9:36
    USB drive it's like an external, you know,
  • 9:36 - 9:38
    USB like I don't know 20 terabytes or
  • 9:38 - 9:40
    something and you want to have it
  • 9:40 - 9:42
    treated like a regular hard drive on
  • 9:42 - 9:44
    your system, but it connects via USB. Well,
  • 9:44 - 9:46
    it is possible to actually have those
  • 9:46 - 9:49
    treated it like a regular drive. So
  • 9:49 - 9:50
    that's what we're going to do. We're
  • 9:50 - 9:52
    going to set up a USB drive so that it
  • 9:52 - 9:54
    doesn't automatically Mount and unmount,
  • 9:54 - 9:57
    when we plug it into the USB connector
  • 9:57 - 9:59
    but treat it more like an internal hard
  • 9:59 - 10:01
    drive on our system, and here's the thing
  • 10:01 - 10:03
    normally when you plug in a USB drive.
  • 10:03 - 10:05
    And I have one just out of camera here.
  • 10:05 - 10:07
    It will do what it just did here. It will
  • 10:07 - 10:10
    automatically Mount that USB stick, and
  • 10:10 - 10:13
    if we look down here DF minus H. It
  • 10:13 - 10:14
    mounts it somewhere like in the media
  • 10:14 - 10:16
    folder, and this is the auto mounter that
  • 10:16 - 10:18
    looks for USB drives and it will do that
  • 10:18 - 10:21
    automatically, but let's say like, like I
  • 10:21 - 10:22
    just discussed that we want this to be
  • 10:22 - 10:24
    treated like a regular hard drive. Well,
  • 10:24 - 10:26
    let's do let's unmount it first. So
  • 10:26 - 10:29
    umount media s Powers USB stick. Now,
  • 10:29 - 10:34
    let's do a sudo BLK ID corrupt Dash V
  • 10:34 - 10:37
    Loop. And let's see if we can find that
  • 10:37 - 10:41
    device, yes. It's right here so Dev SD E1
  • 10:41 - 10:44
    is that partition. I unmounted it but
  • 10:44 - 10:45
    it's still inserted into the system and
  • 10:45 - 10:50
    so we can create an entry in ETC FS tab
  • 10:50 - 10:52
    for this and now remember I said we can
  • 10:52 - 10:54
    specify these based on a lot of things
  • 10:54 - 10:57
    like a device, the problem is with a USB
  • 10:57 - 10:59
    device specifically, let's say we plugged
  • 10:59 - 11:02
    in another USB stick before this one and
  • 11:02 - 11:05
    so the other one was sde and then this
  • 11:05 - 11:08
    one was SD F so using a device name
  • 11:08 - 11:09
    particularly with something. That might
  • 11:09 - 11:11
    change is not a great idea. So in this
  • 11:11 - 11:13
    case, we would either want to use the
  • 11:13 - 11:16
    uuid which you know we have uuid or you
  • 11:16 - 11:19
    could use a label and for something like
  • 11:19 - 11:23
    this. I would probably use a label. My
  • 11:23 - 11:24
    rationale here is that you can actually
  • 11:24 - 11:27
    label different USB disks the same thing.
  • 11:27 - 11:30
    And so, if you always want your USB drive
  • 11:30 - 11:31
    to mount in the same spot. You could just
  • 11:31 - 11:33
    label them the same whichever one's
  • 11:33 - 11:34
    plugged in is going to be there, but
  • 11:34 - 11:37
    nonetheless label is one more way we can
  • 11:37 - 11:39
    specify it. Let's take this label USB
  • 11:39 - 11:41
    underscore stick,
  • 11:41 - 11:43
    Etc fstab.
  • 11:43 - 11:45
    And the same thing as before we're just
  • 11:45 - 11:46
    going to make another entry. This time
  • 11:46 - 11:49
    though we're going to say label equals
  • 11:49 - 11:52
    USB underscore stick.
  • 11:52 - 11:55
    And then I want this one mounted in MNT
  • 11:55 - 11:58
    Drive 2, and this is going to be well
  • 11:58 - 12:00
    what was the file system on there. Let's
  • 12:00 - 12:02
    look. I'm going to go back and look it
  • 12:02 - 12:05
    looks like a v-fat. So this is a, it's a
  • 12:05 - 12:07
    Dos based thing basically. So the type is
  • 12:07 - 12:09
    v-fat it's right here. So we'll go back
  • 12:09 - 12:14
    in and V fat is our type defaults. I'm
  • 12:14 - 12:17
    going to say 0 0. Again.
  • 12:17 - 12:20
    save this and now again it's not mounted
  • 12:20 - 12:22
    because we you mounted it. However, if we
  • 12:22 - 12:25
    were to say sudo Mount Dash a now all of
  • 12:25 - 12:27
    a sudden that drive is going to be
  • 12:27 - 12:30
    mounted in Mount Drive Two. And now when
  • 12:30 - 12:33
    we reboot the system as long as that USB
  • 12:33 - 12:35
    drive is in even. If it's not recognized
  • 12:35 - 12:38
    in the same order. It should mount on
  • 12:38 - 12:41
    that location instead of us having to
  • 12:41 - 12:43
    like put it in and have it Auto Mount
  • 12:43 - 12:45
    detected by the GUI operating system,
  • 12:45 - 12:46
    that sort of thing. It should be treated
  • 12:46 - 12:49
    just like a regular hard drive on the
  • 12:49 - 12:51
    system and mount app boot, but you want
  • 12:51 - 12:52
    to know a little secret system D
  • 12:52 - 12:55
    actually does all of the mounting the
  • 12:55 - 12:57
    ETC fstab file used to be where
  • 12:57 - 12:59
    everything was read from and mounted
  • 12:59 - 13:00
    right from there but not anymore now
  • 13:00 - 13:03
    systemd looks at our FS tab file and
  • 13:03 - 13:06
    creates on the Fly individual
  • 13:06 - 13:10
    system. D Mount files and that is what
  • 13:10 - 13:11
    it uses to mount them. Let me show you if
  • 13:11 - 13:14
    we go to our system here and we go into
  • 13:14 - 13:19
    run system d e generator, and we look at
  • 13:19 - 13:21
    all the files in here. We're going to see
  • 13:21 - 13:25
    a couple specifically this is the the
  • 13:25 - 13:29
    one that is generated on boot. So the
  • 13:29 - 13:31
    dash here is just referring to the root
  • 13:31 - 13:34
    partition, but here is the deal. Let's
  • 13:34 - 13:37
    look at it. This is auto generated by
  • 13:37 - 13:40
    reading the fstab file, and it creates
  • 13:40 - 13:42
    this file on the Fly, and this is
  • 13:42 - 13:45
    actually how it mounts on the system now
  • 13:45 - 13:49
    we can create our own dot Mount files in
  • 13:49 - 13:52
    Mount devices into directories using
  • 13:52 - 13:55
    this method. However, this is not what is
  • 13:55 - 13:57
    generally recommended. It's still
  • 13:57 - 14:00
    recommended to use the ETC fstab file to
  • 14:00 - 14:02
    spell out all of the mounts that you
  • 14:02 - 14:06
    want. Even though they're converted to
  • 14:06 - 14:08
    system D Mount files. However, it is
  • 14:08 - 14:10
    possible to use a systemdmount file. If
  • 14:10 - 14:12
    you have a reason to do that and you
  • 14:12 - 14:15
    want to specify in a file like this
  • 14:15 - 14:17
    but to do that I'm not going to dive too
  • 14:17 - 14:19
    deep into system D, but if you have
  • 14:19 - 14:22
    custom things that you create for
  • 14:22 - 14:24
    systemd. They're going to be put into
  • 14:24 - 14:28
    Etc system D system. This is where the
  • 14:28 - 14:31
    user generated files are put and there's
  • 14:31 - 14:32
    probably already a bunch of stuff in
  • 14:32 - 14:35
    here, but we're going to create a simple
  • 14:35 - 14:37
    Mount file and we're going to put it in
  • 14:37 - 14:41
    here. So I'm going to do sudo VI and this
  • 14:41 - 14:42
    is it has to be in a very specific
  • 14:42 - 14:46
    format. Okay, it has to represent
  • 14:46 - 14:51
    by name where the end result is going to
  • 14:51 - 14:54
    be. So we have to do something like v i m
  • 14:54 - 14:59
    n t Dash Drive 3 dot Mount, because if
  • 14:59 - 15:01
    you remember, I created that directory in
  • 15:01 - 15:05
    Mount Drive 3 and so we have to name the
  • 15:05 - 15:08
    mount file, exactly this or it won't work
  • 15:08 - 15:10
    so we're creating this file. I'm just
  • 15:10 - 15:14
    going to make it very very simple
  • 15:14 - 15:18
    Mount Drive three, and then a little
  • 15:18 - 15:22
    Mount section what equals and then this
  • 15:22 - 15:25
    is the device that we actually want to
  • 15:25 - 15:28
    use. So this is device the device that
  • 15:28 - 15:29
    we're going to mount. So let's get the
  • 15:29 - 15:34
    uuid from a device pseudo okay ID crop
  • 15:34 - 15:36
    Dash V looped. So the loops don't show up
  • 15:36 - 15:40
    and the device that I want to mount in
  • 15:40 - 15:45
    here is this one Dev SDC one, and it has
  • 15:45 - 15:48
    this uuid for the file system. So I'm
  • 15:48 - 15:51
    going to copy this,
  • 15:51 - 15:53
    go back into here and this is a little
  • 15:53 - 15:55
    bit goofy. This is kind of how you
  • 15:55 - 16:01
    specify it Dev disc by uuid. And then
  • 16:01 - 16:03
    actual uuid> So I'm going to get rid of
  • 16:03 - 16:05
    this stuff
  • 16:05 - 16:09
    so we specify that is what device and
  • 16:09 - 16:12
    then where is the next option here and
  • 16:12 - 16:15
    where is going to be Mount Drive three
  • 16:15 - 16:17
    and it has to be here because remember,
  • 16:17 - 16:19
    that's what we named the file type
  • 16:19 - 16:21
    equals
  • 16:21 - 16:24
    btrfs which is what it said it was
  • 16:24 - 16:28
    options equal defaults, and I don't know
  • 16:28 - 16:31
    if this part is required but generally
  • 16:31 - 16:34
    multi user dot Target and that just
  • 16:34 - 16:37
    means that it will call this when we
  • 16:37 - 16:40
    start multi-user mode on boot, all right.
  • 16:40 - 16:42
    So I'll save that,
  • 16:42 - 16:45
    and now we have to do sudo system CTL
  • 16:45 - 16:49
    Daemon reload so that it sees that mount
  • 16:49 - 16:51
    file that we've created. This is just
  • 16:51 - 16:54
    more systemd stuff and then we treat it
  • 16:54 - 16:55
    just like we would a service. So we can
  • 16:55 - 17:01
    say pseudo system CTL start MNT Drive 3
  • 17:01 - 17:02
    mount,
  • 17:02 - 17:05
    and now if we do DF minus H. It's mounted
  • 17:05 - 17:07
    it right here. Now this will not
  • 17:07 - 17:10
    automatically start on boot because just
  • 17:10 - 17:12
    like a systemd service, we would have to
  • 17:12 - 17:17
    do sudo system CTL enable
  • 17:17 - 17:19
    Mount Drive three dot mount.
  • 17:19 - 17:21
    So we do that and now it will actually
  • 17:21 - 17:23
    Mount that on boot. Even though, it's not
  • 17:23 - 17:25
    in our FS tab file. So again it's
  • 17:25 - 17:27
    possible to do that and if you put it in
  • 17:27 - 17:30
    ETC systemd system and name it properly
  • 17:30 - 17:33
    it will mount on system boot, but it's
  • 17:33 - 17:35
    still not generally the way that we go
  • 17:35 - 17:37
    about doing it normally. We still use the
  • 17:37 - 17:40
    ETC fstab file because it's one place
  • 17:40 - 17:41
    that we can put all of our file systems.
  • 17:41 - 17:44
    And that's will be converted.
  • 17:44 - 17:45
    Automatically, so we don't have to worry
  • 17:45 - 17:47
    about the system D side of it and then,
  • 17:47 - 17:50
    you only have one place to remember to
  • 17:50 - 17:52
    store all of your system mounts that
  • 17:52 - 17:54
    said the one last thing. We have to cover
  • 17:54 - 17:58
    is an encrypted file system using Luke's
  • 17:58 - 17:59
    so back here on Ubuntu. I'm going to
  • 17:59 - 18:01
    create one more directory. I'm going to
  • 18:01 - 18:05
    make directory Mount secret. We're going
  • 18:05 - 18:07
    to use this directory for an encrypted
  • 18:07 - 18:11
    file system. Now if you remember lsblk, we
  • 18:11 - 18:14
    have these devices down here. So the one
  • 18:14 - 18:17
    that we haven't messed with at all is
  • 18:17 - 18:20
    sdd1 this is a partition. There's is no
  • 18:20 - 18:22
    file system on it at all. So we're going
  • 18:22 - 18:24
    to create an encrypted partition and to
  • 18:24 - 18:27
    do that we use the Crypt setup tool. So
  • 18:27 - 18:30
    Crypt actually I'm going to do sudo
  • 18:30 - 18:35
    Crypt setup Luke's format Dev
  • 18:35 - 18:37
    sdd1. So it's going to overwrite it
  • 18:37 - 18:40
    completely because it's creating uh this
  • 18:40 - 18:42
    encrypted partition. So I'm going to it
  • 18:42 - 18:44
    says are you sure. Type yes in capital
  • 18:44 - 18:47
    letters. So yes in capital letters. Now, I
  • 18:47 - 18:50
    have to enter a passphrase okay. This is
  • 18:50 - 18:51
    how it's going to decrypt if you don't
  • 18:51 - 18:54
    remember this passphrase. Your data is
  • 18:54 - 18:55
    lost right. There's, there's not a
  • 18:55 - 18:57
    recovery function if you can't remember
  • 18:57 - 18:59
    your passphrase. So it's generally
  • 18:59 - 19:02
    something long. Mine is not going to be
  • 19:02 - 19:04
    really long and now it is an encrypted
  • 19:04 - 19:08
    partition, but it's not open in order to
  • 19:08 - 19:10
    access the partition itself. So that we
  • 19:10 - 19:12
    can write data to it. We have to decrypt
  • 19:12 - 19:14
    it and open it in a decrypted state. So
  • 19:14 - 19:17
    in order to do that, we use the same tool
  • 19:17 - 19:21
    sudo Crypt setup but we say open and
  • 19:21 - 19:25
    then what the device is so Dev sdd1 and
  • 19:25 - 19:28
    then what we want it to be named in its
  • 19:28 - 19:31
    unencrypted state. Okay, does that make
  • 19:31 - 19:32
    sense? Hopefully it does. Hopefully, it
  • 19:32 - 19:35
    does. We're going to call it secret disc.
  • 19:35 - 19:37
    I have to enter the passphrase okay and
  • 19:37 - 19:40
    now I think it shows up with a LS block
  • 19:40 - 19:42
    sort of I mean it is called secret disc
  • 19:42 - 19:45
    but it's going to live in Dev mapper,
  • 19:45 - 19:49
    okay. In Dev mapper, secret disc is that
  • 19:49 - 19:52
    currently decrypted file system. So what
  • 19:52 - 19:54
    we would do is write a file system on
  • 19:54 - 19:56
    there because right now. It's just a
  • 19:56 - 19:58
    an encrypted partition that's currently
  • 19:58 - 20:01
    open and decrypted, and that's how we
  • 20:01 - 20:04
    access it. So we're just going to do sudo
  • 20:04 - 20:06
    mkfs.ext4. I'm just going to make an ext4
  • 20:06 - 20:10
    file system on it Dev mapper secret disk,
  • 20:10 - 20:13
    okay it's all done. And now let's
  • 20:13 - 20:17
    mount it. So we're gonna say sudo Mount
  • 20:17 - 20:23
    Dev mapper secret disc on Mount Secret,
  • 20:23 - 20:25
    and now sure enough, it is there and we
  • 20:25 - 20:27
    should be able to access it so let's
  • 20:27 - 20:30
    go into I'm just going to become root
  • 20:30 - 20:33
    Out secret, okay. There's lost in file
  • 20:33 - 20:36
    touch file.txt, all right. Sure, enough.
  • 20:36 - 20:38
    It's there, so let's get out of there and
  • 20:38 - 20:41
    now to unmount it. We would do the same
  • 20:41 - 20:42
    thing backwards, right. We would just say
  • 20:42 - 20:45
    you mount mount secret okay. It's no
  • 20:45 - 20:48
    longer mounted and then, it's still
  • 20:48 - 20:51
    available in an unencrypted form though.
  • 20:51 - 20:53
    So what we would have to do is say Crypt
  • 20:53 - 20:58
    setup close Dev sdd one, just actually
  • 20:58 - 21:00
    the name of it which for us is secret
  • 21:00 - 21:01
    disc,
  • 21:01 - 21:04
    okay. And now we can no longer access it
  • 21:04 - 21:06
    without retyping in our password. I know
  • 21:06 - 21:08
    that was a lot. There's one more thing
  • 21:08 - 21:11
    that I, it isn't really specified but I
  • 21:11 - 21:13
    do want to show you. You can actually
  • 21:13 - 21:16
    automatically have it mount on boot and
  • 21:16 - 21:19
    it will prompt you during boot up for
  • 21:19 - 21:21
    the passphrase. In order to continue and
  • 21:21 - 21:23
    actually Mount the file system on boot.
  • 21:23 - 21:25
    There's also ways. You can create keys,
  • 21:25 - 21:26
    and have them stored in special places
  • 21:26 - 21:29
    like on a USB drive that you plug in but
  • 21:29 - 21:32
    let's quickly set up an automatic that
  • 21:32 - 21:34
    an automatic Mount that will prompt us
  • 21:34 - 21:38
    on boot to unencrypt the drive and then
  • 21:38 - 21:42
    we'll be done. So let's do the okay ID. So
  • 21:42 - 21:45
    this is our device. Let's get the uuid of
  • 21:45 - 21:48
    this device this is our crypto Lux
  • 21:48 - 21:51
    device itself. So I'm going to copy the
  • 21:51 - 21:54
    uuid and what we need to do is when the
  • 21:54 - 21:56
    system boots up, it will look in a file
  • 21:56 - 21:58
    called
  • 21:58 - 22:01
    Etc Crypt tab. So we have to create this
  • 22:01 - 22:04
    file and in here we actually specify,
  • 22:04 - 22:07
    what it is we want it to decrypt. And so
  • 22:07 - 22:09
    the first field is what we want it to be
  • 22:09 - 22:11
    called. In our case, I want it to be
  • 22:11 - 22:13
    called secret drive.
  • 22:13 - 22:16
    And then the next field is going to be
  • 22:16 - 22:19
    that uuid of the actual Luke's partition
  • 22:19 - 22:23
    itself and then the Third Field is just,
  • 22:23 - 22:24
    I'm just going to put a dash. This is
  • 22:24 - 22:26
    where we could tell it like to have a
  • 22:26 - 22:28
    key that we would automatically decrypt
  • 22:28 - 22:30
    it, but if we just put a dash here. It's
  • 22:30 - 22:32
    going to prompt us for that passphrase
  • 22:32 - 22:34
    as it tries to create secret Drive, okay.
  • 22:34 - 22:37
    So that it should be all we need to do
  • 22:37 - 22:41
    and then if we look in FS tab,
  • 22:41 - 22:43
    then we can assume that we've entered
  • 22:43 - 22:46
    our passphrase Dev mapper.
  • 22:46 - 22:50
    Secret Drive is going to be in Mount
  • 22:50 - 22:54
    secret and this is just ext4
  • 22:54 - 22:58
    defaults, zero zero that should be all. It
  • 22:58 - 23:00
    takes to get it to automatically Mount
  • 23:00 - 23:02
    after it prompts us for the passphrase
  • 23:02 - 23:04
    on boot. So let's reboot the system and
  • 23:04 - 23:06
    see what happens,
  • 23:07 - 23:10
    okay. It's asking us right here for the
  • 23:10 - 23:13
    passphrase. So let's put that in
  • 23:14 - 23:16
    all right we've booted up. Let's have a
  • 23:16 - 23:17
    quick look
  • 23:17 - 23:21
    TF minus H and we have drive one is
  • 23:21 - 23:23
    mounted drive, two is mounted drive three
  • 23:23 - 23:26
    is mounted and Drive Mount secret is
  • 23:26 - 23:28
    mounted so all of the things that we set
  • 23:28 - 23:32
    up survived the reboot including that
  • 23:32 - 23:34
    one that we did with system D and
  • 23:34 - 23:36
    automatically mounting this by prompting
  • 23:36 - 23:38
    us for that passphrase on boot. I know
  • 23:38 - 23:40
    that was a lot to cover and I encourage
  • 23:40 - 23:42
    you to look deeper into things like Auto
  • 23:42 - 23:44
    Mount because that's really fun, but it's
  • 23:44 - 23:47
    not part of the Linux plus objectives.
  • 23:47 - 23:49
    But anyway hopefully, all this made sense
  • 23:49 - 23:50
    maybe you have to go back through and
  • 23:50 - 23:52
    watch it I encourage you to try it on
  • 23:52 - 23:54
    your own system to make sure that you
  • 23:54 - 23:56
    can replicate what's going on as we went
  • 23:56 - 23:58
    along doing it and this is another
  • 23:58 - 24:01
    example of how important it is to learn
  • 24:01 - 24:03
    everything do what you love, and most
  • 24:03 - 24:06
    importantly be kind, I know this is a
  • 24:06 - 24:09
    long one. But I'll see in the next video.
Title:
Mounting Filesystems in Linux! (Linux+ Objective 1.3.3)
Description:

more » « less
Video Language:
English
Duration:
24:08

English subtitles

Revisions Compare revisions