Now those very astute among you may have noticed that on my virtual
machine, I have the one disk, sda, in my system.
Now if we want to be looking at partitioning and working with our filesystems,
we're going to need some additional disks.
But don't worry, we can use virtual disks.
Virtual disks, not in the way, let's say, of virtual machines,
but in the way we can create disk files.
Now the first type of this file that we can look at using are maybe
ISO files. ISO files, obviously, you can download from the
internet, and they are files with pre‑created filesystems on them.
So we can go through and mount those ISO files and use them as our
filesystems directly.
But we want to, as well as working maybe with ISO files to get the
idea of disk files, work with disk files ourselves.
And these disk files can be created either using the dd
command or the fallocate command.
These, then create large, empty files that we can then
link to device files using losetup.
The first thing that we take a look at is maybe with ISO files because
these are simple, and we probably all know what they are.
We can make sure, then that we've got wget installed. Yum list wget will
list it either as being available or installed. But if we didn't know the
package, we could also use the command yum provides and then put the path
to the executable that we want.
So we want the executable wget. It's going to be in the /usr/bin, so it becomes
very easy to search for the name of the package. That aside,
that's our software management. We can then go ahead and make sure that we've
got wget installed, and we're installing wget so we can go download a file from
the internet. And as we go through and take a look at it, I'm not so bothered
about the file that we are downloading.
It really doesn't matter.
I'm more interested that it's just 36 MG.
I don't want to download anything particularly large or you to
have to download anything particularly large.
So the only reason we're downloading this file is just that we've got an
ISO file to be able to work with. Having downloaded it, we can just go
straight ahead and mount this. And don't forget that most files in Linux
are in lowercase, so it's very easy to do a sudo and mount, uppercase V,
and then use tab completion.
We're using sudo in front of the mount command because as ordinary users,
we don't have the privileges to make this mount. We can mount it to the
temporary directory, /mnt. And this temporary mount point then becomes
available for us to use if we don't need to persist the mount, so this
makes a good target. We can then go through and list this, so list the
contents of our mnt directory.
We, of course, can go through and look at our block
devices, but the ISO file isn't a device.
So under lsblk, we're going to see that we have some form of looper device,
but we can see the loop device being linked using losetup.
Once we're finished with this, we unmount our mount
point using the command umount.
So that's a quick look at using ISO files. ISO files are pre‑created
filesystems in a single file, but we can go ahead and create our raw disk
files, and we can use the dd command. With the dd command, we actually write,
in this case, a gig of data through to the disk.
But we can also go through and use the fallocate command. Using the
fallocate command, we're really creating a sparse file.
We're assigning or allocating the 1 GB of disk space, but there's no
need to go ahead and create any data or write any data.
So both are doing the same thing, but just fallocate is going to take a lot
shorter amount of time. Now why don't we go through now and take a look at
the command line, so we can see some of this in action? And remember, that
really is where you guys are going to be getting your real learning by great hands‑on practice.