1
00:00:00,600 --> 00:00:01,620
In this lesson,

2
00:00:01,620 --> 00:00:04,530
we're going to talk about mounting file systems.

3
00:00:04,530 --> 00:00:06,000
After formatting partitions

4
00:00:06,000 --> 00:00:08,160
and logical volumes with file systems,

5
00:00:08,160 --> 00:00:10,800
we need to make those accessible for users.

6
00:00:10,800 --> 00:00:14,190
So we are going to make these file systems available for users

7
00:00:14,190 --> 00:00:16,920
by mounting them into the operating system.

8
00:00:16,920 --> 00:00:19,200
Now, before an operating system can read from

9
00:00:19,200 --> 00:00:21,450
or write to a disk, the file system

10
00:00:21,450 --> 00:00:24,510
on one of those disk partitions has to be mounted.

11
00:00:24,510 --> 00:00:27,390
Since a file system is really just a big array of bytes

12
00:00:27,390 --> 00:00:29,220
typically stored on a partition,

13
00:00:29,220 --> 00:00:32,400
you need to get access to the file system by mounting it.

14
00:00:32,400 --> 00:00:34,680
Now a mount point is an access point

15
00:00:34,680 --> 00:00:36,720
where information is going to be stored on a local

16
00:00:36,720 --> 00:00:38,490
or remote storage device.

17
00:00:38,490 --> 00:00:41,640
That mount point is typically going to be an empty directory

18
00:00:41,640 --> 00:00:44,580
on which a file system is going to be loaded or mounted

19
00:00:44,580 --> 00:00:47,610
to make that file system accessible to users.

20
00:00:47,610 --> 00:00:49,530
The mount command is what we're going to use

21
00:00:49,530 --> 00:00:52,410
to load a file system to a specified directory

22
00:00:52,410 --> 00:00:55,410
so it can be accessible to users and applications.

23
00:00:55,410 --> 00:00:58,680
To do this, we have to specify the device to mount to,

24
00:00:58,680 --> 00:01:00,630
as well as the desired mount point.

25
00:01:00,630 --> 00:01:03,780
The proper way to use the mount command is to type mount,

26
00:01:03,780 --> 00:01:05,129
the options you want to use,

27
00:01:05,129 --> 00:01:06,720
the device name you want to use,

28
00:01:06,720 --> 00:01:08,700
and the mount point you want to use.

29
00:01:08,700 --> 00:01:11,100
You can also specify various mount options

30
00:01:11,100 --> 00:01:12,600
for a file system.

31
00:01:12,600 --> 00:01:15,990
These options are typically included in the fstab file

32
00:01:15,990 --> 00:01:18,480
rather than as a command line argument.

33
00:01:18,480 --> 00:01:21,120
Option auto, for example, is used to specify

34
00:01:21,120 --> 00:01:24,330
that the device has to be mounted automatically.

35
00:01:24,330 --> 00:01:26,160
Noauto is going to be used to specify

36
00:01:26,160 --> 00:01:29,070
that the device should not be mounted automatically.

37
00:01:29,070 --> 00:01:31,320
Nouser is going to be used to specify

38
00:01:31,320 --> 00:01:34,710
that only the root user can mount a device or file system.

39
00:01:34,710 --> 00:01:36,690
And user is used to specify

40
00:01:36,690 --> 00:01:39,990
that all users can mount a device or file system.

41
00:01:39,990 --> 00:01:43,050
Exec is going to allow binaries in a file system

42
00:01:43,050 --> 00:01:44,250
to be executed,

43
00:01:44,250 --> 00:01:46,950
whereas noexec is going to be used to prevent binaries

44
00:01:46,950 --> 00:01:49,860
in a file system from being executed.

45
00:01:49,860 --> 00:01:53,460
Ro is going to be used to mount a file system as read only,

46
00:01:53,460 --> 00:01:56,220
whereas rw is used to mount that file system

47
00:01:56,220 --> 00:01:58,560
as a read or write partition.

48
00:01:58,560 --> 00:02:00,243
Sync is going to be used to specify

49
00:02:00,243 --> 00:02:02,040
that input and output operations

50
00:02:02,040 --> 00:02:05,400
in the file system should be done synchronously.

51
00:02:05,400 --> 00:02:07,980
Async, on the other hand, is going to be used to specify

52
00:02:07,980 --> 00:02:09,720
that the input and output operations

53
00:02:09,720 --> 00:02:13,350
in that file system can be done asynchronously.

54
00:02:13,350 --> 00:02:15,540
I know I just mentioned a lot of options there,

55
00:02:15,540 --> 00:02:16,890
and one of the things I mentioned

