17/180: Linux Boot Process, Disk Partition and much more
Today is day 17 of 180 days streak and proudly continuing the challenge, though sometimes I become late to post but I make sure I post regularly. This challenge is taken by me to improve my habit and making learning beside the office job as daily ritual.
System Run Levels (init ?)
There are 6 kinds of run level
- 0 : shut down or halt the system
- 1: single user mode usually aliased as s or S
- 6: reboot the system
Other run levels:
- 2: Multiuser mode without networking
- 3: Multiuser mode with networking
- 5: Multiuser mode with networking and GUI
init 0 -> will shut down and 1 will bring it back.
Linux Boot Process
- Bios : Basic input output system. Executes MBR
- MBR: Master Boot Record executes GRUB
- GRUB: Grand Unified Boot Loader, executes Kernel
- Kernel: executes /sbin/init
- init: executes run level program
- Run Level: Run level programs are executed from /etc/rc.d/rc*.d/
The boot process sequence changes in Cent OS/Redhat 7 and above. systemd is the new service manager in CentOS/RHEL7 that manages the boot sequence. It is backward compatible with SysV init Scripts used by previous versions of RedHat Linux including RHEL 6
Every system administrator needs to understand the boot process of an OS in order to trouble shoot. BIOS -> POST (Power on Test Start) -> MBR (indicates where grub 2 is located) -> GRUB(job is to load linux kernel)-> Kernel (core of Operating System). Load required drivers from initrd.img. Start the first OS process (systemd). systemd = System Daemon
Message of the Day
After login everytime some message user will see. It is present under /etc/motd file. If you will open the file you can see the message there. You can also customize the message.
Customize message -> create file in /etc/profile.d/motd.sh, Add desired message and commands in it. Modify /etc/ssh/sshd_config, uncomment /Printmotd and make Yes as No. systemctl restart sshd service
And now when you login again, you can see the message you have added is displayed on the screen.
Storage
- Local Storage -> inside computer
- SAN -> Storage Area Network (attaches to your computer through fibre cable)
- NAS -> Network Attached Storage
Disk Partition (df, fdisk)
df -> disk info, fdisk-> disk total size. How many partitions created.
Add disk and create standard partition. Purpose -> out of space or additional apps. You can use these 2 commands for this.
Logical Volume Manager (LVM)
It allows disks to be combined together. Configure LVM during installation always. Add disk and create LVM partition
Physical Volumes Volume Groups Logical Volumes Mounted on
Disk 1 rootvg system "/"
home "/home"
swap
Disk 2 datavg data 1 "/data1"
data 2 "/data2"
data 3 "/data3"
data 4 "/data4"
Adding or Extending Swap space
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 the memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM, Swap is located on harddrives, which have a slower access time than physical memory. Recommended swap size is equal to twice the size of RAM. Commands for this are:
- dd
- mkswap
- swapon (mkswap only works when we use this command to add swap space) or swapoff (delete swap space)
RAID
Raid stands for redundant array of Independent disks. Type of RAID:
- RAID0
|++++|
| 5 | + |++++| = 10 G
|____| | 5 |
|____|
2. RAID1
|++++|
| 5 | = |++++| = 5G
|____| | 5 |
|____|
3. RAID5
|++++|
| 5 | += |++++| = 8G
|____| | 5 |
|____|
File System Check (fsck & xfs_repair)
Depending on when was the last time a filesystem was checked, the system runs the fsck during boot time to check whether the filesystem is in consistent state. System administrator could also run it manually when there is a problem with the filesystem. Make sure to execute the fsck on an unmounted filesystem to avoid any data corruption issue.
System Backup (dd command)
5 types of backup:
- System Backup (entire image)
- Application Backup (3rd party application backup solution)
- Database Backup (Oracle dataguard, SQL backup etc)
- Filesystem backup (tar, gzip directories etc)
- Disk backup or disk clonning (dd command)
dd if = <source file name> of = <target file name> [options]
Network File System
It is a client / server system that allows users to access files across a network and treat them as if they reside in a local file directory. For example if you are using a computer linked to second computer via NFS you could access the files on second computer as if they resided in the directory of first computer. This is accomplished through the process of exporting (the process by which an NFS server provides remote clients with access to its files) and mounting (this process by which client map NFS shared filesystem).