Ceci est une ancienne révision du document !
I recently read a book called Linux Unveiled, that only unveiled that the author, ‘Half-job Hussain’, had no idea how to show newbies around. I did like some of the book somewhat (very little), so I’ll be stealing some of that to do a proper job for our FCM newbies. (No, I will not be using anything from that horrible book). I’ll try to take a more hands-on approach, so I would ask you to keep your terminal emulators open and follow along, just to get the muscle-memory going. Now obviously I cannot cover a whole book’s worth of stuff here, but I’m thinking CPU, memory and disk… This can then tie into some of the LPI stuff we are covering elsewhere. That means there will be homework, but I’ll keep it short.
By this issue, I’m assuming you added the second drive to your VM or added a physical drive to your metal. If you did not, do it quickly before continuing this article as it will revolve around you doing some practical work.
(As you can see, below, mine is added)
Now for a quick check, with:
df -h
Oh no! The disk is nowhere to be found. What to do?
First, let’s list out the block devices. You remember how! (lsblk, shown top right)
You can infer from my image that I have a disk, named sda1, that is mounted to “/” - meaning that this is my Lubuntu drive. You can also see a sdb, that is the “right size” for the disk we added. Currently you can see it has no mount points. If you would try to click on it in your file manager, you would get an error.
Any ideas? This is because we have no filesystem, that disk is considered RAW. So even though you can see it, you cannot use it.
Enter tool #1: cfdisk or fdisk
Right, open a terminal and type: sudo cfdisk /dev/sdb (as we saw in lsblk)
You will be prompted to choose a label type. We’ll just choose gpt for now.
Then, you will work from the screen shown above.
Notice the row of commands along the bottom.
Since we have “free space” and we need a new partition, we choose “new” and since there is no mouse interaction here, with “new” highlighted, press enter. You are given a partition size and told how to specify sizes. If you wanted a 500MB partition, you could type 500M and press enter, but in our case, we will accept the full size. When you hit enter, the drive is given a UUID. That UUID lives and dies with the drive. If you had a physical drive, this means that you could take it out of the external enclosure and mount it in the machine, and Linux would be fine with it, or vice-versa.
OK, but currently, the changes are only proposed, we need to write our changes to the disk. Select “write” and follow the prompts, to get your new disk sorted. We can now quit, highlight “quit” and press enter. Run lsblk again and compare the differences. You should see that sdb now has a partition, named sdb1. We are almost there, but not quite yet. We need a filesystem for the new disk. Let’s do it in the terminal also. Type: sudo mkfs.ext4 /dev/sdb1
Wham-bam-thankyou-mam and we are done. Here in Lubuntu, you can see that when I click on the drive, it mounts it, but it also has an eject symbol next to it (under devices). That is because it is not “permanently” mounted. For that, we need to edit the fstab file. However, we are not going to, as this drive is temporary, and faffing with fstab is dangerous for newbies, especially if you did not follow in a virtual machine.
Since you know how, please check how much of the disk is free, via the terminal. You can use the -l modifier to see only local filesystems, should you have any network filesystems mounted (df-lh).
If you were ever curious about what you could find out with the df command, type: df - - output ( that’s two dashes, no spaces).
That segues into something else, let’s check the status of our new disk. Oh no! We cannot check the S.M.A.R.T. status, as virtual machines do not support S.M.A.R.T. So any smarty pants who jumped the gun, good on you! I love to see it!
We can also get more information from lsblk, simply type lsblk -fs in your terminal and peruse the output.
Now I need to send you down the rabbit-hole. Clear your terminal with CTRL+L or the clear command, as we will need space. Type:
udevadm info -ap /sys/block/sdb
This displays the whole tree related to /dev/sdb, there should be pages of information. If you wanted a bit less, you could try: mount | grep sdb
You’d notice that you can see the UUID in both this mount command as well as in lsblk -fs. Remember that, before you just start poking about in fstab as a newbie.
With the mount command we can also find out more about our filesystem; type:
mount | grep ext4
and see what you get.
I’m going to end this one here, as I want us to do more exploring in the next issue, so see you there!
As per usual, if you see a mistake, let us know: misc@fullcirclemagazine.org