Click Here for : PART 1: LINUX Interview Questions
Click Here for : PART 2: LINUX Interview Questions
PART 3: LINUX Interview Questions
In part 3 we are going to see the below questions and answers.
13. What is swap ? Why we need swap partition?
14. How to Create / extend / remove swap partition?
15. Why does kernel need IO scheduler?
16. How to view Current Disk i/o scheduler ? How to change I/o Scheduler for hard disk?
17: How to restore the default system permission on Linux ?
13. What is swap ? Why we need swap partition?
Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full,
inactive pages in memory are moved to the swap space.
Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files.
Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB.
14. How to Create / extend / remove swap partition?
A.Create a SWAP Partition:
1. Create a file system on disk
#fdisk /dev/cciss/c?d?
Note : Make the new partition as swap. Change toggle id to 82 (for swap).
2. Make the FS as Swap partition
#mkswap /dev/cciss/c?d?p?
3. Run swapon commad to enable swap space
#swapon /dev/cciss/c?d?p?
4.Verify the new swap partition
#cat /proc/swap
or
#swapon -s
5. Add this new swap partion entry to /etc/fstab
vi /etc/fstab
/dev/cciss/c?d?p? swap swap defaults 0 0
B.How to increase / extend SWAP partition ?
Follow the below steps to increase the Swap for LVM
# swapoff -v /dev/rootvg/swapvol
# lvm lvresize /dev/rootvg/swapvol -L +8G or lvextend -L +8G /dev/rootvg/swapvol
# mkswap /dev/rootvg/swapvol
# swapon -va
C.How to remove the swap partition ?
1.swapoff -v /dev/VolGroup00/swap_vol
2.lvremove /dev/VolGroup00/swap_vol
3. Remove the entry from /etc/fstab
15. Why does kernel need IO scheduler?
Without an I/O scheduler, the kernel would basically just issue each request to disk in the order that it received them. This could result in massive HardDisk
thrashing: if one process was reading from one part of the disk, and one writing to another, the heads would have to seek back and forth across the disk for
every operation. The scheduler’s main goal is to optimise disk access times.
16. How to view Current Disk i/o scheduler ? How to change I/o Scheduler for hard disk?
Assuming that we have a disk name /dev/sda, type :
# cat /sys/block/{DEVICE-NAME}/queue/scheduler
# cat /sys/block/sda/queue/scheduler
How to set I/O Scheduler For A Hard Disk ?
To set a specific scheduler, simply type the command as follows:
# echo {SCHEDULER-NAME} > /sys/block/{DEVICE-NAME}/queue/scheduler
For example, set noop scheduler, enter:
# echo noop > /sys/block/hda/queue/scheduler
OR
Edit /boot/grub/grub.conf and enter in kernel line "elevator=noop" or any other scheduler available.
There are currently 4 available IO schedulers :
* No-op Scheduler
* Anticipatory IO Scheduler (AS)
* Deadline Scheduler
* Complete Fair Queueing Scheduler (CFQ)
Changing Scheduler:
The most reliable way to change schedulers is to set the kernel option “elevator” at boot time. You can set it to one of “as”, “cfq”, “deadline” or “noop”, to set the appropriate scheduler.
elevator=cfq
17. How to restore the default system permission on Linux ?
We can recover or restore the defualt file / folder permission and ownership using rpm command with the options -setperms and --setugids.
This is very usefull option which i found in RPM command.
1) To reset uids and gids on files and directories :
# for i in $(rpm -qa); do rpm --setugids $i; done
2) To permissions on files and directories
#for i in $(rpm -qa); do rpm --setperms $i; done
1 Comments
This comment has been removed by the author.
ReplyDelete