1. What is partition?
A
partition is a contiguous set of blocks on a drive that are treated as
independent disk.
2. What is partitioning?
Partitioning
means to divide a single hard drive into many logical drives.
3. Why we have multiple partitions?
Ø Encapsulate our data.
Ø Since file system corruption is limited to that partition only.
Ø So we can save our data from accidents.
Ø We can increase the disk space efficiency
Ø . Depending on our usage we can format the partition with different
block sizes.
Ø So we can reduce the wastage of the disk.
Ø We can limit the data growth by assigning the disk quotas.
4. What is the structure of the disk partition?
The first
sector of the O/S disk contains the MBR (Master Boot Record). The MBR is
divided into 3 parts and it's size is 512 bytes. The first part is IPL (Initial
Program Loader) and it contains the Secondary Boot Loader. So, IPL is responsible for booting the O/S and it's
size is 446 bytes The second part is PTI (Partition Table
Information). It contains the number of
partitions on the disk, sizes of the partitions and type of the partitions
.
5 Explain the disk partition
criteria?
Every disk can have max. 4 partitions. The
4 partitions are 3 Primary partitions and 1 Extended partition.
The MBR and O/S will install in Primary
partition only. The Extended partition is a special partition and can be
further divided into multiple logical partitions.
6. How to identify the disks?
Ø In Linux different types of disks will be identified by different naming
conventions.
Ø IDE) drives will be shown as /dev/hda, /dev/hdb, /dev/hdc, ...etc., and the partitions are /dev/hda1, /dev/hda2, /dev/hda3, ...etc.
Ø iSCSI/SCSI and SATA drives will
be shown as /dev/sda, /dev/sdb, /dev/sdc, ...etc., and the partitions are /dev/sda1, /dev/sda2,
/dev/sda3, ...etc.,
Ø Virtual drives will be shown as /dev/vda, /dev/vdb, /dev/vdc,
...etc., and the partitions are
/dev/vda1, /dev/vda2, /dev/vda3, ...etc.,
·
IDE ----->
Integrated Drive Electronics.
·
iSCSI ----->
Internet Small Scale System
Interface.
·
SCSI ----->
Small Scale System Interface.
7.What is file system?
It is a method of storing the data in an organized fashion on the disk.
Every partition on the disk except MBR and Extended
partition should be assigned with some file system in order to make them to
store the data. File system is applied on the partition by formatting it with a
particular type of file system.
8. What are the different types of file systems supported in Linux?
Ø The Linux supported file systems are ext2, ext3, ext4, xfs, vfat, cdfs,
hdfs, iso9660 ...etc.,
Ø The ext2, ext3, ext4 file systems are widely used in RHEL-6 and xfs file
system is introduced on RHEL-7.
Ø The vfat file system is used to maintain a common storage between Linux
and Windows O/S.
Ø The cdfs file system is used to mount the CD-ROMs and the hdfs file
system is used to mount DVDs.
Ø The iso9660 file system is used to read CD/DVD.iso image format files in
Linux O/S.
9. How to create different types of partitions?
# fdisk -l
#
fdisk /dev/sdc
Command
(m for help) : n (type n
for new partition)
(p
- primary) or e - extended) : p
(type p for primary partition or type e for extended partition)
First
cylinder : (press Enter for default
first cylinder)
Last cylinder : +
Command
(m for help) : t (type t to
change the partition id)
(for example: 8e for Linux LVM, 82
for Linux Swap and 83
for Linux normal partition)
Command
(m for help) : w (type w
tosave the changes into the disk)
#
partprobe /partx -a/kpartx /dev/sdc1 (to update the partitioning information
in partition table)
10. How to make a file
system in Linux?
# mkfs.ext2/ext3/ext4/xfs/vfat ( for example/dev/sdc1)
11. How to mount the file
systems temporarily or permanently?
#
mkdir /mnt/oracle
#
mount /dev/sdc1 /mnt/oracle (temporary mount)
# vim /etc/fstab
/dev/sdc1 /mnt/oracle
xfs defaults 0 0
Esc+:+wq!
#
mount -a (permanent mount)
12. How to delete the
partition?
# fdisk /dev/sdc
Command (m for help) :d (type d
for delete the partition)
Partition number : (specify the partition number)
Command (m for help) : w (type
w to write the changes into disk)
#
partprobe/partx -a/kpartx /dev/sdc1(to update the partition table
without restarting the system)
13. What is mounting and
in how many types can we mount the partitions?
Attaching a parititon to a directory under root is known as mounting.
There
two types of mountings in Linux/Unix.
v Temporary Mounting :
In a temporary mounting first we create a
directory and mount the partition on that directory. But this type mounting
will last only till the system is up and once it is rebooted the mounting will
be lost.
Example:# mount
v Permanent Mounting :
In this also first we create the directory
and open the /etc/fstab file and make an entry as below,
Whenever the system reboots mount the partitions according to
entries in /etc/fstab file. So, these type of mountings are permanently even
after the system is rebooted.
# mount
-a to mount the
partitions without reboot)
14. What are differences
between the ext2, ext3, ext4 and xfs file systems?
S.No.
|
Ext2
|
Ext3
|
Ext4
|
1.
|
Stands for Second Extended file system.
|
Stands for Third Extended file system.
|
Stands for Fourth Extended file system.
|
2.
|
Does not having Journaling feature.
|
Supports Journaling feature.
|
Supports Journaling feature.
|
3.
|
Max. file size can be from 16 GB to 2 TB.
|
Max. file size can be from 16 GB to 2 TB.
|
Max. file size can be from 16 GB to 16
TB.
|
4.
|
Max. file system size can be from 2 TB to
32 TB
|
Max. file system size can be from 2 TB to
32 TB
|
Max. file system size can be from 2 TB to
1 EB
*1EB = 1024 Peta bytes.
|
15. Which files are
related to mounting in Linux?
Ø /etc/mtab ----> is a file which stores the information of all
the currently mounted file systems and this file is dynamic
and keep on changing.
Ø /etc/fstab ----> is keeping information about the permanent
mount points. If we want to make our mount point permanent then make an entry about the mount
point in this file.
/etc/fstab entries are:
1 2 3 4 5
6
device
name mount point F/S type mount
options Dump FSCK
16. The partitions are not
mounting even though there are entries in /etc/fstab. How to solve this
problem?
First check any wrong entries are there in /etc/fstab file. If all are ok
then unmount all the partitions by
executing
the below command,
ü # umount -a
Then
mount again mount all the partitions by executing the below command,
ü # mount -a
17. When trying to
unmounting it is not unmounting, how to troubleshoot this one?
Some times directory reflects error while unmounting because,
(i)
you are in the same directory and trying to unmount it, check with # pwdcommand.
(ii)
some users are present or accessing the same directory and using the contents
in it, check this with
ü # fuser -cu (to check the users who
are accessing that partition)
ü # lsof (to check the files which are open in that
mount point)
ü # fuser -ck (to kill that opened files)
Now
we can unmount that partition using #
umount
18. How to see the usage
information of mounted partitions?
# df -hT (to see device name, file system type,
size, used, available size, use% and mount point)
19. How to see the size of
the file or directory?
ü # du -h
(to see the size of the in that directory)
ü # du -h (to see all the file sizes which are
located in the present working directory)
ü # du .| sort -nr | head
-n10 (to see the biggest
files from current location)
ü # du -s * | sort -nr | head
-n10 (to see the biggest directories
from that partition)
ü # ncdu (to list biggest files
and directories, we have to install the ncdu
package before executing this)
ü
20. How to assign a label
to the partition?
# e2label
Example
: # e2label /dev/sdb1
oradisk (to assign oradisk
label to /dev/sdb1 partition)
#
mount -l (to list all the mounted partitions
along with their labels)
21. How to mount a
partition temporarily or permanently using label?
#
mount LABEL=
ex : # mount
LABEL=oradisk /mnt/oracle (to mount the oradisk label on /mnt/oracle directory)
#
vim /etc/fstab
LABEL=oradisk /mnt/oracle ext4 defaults 0 0
Esc+:+wq! (to save and exit the file)
#
mount -a (to mount the partitions)
#
mount (to verify whether it is mounted or
not)
22. How mount the
partition permanently using block id (UUID)?
# blkid (to see the UUID or
block id of that partition)
Example
: #blkid /dev/sdb2 (to see the UUID or block id of the
/dev/sdb2 partition)
Copy
that UUID with mouse and paste it in /etc/fstab file and make an entry about
that.
Example: # vim /etc/fstab
UUID="{.......................}" /mnt/oracle ext4 defaults 0 0
Esc+:+wq! (to save and exit)
23. What is the basic rule
for swap size?
(i) If the size of the RAM is less than or equal to 2GB, then the size
of the swap = 2 X RAM size.
(ii)
If the size of the RAM is more than 2GB, then the size of the swap = 2GB + RAM
size.
24. How to create a swap
partition and mount it permanently?
# free -m (to see the present swap size)
#
swapon -s (to see the swap usage)
#
fdisk (to make a partition)
Example: # fdisk
/dev/sdb
Command
(m for help) : n (to create a new partition)
First
cylinder : (press Enter to take as
default value)
Last
cylinder : +2048M (to create 2GB partition)
Command
(m for help) : t (to change the partition id)
Enter
the partition No.: 2 (to change the /dev/sdb2 partition id)
Enter
the id : 82 (to change the partition id Linux to Linux
Swap)
Command
(m for help) : w (to save the changes into the disk)
#
partprobe /dev/sdb (to update the partition table
information)
#
mkswap (to format the partition with swap file system)
Example
: # mkswap /dev/sdb2 (to format the /dev/sdb2 partition with
swap file system)
#
swapon (to activate the swap space)
Example
: # swapon /dev/sdb2 (to activate /dev/sdb2 swap space)
#
free -m (to see the swap size)
#
vim /etc/fstab (to make an entry to permanent mount the
swap partition)
/dev/sdb2 swap swap defaults 0 0
Esc+:+wq! (to save and exit)
25. What are the
attributes of the file system?
(i) Inode number
(ii)
File name
(iii) data block
26. What is inode number
and what is the use of it?
Inode numbers are the objects the Linux O/S uses to record the
information about the file.
Generally
inode number contains two parts.
(a)
Inode first part contains information about the file, owner, its size and its permissions.
(b)
Inode second part contains pointer to data blocks associated with the file
content.
That's
why using the inode number we can get the file information quickly.
27. How to check the
integrity of a file system or consistency of the file system?
# fsck
command we
can check the integrity of the file system.
But
before running the fsck command
first unmount that partition and then run fsck command.
28. What is fsck check or
what are the phases of the fsck?
(a) First it checks blocks and sizes of the file system
(b)
Second it checks file system path names
(c)
Third it checks file system connectivity
(d)
Fourth it checks file system reference counts (nothing but inode numbers)
(e)
Finally it checks file system occupied cylindrical groups
29. Why the file system
should be unmount before running the fsck command?
If we run fsck on mounted file systems, it leaves
the file systems in unusable state and also deletes the data. So, before running the fsck command the file system should be unmounted.
30. Which type of file
system problems you face?
(i) File system full
(ii) File system corrupted
31. How to extend the root
file system which is not on LVM?
By using # gparted command we can extend the root
partition, otherwise we cannot extend the file systems which is not on LVM.
32. How to unmount a file
system forcefully?
# umount -f
#
fuser -ck
33. How to know the file
system type?
# df -hT (command gives the file system type
information)
34. How to know which file
system occupy more space and top 10 file systems?
# df -h | sort
-r | head
-10
35. What is the command to
know the mounted file systems?
# mount or # cat
/etc/mtab
36. How to know whether
the file system is corrupted or not?
First unmount the file systems and then run fsck command on that file system.
37. How to recover if a
file system is corrupted or crashed?
If the normal
or not related to O/S file system is corrupted first unmount that file system
and run fsck command on that file
system and if the O/S related file system is corrupted then boot the system
with CDROM in single user mode and
run the fsck command.
If the normal
or not related to O/S file system is crashed then restore it from the recent backup
and if the O/S related file system is
crashed then boot the system with CDROM in single user mode and restore it from
the recent backup.
38. How to create a file
with particular size?
# dd if=/dev/zero of=/orafile bs=1MB
count=500 (to create 500MB size
/orafile with 4KB blocksize)
39. How to find how many
disk are attached to the system?
# fdisk -l (to see how many disk are attached to the
system)
40. What is journaling?
It is a dedicated area in the file system where all the changes are
tracked when the system crashed. So the possibility
of the file system corruption or crashes is less because of this journaling feature.
41. How to repair the
Superblock of the file system?
Whenever we
want to store the data into the hard disk, if the input/output error occurs
then the Superblock of the
file system may be erased or corrupted. So, we have to restore or repair that
Superblock.
#
umount (to unmount the file system)
#
dumpe2fs
#
e2fsck -b
(to
restore the damaged superblock)
#
mount -a (to mount the file system)
42. How to create the file
systems with the user specified superblock reserve space?
# mkfs.ext4 -m (to format the partition with
% of reserve space to superblock)
Whenever we format the file system, by
default it reserve the 5% partition space for Superblock.
|
43. How to modify the
superblock reserve space?
# tune2fs -m (to modify the superblock reserve space to %)
Important Commands :
ü # fsck (to
check the consistency of the file system)
ü # e2fsck (to check the consistency of
the file system in interactive mode)
ü # e2fsck -p (to check the consistency of the file
system without interact mode)
ü # mke2fs -n (to see the superblock information)
ü # mke2fs -t (to format the partition in the specified filesys type)
ü # mke2fs (to format the partition in default
ext2 file system type)
ü # blockdev --getbs /dev/sdb1 (to
check the block size of the /dev/sdb1 file system)
ü # fsck (to
check and repair the file system)
Note: Before running this command first
unmount that partition then run fsck command.
# umount
-a (to
unmount all the file systems except ( / ) root file system)
# mount
-a (to
mount all the file systems which are having entries in /etc/fstab file)
# fsck
-A (to
run fsck on all file systems)
# fsck
-AR -y (to run fsck without asking any questions)
# fsck
-AR -t ext3
-y (to run
fsck on all ext3 file systems)
# fsck -AR
-t no ext3 -y (to
run fsck on all file systems except ext3 file systems)
# fsck
-n /dev/sdb1 (to see the /dev/sdb1
file system report without running fsck)
# tune2fs
-l /dev/sdb1 (to check whether the
journaling is there or not)
# tune2fs
-j /dev/sdb1 (to convert ext2 file
system to ext3 file system)
# tune2fs
-l /dev/sdb1 (to check whether the
journaling is added or not)
# tune2fs
-O ^has_journal /dev/sdb1 (to
convert ext3 file system to ext2 file system)
# tune2fs
-O dir_index, has_journal,
unit_bg /dev/sdb1 (to convert ext2 file system to ext4
file system)
# tune2fs
-O extents, dir_index,
unit_bg /dev/sdb1 (to convert ext3 file system to ext4 file
system)
# mount
-o remount, rw /dev/sdb1 (to
mount the partition with read and write permissions)
# mount
-o remount, ro /dev/sdb1 (to
mount the partition with read only permissions)
# mount
< directory name> (to check whether this directory is mount/
normal directory)
# dump2fs
(to
check the metadata of the partition and repair the metadata)
# fdisk
-l (to
list total hard disks attached to system and their partitions)
# fuser
-cu (to see the users who are accessing that file system)
# fuser
-cK (to kill the users processes who accessing the file systems)
Note: Even though we kill those users processes sometimes
we cannot unmount those partitions, so if this
situation arises then first see the process
id's of the user opened files by
# lsof
# kill -9 killthose processesforcefully
# journalctl (It tracks all the log files between two different
timings and by default saved in /run/log )
* /run/log is mounted on tmpfs file system. ie., if system is rebooted, the
whole information in that location will
be deleted or erased.
* We
can change the location of the /run/log to another like /var/log/journal by
# mkdir
-p /var/log/journal (to make a directory
in /var/log location)
# chown
root : systemd-journal
/var/log/journal (to change
the group ownership of
/var/log/journal)
# chmod
g+s /var/log/journal (to set the
sgid on /var/log/journal)
# killall
-URS1 systemd-journald (It is necessary to kill old /run/log
process and the location of
journal messages is changed to
/var/log/journal)
# journalctl -n
5 (to
display last five lines of all the log files)
# journalctl -p
err (to
display all the error messages)
# journalctl -f (to
watch journalctl messages continuously)
# journalctl --since or
(to see all
the journalctl messages since today or yesterday)
# journalctl --since
"date" --until "date" (to see the journal messages between the
specified two dates)
# journalctl -pid=1 (to
see the pid=1 process name)
# auditctl (to
see the audit report).
No comments:
Post a Comment