LVM Interview Questions and Answers

 Logical Volume Manager (LVM) is a powerful tool for managing disk space in a flexible and scalable manner on Linux systems. Here are some common LVM interview questions and their answers to help you prepare:

Basic Concepts

  1. What is LVM and why is it used?

    • Answer: LVM stands for Logical Volume Manager. It is used to manage disk drives and other storage devices. LVM allows for flexible disk management, including creating, resizing, and moving partitions without downtime. This makes it easier to manage disk space and provides a way to dynamically adjust to changing storage needs.
  2. What are the components of LVM?

    • Answer:
      • Physical Volume (PV): Physical storage device or partition.
      • Volume Group (VG): Aggregates multiple PVs into a single storage pool.
      • Logical Volume (LV): Created from the storage pool provided by a VG, and can be resized or moved more easily than traditional partitions.

Commands and Operations

  1. How do you create a physical volume?

    • Answer: pvcreate /dev/sdX (where /dev/sdX is the physical disk or partition).
  2. How do you create a volume group?

    • Answer: vgcreate vg_name /dev/sdX1 /dev/sdX2 (where vg_name is the name of the volume group and /dev/sdX1, /dev/sdX2 are the physical volumes).
  3. How do you create a logical volume?

    • Answer: lvcreate -n lv_name -L size vg_name (where lv_name is the name of the logical volume, size is the size of the LV, and vg_name is the volume group).
  4. How do you extend a logical volume?

    • Answer: lvextend -L +size /dev/vg_name/lv_name (where size is the amount to increase).
  5. How do you resize a filesystem on a logical volume?

    • Answer: For ext4: resize2fs /dev/vg_name/lv_name. For XFS: xfs_growfs /mount_point (assuming the logical volume is already mounted).

Advanced Operations

  1. How do you reduce the size of a logical volume?

    • Answer:
      • First, resize the filesystem to a smaller size: resize2fs /dev/vg_name/lv_name new_size (for ext4).
      • Then reduce the LV size: lvreduce -L new_size /dev/vg_name/lv_name.
      • Note: Always ensure that the filesystem is not in use and is backed up before reducing its size.
  2. How do you remove a logical volume?

    • Answer: lvremove /dev/vg_name/lv_name.
  3. How do you remove a volume group?

    • Answer:
      • Remove all logical volumes within the volume group: lvremove /dev/vg_name/lv_name.
      • Remove the volume group: vgremove vg_name.
  4. How do you remove a physical volume?

    • Answer: Ensure the PV is not in use by any VG: vgreduce vg_name /dev/sdX.
      • Then remove the PV: pvremove /dev/sdX.

Troubleshooting and Best Practices

  1. What is a PV metadata and how do you view it?

    • Answer: PV metadata contains information about the physical volumes, volume groups, and logical volumes. You can view it using pvdisplay.
  2. How do you move data from one physical volume to another?

    • Answer: Use the pvmove /dev/sdX1 /dev/sdY1 command to move data from one PV to another within the same VG.
  3. What are the benefits of using LVM snapshots?

    • Answer: LVM snapshots allow you to create point-in-time copies of logical volumes, which are useful for backups, testing, and recovery purposes. They can be created and managed without interrupting the service.
  4. How do you create an LVM snapshot?

    • Answer: lvcreate --size size --snapshot --name snapshot_name /dev/vg_name/lv_name.

Example Scenario

  1. Scenario: You have a volume group vg_data with two physical volumes /dev/sda1 and /dev/sdb1. You need to create a new logical volume lv_backup of size 10G. How would you do it?

    • Answer:
      bash
      vgcreate vg_data /dev/sda1 /dev/sdb1 lvcreate -n lv_backup -L 10G vg_data mkfs.ext4 /dev/vg_data/lv_backup mount /dev/vg_data/lv_backup /mnt/backup
  2. Scenario: Your logical volume lv_data is running out of space. You have added a new physical disk /dev/sdc1. How do you extend the logical volume and resize the filesystem?

    • Answer:
      bash
      pvcreate /dev/sdc1 vgextend vg_data /dev/sdc1 lvextend -L +20G /dev/vg_data/lv_data resize2fs /dev/vg_data/lv_data

