Tech Junkie Blog - Real World Tutorials, Happy Coding!: Storage

Latest Posts

Showing posts with label Storage. Show all posts
Showing posts with label Storage. Show all posts

Monday, January 3, 2022

LVM in Linux allows multiple disks to be combined into one called logical volumes via software.  In this post we are going to create LVMs for a brand new system.  There are two scenarios, the first is LVM on a new system and the second scenario is to create LVM on an existing system.

I am going to create the new system on VirtualBox, I will not go through the process of create a new VM on VirtualBox because I've covered that in the past.  You can search for it on my site if you are lost.

Here are the steps to creating LVM during installation:

1.  On the first screen of installation select the first option




















2. Select your language, then click "Continue"



























3. On the "Installation Summary" screen click on "Network & Hostname"



























4. Give your system a hostname and click "Apply", then click "Done"



























5. Click on "Installation Destination"



























6. Select disk on the screen and make sure you select "Custom




























7. On the "Manual Partitioning" screen select LVM




























8. Then click on the + sign
9. The first mount point you are going to create is the /boot mount point because it is required, but it doesn't require a lot of disk space, so we are going to allocate 500m.  A custom Logical Volume basically let's you divide the 8GB on the disk anyway you like instead of letting the operating system decide for you.  That's why most systems run out of disk space at the root level which is / because the operating system did not allocate enough space at installation. Click on "Add mount point" when done

10. On the confirmation screen reselect LVM on the drop down if Standard is selected, accept the default, notice now you only have 7.5GB of disk space left, that's because you allocated 500MB to the /boot mount.

11. Click on the + sign again, this time assign 2 GB to the /home mount, follow the steps above to create the /home mount point with 2 GB




12. Repeat the steps for /var and allocate 2 GB to it and the mount swap with 1 GB, your screen should look like the following when you are finished


13.  You should be left with about 3 GB of disk space left, the best thing we can do right now is to assign it to the root / mount so that we are using all the capacity of the disk.  To do that click on the + sign again, select / from the mount dropdown and type all in the "Desired Capacity" field, then click on the "Add mount point" button


Your screen should look like the following when you are done, click "Done"


Error checking will be performed and a message will pop up telling you to click "Done" again.  "Accept Changes"

14.  While Error checking is performed on the disk, create a root password by clicking on "Root Password" follow the direction to create a root password

15. For Error checking, it says that /boot cannot be LVM so change it to Standard

Note: I had to add a bigger disk on VirtualBox because apparently CentOS required more disk space for installation.  It would not pass the installation requirements, so I used a 25 GB disk.  But the instructions should be the same.


16.  Once the root password has been created click on the "Begin Installation" button.


17.  This step is going to take awhile.

18.  Once installation is complete remove the installation media and click on "Reboot System"

19. On reboot for the first time you will be asked to create a new user, that's up to you.  I usually create one just for convenience.  If you don't want to create a user just accept the license and click "Finish Configuration"

20. Once you completed the configuration steps and logged in, type df -h in the terminal and you will see that the disk's setup is as you specified in your installation






Monday, September 20, 2021

 In the last post we created a new partition for a new disk that we've just added, in this post we are going to mount the partition and create a filesystem for the partition so that we can use it.  First lets check to see that we have a new partition by running the fdisk -l command














As you can see a new partition called /dev/sdb1 has been created with 8 GB of disk space.  Now we all good to go.

Here are the steps to mount and create a file system in Linux:

1. First we need to create a filesystem so that the Linux system can read and write to it.  Linux uses the xfs filesystem so that's what we are going to use.  To do that we have to run the mkfs command. To make an xfs filesystem you simply type mkfs.xfs /dev/sdb1







2. Now that we have a filesystem that Linux could understand, it is time to mount the partition so that we could use in our server.  It's a two step process to accomplish that, first you have to create a directory, type mkdir /data to create /data directory.  Then you are going to mount the partition to that directory with this command mount /dev/sdb1 /data now if you run the command df -h you will see the partition has been mounted to the /data director








3. We still have one more step before we are finished.  Everything will work like it should, but once you reboot the settings will not persist in it's current state.  To make the settings persist we have to edit the fstab file.  So type the command vi /etc/fstab make sure you have your system backed up and you can revert back because if you messed up you will not be able to log in. When you are in the fstab file type in the following line at the end of the file

/dev/sdb1               /data                   xfs     defaults        0       0

The spaces are tabs, the 0s are options for file system checks on boot.  You probably don't want that, so just type 0s to skip it. Press esc and :wq! to write to the file.














4. Reboot and run the df -h command again and you should see that the changes persist and you can use the new partition


Monday, September 13, 2021

 In the previous post we used the df and fdisk commands to gather storage information about our Linux system.  In this post we are going to add a new disk and partition to our system.  I am using VBox and you can create a new storage by going to settings and adding a new disk, it will be just like adding a real physical disk on a physical machine except it's virtual.  You can go to this post if you want to know how to do it

Here are the steps to adding a new disk and creating a partition for the disk:

1. First we want to see what the new disk is identified as in our Linux system, we can do that by typing the command fdisk -l








As you can see the new disk is identified as /dev/sdb and it has 8 GB which is correct

2. We want to go into the fdisk utility to work with our new disk, to do that you type fdisk /dev/sdb then press enter





3. Press m to see all the options that are available





















From the help menu we know that we have to use the n option to add a new partition

4. Type n and then press Enter to get into the create partition steps

5. You will be given a choice of the partition being a primary or extended, since this is a new disk we want to make it a primary partition, so press p and ENTER






6. For the partition number accept the default 1 by pressing ENTER, once again it's a new disk so it's going to be the first partition on the disk

7. Accept the default again for the first sector by pressing ENTER





8. Accept the default again by pressing ENTER, if you want to create more than one partition and not use the entire disk you enter the size so that there's disk space left like this +4G, and it would use only 4 GB for the partition, but since we want to use the entire disk we just going to press ENTER







A new partition has been created for the new disk.  Or have you? A lot of beginners forget to do the next step and the partition is not created even though they went to through all the steps. The final step to the process is that you have to type w to write your changes else nothing will happen.  It's just a confirmation that fdisk needs, for you to confirm that the changes are correct in the final step.





 In the next post we are going to mount the partition and create a filesystem for the new partition.

Monday, September 6, 2021

 To simulate a real world scenario often times you have to add components to your virtualize Linux operating system.  In this post we are going to add a new disk to our virtual machine in Oracle's VirtualBox.  

Here are the steps to adding a new disk to a VM:

1.  Right click on your virtual machine and select settings then select "Storage", the power must be off.  Click on the second icon next to the "Controller: SATA" section








2. On the next dialog click on the "Create" icon









3. Click "Next"














4. Click "Next"














5. Type in a name for the disk and then click "Create"














6. Select the disk under "Not Attached" and then click on "Choose"














7. Now your new disk is attached to the Virtual Machine, click "OK"






Search This Blog