56
00:02:16,890 --> 00:02:19,140
was a binary being executed.

57
00:02:19,140 --> 00:02:20,790
Now you may not know what a binary is,

58
00:02:20,790 --> 00:02:22,590
so let me cover that real quick.

59
00:02:22,590 --> 00:02:25,170
A binary is source code that has been compiled

60
00:02:25,170 --> 00:02:27,030
into an executable program

61
00:02:27,030 --> 00:02:28,320
or otherwise assembled

62
00:02:28,320 --> 00:02:30,930
so it can be readable by the computer system.

63
00:02:30,930 --> 00:02:32,070
In addition to this,

64
00:02:32,070 --> 00:02:34,320
binaries can also be things like pictures,

65
00:02:34,320 --> 00:02:37,110
word-processing files, or spreadsheet files,

66
00:02:37,110 --> 00:02:38,730
essentially anything that is not

67
00:02:38,730 --> 00:02:41,100
a standard text readable file.

68
00:02:41,100 --> 00:02:42,990
Now after you're done using the file system,

69
00:02:42,990 --> 00:02:45,690
you may choose to unmount that file system.

70
00:02:45,690 --> 00:02:47,550
And this means it'll be disassociated

71
00:02:47,550 --> 00:02:50,310
from the directory by unloading or unmounting it

72
00:02:50,310 --> 00:02:52,230
so it's no longer going to be used.

73
00:02:52,230 --> 00:02:55,530
To do this, we're going to use the umount command.

74
00:02:55,530 --> 00:02:58,200
The umount command stands for unmount.

75
00:02:58,200 --> 00:03:00,180
In order to unmount a file system,

76
00:03:00,180 --> 00:03:02,280
it has to not be in use currently.

77
00:03:02,280 --> 00:03:04,350
That means that you can't have any files

78
00:03:04,350 --> 00:03:07,260
from that file system currently open in some application

79
00:03:07,260 --> 00:03:09,000
like a word-processing program

80
00:03:09,000 --> 00:03:11,460
or a spreadsheet or something like that.

81
00:03:11,460 --> 00:03:14,820
The proper way to use the umount command is to enter umount,

82
00:03:14,820 --> 00:03:16,860
the options, and the mount point.

83
00:03:16,860 --> 00:03:19,410
There's also some common options for you umount,

84
00:03:19,410 --> 00:03:22,380
things like -f, which will force a file system

85
00:03:22,380 --> 00:03:25,230
to be unmounted despite any detected issues.

86
00:03:25,230 --> 00:03:27,420
Be very careful using this one.

87
00:03:27,420 --> 00:03:29,670
There's another option known as -l.

88
00:03:29,670 --> 00:03:31,800
This is used to perform a lazy unmount,

89
00:03:31,800 --> 00:03:34,410
in which the file system is detached from the hierarchy,

90
00:03:34,410 --> 00:03:37,290
but references to that file system are not cleaned up

91
00:03:37,290 --> 00:03:39,990
until the file system is no longer being used.

92
00:03:39,990 --> 00:03:43,140
We can also use -R, which recursively unmount

93
00:03:43,140 --> 00:03:45,210
the specified directory's mount points.

94
00:03:45,210 --> 00:03:48,330
We can also use -t and the file system type

95
00:03:48,330 --> 00:03:50,400
if we want to unmount only the file system types

96
00:03:50,400 --> 00:03:53,010
that are specified like all FAT partitions

97
00:03:53,010 --> 00:03:55,230
or all Ext2 partitions.

98
00:03:55,230 --> 00:03:58,170
We can also use -O with some mount options

99
00:03:58,170 --> 00:04:00,240
to unmount only the file systems that are mattered

100
00:04:00,240 --> 00:04:05,160
with the specified options inside the /etc/fstab file.

101
00:04:05,160 --> 00:04:09,000
Or we can type -fake to test the unmounting procedure

102
00:04:09,000 --> 00:04:11,730
without actually unmounting the file system.

103
00:04:11,730 --> 00:04:14,160
Remember, mounting of the file system occurs

104
00:04:14,160 --> 00:04:16,140
during the startup process normally,

105
00:04:16,140 --> 00:04:21,060
and it's managed by the /etc/fstab configuration file.

106
00:04:21,060 --> 00:04:22,860
An easy way to remember this is that,

107
00:04:22,860 --> 00:04:25,830
fstab stands for file system table.

108
00:04:25,830 --> 00:04:27,600
And it's a list of all the file systems

109
00:04:27,600 --> 00:04:28,920
that need to be mounted,