My Question:

Are there specific aspects of LVM management or particular scenarios you’d like more detailed explanations on?

WHAT IS DIGITAL PLANNER

 A digital planner is an electronic version of a traditional paper planner. It is designed to help you organize your schedule, tasks, goals, and notes using digital devices like tablets, smartphones, or computers. Digital planners can come in various formats, such as apps, PDF files, or integrated software features. Here are some key features and benefits of using a digital planner:

Key Features:

  1. Calendar Integration:
    • Sync with your device’s calendar for automatic updates and reminders.
  2. Task Management:
    • Create, prioritize, and track tasks and to-dos.
  3. Goal Setting:
    • Set and track short-term and long-term goals.
  4. Customization:
    • Personalize layouts, colors, and templates to fit your preferences.
  5. Accessibility:
    • Access your planner from multiple devices and locations.
  6. Note-Taking:
    • Add handwritten or typed notes, attach files, and insert images.
  7. Habit Tracking:
    • Monitor and track daily habits and routines.
  8. Search Functionality:
    • Easily find past entries or specific information.
  9. Cloud Storage:
    • Save data to the cloud for backup and easy access across devices.
  10. Collaboration:
    • Share and collaborate on plans with others.

Benefits:

  • Convenience: Carry all your planning tools in one device.
  • Eco-Friendly: Reduce paper usage.
  • Flexibility: Easily edit, move, or delete entries.
  • Efficiency: Automate reminders and recurring tasks.
  • Enhanced Features: Utilize multimedia, hyperlinks, and interactive elements.

Example:

Imagine you are a student. A digital planner can help you keep track of your class schedule, assignments, exams, and extracurricular activities. You can set reminders for due dates, take notes during lectures, and sync your planner with your school’s online portal for updates on grades and announcements.

Example Setup:

  1. Weekly Overview: Display a week-at-a-glance view with your classes and study sessions.
  2. Daily Log: Detail your tasks, priorities, and notes for each day.
  3. Assignment Tracker: Monitor progress on projects and homework with deadlines and completion status.
  4. Exam Schedule: Plan study sessions and mark exam dates.
  5. Goal Section: Set academic and personal goals, such as reading more books or joining a club.

Tips for Using a Digital Planner:

  • Regular Updates: Consistently update your planner to stay organized.
  • Explore Features: Take time to learn all the functionalities your digital planner offers.
  • Customization: Adjust the layout and features to suit your needs.
  • Integration: Sync with other productivity tools you use, such as email or task managers.

My Question:

What specific aspect of your life or work are you hoping to improve with a digital planner? This will help me give you tailored advice and examples.

How to install a package forcefully in Linux

Install a package forcefully in Linux

Before installing a package forcefully, first understand a situation where we need this force option.
Let me corrupt one command and show you how to install it's package forcefully.
First check the package of the command we are going to corrupt. Let say mount command.

# which mount
# rpm -qf /bin/mount


[root@linuxelearn Packages]# which mount
/bin/mount
[root@linuxelearn Packages]# rpm -qf /bin/mount
util-linux-ng-2.17.2-6.el6.x86_64
[root@linuxelearn Packages]#


Okey, so we know the package of mount let's copy other commands content over mount command. Let copy date commands contents over mount command.

#cp /bin/date /bin/mount


