Pages

Tuesday, May 21, 2019

Enabling Graphical User Interface (GUI Mode) on CentOS - Linux

Problem: How to enable Graphical User Interface (GUI Mode) on Pre-Installed Linux machine with core.


Solution : 

Prerequisite :

1. You must have sudo access access to your Linux machine.
2. Your Linux machines must have access to either internet or latest Yum Repositories. 

Steps: 

To enable GUI on your Linux (CentOS), you need following commands to be run in a sequence:

1. Install GNOME Desktop through following command:

# sudo yum group install "GNOME Desktop"

It will install all the required binaries on your Linux machine.

2. To confirm that GNOME Desktop (GUI) has been successfully installed on your machine, run following command:

# startx

Accept the license agreement and then set few local language settings. 
Click done.

It confirms that GUI has successfully been installed on your machine but it is temporary. As soon as you will reboot your machine, you will again reach to your black terminal. 

3. To make GUI as your default mode run following command.

# systemctl set-default graphical.target

The output of this command will be similar to following:

Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.

It will permanently  change your run level from runlevel3 (Core with Networking) to runlevel5 (Graphical). Now you will get the GUI based login screen when even you will reboot / log on to your Linux (CentOS) machine.



Enjoy!!!!


Monday, May 13, 2019

Attaching a New Volume to an EC2 Linux instance

Problem: Step by Step process to attach a new volume (new disk) to running EC2 instance


Solution:

Pre-Requisite:

1. You must have an AWS subscription.
2. An EC2 with Linux (Amazon AMI or RedHat AMI) must be in running state.

Steps:

Adding New Volume from AWS Console.


  • Go to Volumes from your EC2 Dashboard and click on "Create Volume"
  • Select the Volume Type as (General Purpose SSD - GP2) , Size as 10 GB, Availability Zone, and leave rest of options as default.
  • Click on Create Volume.



 2. You will get a confirmation that your volume has been created successfully and it will show the volume Id in the next screen.


   3. Now click on Close , it will take you to the Volumes console where you will find an additional disk with "Available" status.



4. You have successfully created a new Volume of 10 GB size, now its time attaching this disk to your EC2 instance. To attache this new volume as a disk to your EC2 instance, select that new volume and click on "Action" and select "Attache Volume" option.

5. It will take you to the next screen where you will put the instance ID from the drop down menu and the Partition name of the disk will be automatically selected (as /dev/sdf) .. it is default path selected for the new volume by AWS.


6. Click on Attach button, and AWS will confirm that you have successfully attached the new volume to an instance. In the next window you will see that both volumes' status is now "in-use".



Commands for Mounting the New Volume in the EC2 Instance:


7. Since this EC2 instance is a linux instance , we will have to mount it as new partition / disk from the linux OS.

8. Log on to your EC2 instance, to which this new volume has been attached from AWS console.


9. type sudo su to take root access of the OS.

10. Now put the following command to list the available disks on your Linux EC2 instance.

    lsblk

It will list all disks available to the OS. In our example we can see that the last disk with them xvdf is visible (with 10G capacity).



We have to mount this disk to OS to use as data1 disk.

11.  Now check if this new disk contains any data or not. Run the following command to know this:

   #file -s /dev/xvdf

if the output of this command is /dev/xvdf:data then it means that this disk is empty.



12. Now format this disk / volume to use the file system ext4 with following command.

# mkfs -t ext4 /dev/xvdf

if you have shoot the command properly and there is no other error, it should give following results.



13.  Create a directory of your choice to mount our new ext4 volume. I am using the name “data1

 mkdir /data1

14. Now mount the new volume to "data1" directory through following mount command

# mount /dev/xvdf  /data1/



15. Now your new volume has been successfully mounted and is ready to use. you can confirm its usability using df -H command. It should produce following results:


This output confirms that your disk / volume has been successfully attached and mounted to your Linux OS for use.

Make the EBS Volume Mount permanent on Linux.


The Volume which we just mounted in previous steps is temporary. As soon as your OS will restart, this mount point will be lost and you will no longer be able to use this disk using /data1 path. To make it permanently available for use even after reboot, you will need to make changes in /etc/fstab file.

16. Take the back of fstab file using following command before making any changes.

# cp /etc/fstab /etc/fstab.old



17. Now make the following entry in /etc/fstab file using #vi /etc/fstab command

      /dev/xvdf      /data1        ext4       defaults,nofail

Save the fstab file using :wq! and exit the vi editor.



18. Now run the following command to check if the fstab file has any errors after you made this entry.

# mount -a

If your fstab file does not have any error the command will run seem less and you are done with 

19. Now reboot your EC2 instance, and it will mount the new volume automatically. you can check that with df -f command.




Hope This Helps !!!!