110
00:04:28,920 --> 00:04:30,270
their designated mount points,

111
00:04:30,270 --> 00:04:32,250
and any other options that might be needed

112
00:04:32,250 --> 00:04:34,470
for specific file systems.

113
00:04:34,470 --> 00:04:36,840
Another method of mounting a file system is to use

114
00:04:36,840 --> 00:04:39,210
the systemd or system daemon.

115
00:04:39,210 --> 00:04:42,330
The systemd.mount can be used to create a new mount unit

116
00:04:42,330 --> 00:04:44,160
to mount this file system.

117
00:04:44,160 --> 00:04:46,830
To set this up, you need to create a text file located

118
00:04:46,830 --> 00:04:50,850
in the /etc/systemd/system directory

119
00:04:50,850 --> 00:04:53,550
and name it as something.mount.

120
00:04:53,550 --> 00:04:55,200
For example, here, I'm going to create

121
00:04:55,200 --> 00:04:59,862
a text file called /etc/systemd/system

122
00:04:59,862 --> 00:05:03,492
/var-lib-docker.mount.

123
00:05:03,492 --> 00:05:05,220
And this is going to be used to mount a specific disk

124
00:05:05,220 --> 00:05:09,870
and its UUID to the /var/lib/docker directory

125
00:05:09,870 --> 00:05:11,310
as a mount point.

126
00:05:11,310 --> 00:05:14,280
I've done this using the btrfs file system

127
00:05:14,280 --> 00:05:15,990
and the default options.

128
00:05:15,990 --> 00:05:18,720
To enable this, I'm going to use systemctl

129
00:05:18,720 --> 00:05:23,580
and enter systemctl enable var-lib-docker.mount

130
00:05:23,580 --> 00:05:25,020
at my Command Prompt.

131
00:05:25,020 --> 00:05:26,460
When I reboot my system,

132
00:05:26,460 --> 00:05:28,200
this new mount point is going to be created,

133
00:05:28,200 --> 00:05:30,360
and the disk is going to be mounted to it.

134
00:05:30,360 --> 00:05:31,650
The final thing I want to discuss

135
00:05:31,650 --> 00:05:34,200
in this lesson concerning file systems is the concept

136
00:05:34,200 --> 00:05:38,010
of FUSE, which is the Filesystem in USErspace.

137
00:05:38,010 --> 00:05:40,500
FUSE is a software interface in Linux systems

138
00:05:40,500 --> 00:05:43,650
that lets non-privileged users create their own file systems

139
00:05:43,650 --> 00:05:46,410
without editing the underlying kernel code.

140
00:05:46,410 --> 00:05:48,300
FUSE was originally developed and designed

141
00:05:48,300 --> 00:05:49,890
as a virtual file system

142
00:05:49,890 --> 00:05:52,290
that allows you to specify how read, write,

143
00:05:52,290 --> 00:05:55,140
and stat requests can be made to a file system,

144
00:05:55,140 --> 00:05:58,140
as well as how to mount this new file system you'd create.

145
00:05:58,140 --> 00:06:00,810
FUSE is commonly used to create virtual file systems

146
00:06:00,810 --> 00:06:02,910
that are detached from the underlying physical media

147
00:06:02,910 --> 00:06:04,320
or drives themself.

148
00:06:04,320 --> 00:06:06,810
And this allows them to act as sort of a translation

149
00:06:06,810 --> 00:06:09,510
between different file system types as needed.

150
00:06:09,510 --> 00:06:11,520
For example, if you need to be able to read

151
00:06:11,520 --> 00:06:13,800
or write to an NTFS-based volume

152
00:06:13,800 --> 00:06:15,750
but your system doesn't support it natively,

153
00:06:15,750 --> 00:06:18,080
you could write a translation program using the Filesystem

154
00:06:18,080 --> 00:06:21,210
in USErspace to provide you with this capability.

155
00:06:21,210 --> 00:06:23,220
Other common uses of FUSE is to allow

156
00:06:23,220 --> 00:06:25,350
a local Linux operating system to interact

157
00:06:25,350 --> 00:06:27,420
with cloud-based file storage systems

158
00:06:27,420 --> 00:06:31,230
like Amazon's S3 Buckets or Microsoft Azure Blobs.

159
00:06:31,230 --> 00:06:33,480
As you can guess, FUSE is really useful

160
00:06:33,480 --> 00:06:34,440
to be able to read and write

161
00:06:34,440 --> 00:06:36,330
to all sorts of different file systems

162
00:06:36,330 --> 00:06:37,650
that you can then mount easily

163
00:06:37,650 --> 00:06:39,550
inside of your Linux operating system.