[root@linuxelearn Packages]# cp /bin/date /bin/mount
cp: overwrite `/bin/mount'? y
[root@linuxelearn Packages]#


Now when you run mount command it will show Date, that means it is corrupted.

[root@linuxelearn Packages]# mount
Tue Mar 14 22:59:43 IST 2017
[root@linuxelearn Packages]# date
Tue Mar 14 22:59:49 IST 2017
[root@linuxelearn Packages]#


So to fix the mount command we need to reinstall it's package, let's install the package and check whether mount command is fixed or not. Move to the folder where you kept the package and install it.

#rpm -ivh util-linux-ng...


[root@linuxelearn Packages]# rpm -ivh util-linux-ng-2.17.2-6.el6.x86_64.rpm
warning: util-linux-ng-2.17.2-6.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
            package util-linux-ng-2.17.2-6.el6.x86_64 is already installed
[root@linuxelearn Packages]#


It says the package already install, check by using mount command whether it is working fine.

[root@linuxelearn Packages]# mount
Tue Mar 14 23:03:41 IST 2017
[root@linuxelearn Packages]#


opps...! It isn't fixed yet, now in such to force the installation to be done, the syntax is

#rpm -ivh <package name> -- force
#rpm -ivh util-linux-ng...


[root@linuxelearn Packages]# rpm -ivh util-linux-ng-2.17.2-6.el6.x86_64.rpm --force
warning: util-linux-ng-2.17.2-6.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:util-linux-ng          ########################################### [100%]
[root@linuxelearn Packages]#


Okay then we have not only installed package successfully but we have also fixed the command. Congratulations.

Now we run the mount command check output.


[root@linuxelearn Packages]# mount
/dev/sda2 on / type ext4 (rw)
oproc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
/dev/sr0 on /media/RHEL_6.0 x86_64 Disc 1 type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)
/dev/sdb on /media/XIAOMI type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)
[root@linuxelearn Packages]#


This is step by step solution of install package forcefully.


I Hope You Enjoyed reading This articule…..

How to check the package of a particular command

Check the package of a particular command

If in Linux any command not working properly then find out the location of command and reinstall the package before that you have to check package of particular command

There are only two commands for checking a package of particular command.

To check the package of particular command, first check the installed location o a command using following command.

#which <command name>
#which cat


[root@linuxelearn Packages]# which cat
/bin/cat
[root@linuxelearn Packages]#


Now, use the following command
#rpm -qf <path of the command>
#rpm -qf /bin/cat


[root@linuxelearn Packages]# rpm -qf /bin/cat
coreutils-8.4-9.el6.x86_64
[root@linuxelearn Packages]#



I hope you enjoyed reading this article…

How to install package in Linux using RPM command.

Install package in Linux using RPM command.

In Linux there are two utilities are used for install package.
  • 1.   RPM – Redhat Package Manager
  • 2.   YUM- Yellowdog Updater modified

But in this toturial we will learn about RPM and how to install package using RPM command.

RPM – Redhat Package Manager

RPM is package managing system ( collection of tools to manage software packages). RPM is a powerful software management tool for installing, uninstalling, verifying, querying and updating software packages. RPM is a straight forward program to perform the above software management tasks.

Features:
  • RPM can verify software packages.
  • RPM can be served as a powerful search engine to search for software’s.
  • Components, software’s etc can be upgraded using RPM without having to reinstall them.
  • Installing, reinstalling can be done with ease using RPM.
  • During updates RPM Handels configuration Files carefully, so that the customization is not lost.


To install a package using rpm command and check whether it is installed properly or not.

In linux to install the package first we need to be in the directory of the package


[root@linuxelearn RHEL_6.0 x86_64 Disc 1]# cd Packages
[root@linuxelearn Packages]# ls  | grep -i finger
finger-0.17-39.el6.x86_64.rpm
finger-server-0.17-39.el6.x86_64.rpm
gdm-plugin-fingerprint-2.30.4-21.el6.x86_64.rpm
[root@linuxelearn Packages]#


To install the package use the following command.
#rpm -ivh <package name>
#rpm -ivh finger-0.17-39.el6.x86_64.rpm


[root@linuxelearn Packages]# rpm -ivh finger-0.17-39.el6.x86_64.rpm
warning: finger-0.17-39.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing...                ########################################### [100%]
   1:finger                 ########################################### [100%]
[root@linuxelearn Packages]#


For check whether it is installed or not use following command
#rpm -qa finger


[root@linuxelearn Packages]# rpm -qa finger
finger-0.17-39.el6.x86_64
[root@linuxelearn Packages]#


Check the installed package by using it command, finger is used to check user's details.
#finger <user name>
#finger Pooja


[root@linuxelearn Packages]# finger pooja
Login: pooja                                        Name:
Directory: /home/pooja                       Shell: /bin/bash
Never logged in.
No mail.
No Plan.
[root@linuxelearn Packages]#


How to remove a package or uninstall the package in linux.

In Linux for remove a package use the following synxax.
#rpm -e <package name>
#rpm -e finger
Verify whether the package uninstall or not using this command # rpm -q or #rpm -qa command.


[root@linuxelearn Packages]# rpm -e finger
[root@linuxelearn Packages]# rpm -q finger
package finger is not installed
[root@linuxelearn Packages]# rpm -qa finger
[root@linuxelearn Packages]#


How to see information about the installed package.

To see the information or details about the installed package, the syntax is
#rpm -qi <package name>
#rpm -qi vsftpd


[root@linuxelearn Packages]# rpm -qi vsftpd
Name        : vsftpd                       Relocations: (not relocatable)
Version     : 2.2.2                             Vendor: Red Hat, Inc.
Release     : 6.el6                         Build Date: Wed 26 May 2010 06:16:30 PM IST
Install Date: Wed 24 Aug 2016 07:23:00 PM IST      Build Host: x86-004.build.bos.redhat.com
Group       : System Environment/Daemons    Source RPM: vsftpd-2.2.2-6.el6.src.rpm
Size        : 338480                           License: GPLv2 with exceptions
Signature   : RSA/8, Tue 17 Aug 2010 01:49:04 AM IST, Key ID 199e2f91fd431d51
Packager    : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL         : http://vsftpd.beasts.org/
Summary     : Very Secure Ftp Daemon
Description :
vsftpd is a Very Secure FTP daemon. It was written completely from
scratch.
[root@linuxelearn Packages]#


I Hope You enjoyed reading this article….


How to manage installed services in Linux.

manage installed services in Linux.

Services in linux are programs or called daemon's that once started run continuously in the background and are ready for input or monitor changes in your computer and respond to them. For example the Apache server has a daemon called httpd ( The d is for daemon ) that listens on port 80 your computer and when it receives a request for a page it sends the appropriate data back to the client machine.

Many services are required to run all the time however many can be safely turned of for both security reasons as running unnecessary services opens more doors into your computer, but also for performance reasons. It may not make much difference but your computer should boot slightly faster with less services it has to start on boot.
One of the techniques in every Linux administrators toolbox to improve security of a box is to turn off unneeded services.

Chkconfig and service Commands

There are 2 commands used to control services:
  • Service – This controls the starting and stopping of services during a session, these setting are not saved. If you start Apache this way but it is not set to start on boot using the above method then it will continue to run but on next boot will not start automatically.
  • Chkconfig – This controls which services are set to start on boot, by their nature these setting are saved and are applied at next boot. Changing these settings will not start the services immediately; it will just flag them to be strated from the next boot.

The command use for maintaining a service is

#service <name of the service> Status                     ---        To check the status of the service
#service <name of the service> start                        ---        To start the service
#service <name of the service> stop             ---        To stop a service
#service <name of the service> reload                     ---        To reload the service
#service <name of the service> restart                    ---        To restart the service
#service - - status-all                                      ---        To see all the service status

To command use for service availability is

#chkconfig – list                                             ---        To check the availability of service
#chkconfig <service> on                               ---        To make the service available after restart
#chkconfig <service> off                              ---        To make the service unavailable after restart

Now we will see how to use the above commands:

Check the status of ftp service “vsftpd”
To check the status of the above service

#service vsftpd status


[root@linuxelearn Desktop]# service vsftpd status
vsftpd is stopped
[root@linuxelearn Desktop]#


Start Ftp services
To start the ftp service, the command is
#service vsftpd start


[root@linuxelearn Desktop]# service vsftpd start
Starting vsftpd for vsftpd:                                [  OK  ]
[root@linuxelearn Desktop]# service vsftpd status
vsftpd (pid 3261) is running...
[root@linuxelearn Desktop]#


Reload the ftp services, may be required after doing some change in config file.
To reload the service, the command is
#service vsftpd reload


[root@linuxelearn Desktop]# service vsftpd reload
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]
[root@linuxelearn Desktop]#


To restart the ftp or any service, required when reload does not work
To restart the ftp services, the command will be

#service vsftpd restart


[root@linuxelearn Desktop]# service vsftpd restart
Shutting down vsftpd:                                      [  OK  ]
Starting vsftpd for vsftpd:                                [  OK  ]
[root@linuxelearn Desktop]#


Check the status of the all service availability using chkconfig command.
To check the status of all service availability, use

#chkconfig –list


[root@linuxelearn Desktop]# chkconfig --list
NetworkManager        0:off    1:off    2:on     3:on     4:on     5:on     6:off
abrtd                0:off    1:off    2:off    3:on     4:off    5:on     6:off
acpid               0:off    1:off    2:on     3:on     4:on     5:on     6:off
atd                   0:off    1:off    2:off    3:on     4:on     5:on     6:off
auditd              0:off    1:off    2:on     3:on     4:on     5:on     6:off
autofs              0:off    1:off    2:off    3:on     4:on     5:on     6:off
avahi-daemon              0:off    1:off    2:off    3:on     4:on     5:on     6:off
bluetooth         0:off    1:off    2:off    3:on     4:on     5:on     6:off
certmonger     0:off    1:off    2:off    3:off    4:off    5:off    6:off
cgconfig          0:off    1:off    2:off    3:off    4:off    5:off    6:off
cgred               0:off    1:off    2:off    3:off    4:off    5:off    6:off
cpuspeed         0:off    1:on     2:on     3:on     4:on     5:on     6:off
crond               0:off    1:off    2:on     3:on     4:on     5:on     6:off
cups                 0:off    1:off    2:on     3:on     4:on     5:on     6:off
dnsmasq          0:off    1:off    2:off    3:off    4:off    5:off    6:off
firstboot          0:off    1:off    2:off    3:off    4:off    5:off    6:off
haldaemon      0:off    1:off    2:off    3:on     4:on     5:on     6:off
httpd               0:off    1:off    2:off    3:off    4:off    5:off    6:off
ip6tables          0:off    1:off    2:on     3:on     4:on     5:on     6:off
iptables            0:off    1:off    2:on     3:on     4:on     5:on     6:off
irqbalance        0:off    1:off    2:off    3:on     4:on     5:on     6:off
kdump             0:off    1:off    2:off    3:off    4:off    5:off    6:off
lvm2-monitor              0:off    1:on     2:on     3:on     4:on     5:on     6:off
mdmonitor                  0:off    1:off    2:on     3:on     4:on     5:on     6:off
messagebus                 0:off    1:off    2:on     3:on     4:on     5:on     6:off
microcode_ctl             0:off    1:off    2:on     3:on     4:on     5:on     6:off
nagios              0:off    1:off    2:on     3:on     4:on     5:on     6:off
netconsole       0:off    1:off    2:off    3:off    4:off    5:off    6:off
netfs                0:off    1:off    2:off    3:on     4:on     5:on     6:off
network           0:off    1:off    2:on     3:on     4:on     5:on     6:off
nfs                   0:off    1:off    2:off    3:off    4:off    5:off    6:off
nfslock            0:off    1:off    2:off    3:on     4:on     5:on     6:off
nscd                 0:off    1:off    2:off    3:off    4:off    5:off    6:off
nslcd                0:off    1:off    2:off    3:off    4:off    5:off    6:off
ntpd                 0:off    1:off    2:off    3:off    4:off    5:off    6:off
ntpdate            0:off    1:off    2:off    3:off    4:off    5:off    6:off
oddjobd          0:off    1:off    2:off    3:off    4:off    5:off    6:off
portreserve      0:off    1:off    2:on     3:on     4:on     5:on     6:off
postfix             0:off    1:off    2:on     3:on     4:on     5:on     6:off
psacct              0:off    1:off    2:off    3:off    4:off    5:off    6:off
rdisc                0:off    1:off    2:off    3:off    4:off    5:off    6:off
restorecond    0:off    1:off    2:off    3:off    4:off    5:off    6:off
rhnsd               0:off    1:off    2:on     3:on     4:on     5:on     6:off
rpcbind            0:off    1:off    2:on     3:on     4:on     5:on     6:off
rpcgssd            0:off    1:off    2:off    3:on     4:on     5:on     6:off
rpcidmapd      0:off    1:off    2:off    3:on     4:on     5:on     6:off
rpcsvcgssd       0:off    1:off    2:off    3:off    4:off    5:off    6:off
rsyslog             0:off    1:off    2:on     3:on     4:on     5:on     6:off
saslauthd         0:off    1:off    2:off    3:off    4:off    5:off    6:off
smartd             0:off    1:off    2:off    3:off    4:off    5:off    6:off
snmpd             0:off    1:off    2:off    3:off    4:off    5:off    6:off
snmptrapd      0:off    1:off    2:off    3:off    4:off    5:off    6:off
sshd                 0:off    1:off    2:on     3:on     4:on     5:on     6:off
sssd                 0:off    1:off    2:off    3:off    4:off    5:off    6:off
sysstat             0:off    1:on     2:on     3:on     4:on     5:on     6:off
udev-post        0:off    1:on     2:on     3:on     4:on     5:on     6:off
vsftpd              0:off    1:off    2:off    3:off    4:off    5:off    6:off
wpa_supplicant           0:off    1:off    2:off    3:off    4:off    5:off    6:off
ypbind             0:off    1:off    2:off    3:off    4:off    5:off    6:off
[root@linuxelearn Desktop]#


Note: where 0 1 2 3 4 5 6 are the run levels in Linux, The output shows that on which run level the service is available even after reboot.

Check the status of a particular service, say “vsftpd”
To check the status of a vsftpd service, the command is

#chkconfig –list <name of the service>
#chkconfig –list vsftpd


[root@linuxelearn Desktop]# chkconfig --list vsftpd
vsftpd              0:off    1:off    2:off    3:off    4:off    5:off    6:off
[root@linuxelearn Desktop]#


Make the service availability on for vsftpd.
To make the service availability on for vsftpd service,

#chkconfig vsftpd on


[root@linuxelearn Desktop]# chkconfig vsftpd on
[root@linuxelearn Desktop]# chkconfig --list vsftpd
vsftpd              0:off    1:off    2:on     3:on     4:on     5:on     6:off
[root@linuxelearn Desktop]#


Make the service availability off for vsftpd
To make the service availability off the command is

#chkconfig vsftpd off


[root@linuxelearn Desktop]# chkconfig vsftpd off
[root@linuxelearn Desktop]# chkconfig --list vsftpd
vsftpd              0:off    1:off    2:off    3:off    4:off    5:off    6:off
[root@linuxelearn Desktop]#


Make the service vsftpd availability on only runlevel 5
To make the service availability on, on a particular runlevel, the syntax is

#chkconfig –level <1-6> <service> <on/off>
#chkconfig – level 5 vsftpd on


[root@linuxelearn Desktop]# chkconfig --level 5 vsftpd on
[root@linuxelearn Desktop]# chkconfig --list vsftpd
vsftpd              0:off    1:off    2:off    3:off    4:off    5:on     6:off
[root@linuxelearn Desktop]#


The same can be done for making service unavailable in a particular run level.

I hope you enjoyed reading this article….