More on file systems, Booting Todd Kelley CST8177 Todd Kelley 1

Similar documents
More on file systems, Booting Todd Kelley CST8177 Todd Kelley 1

Quota LVM (Logical Volume Manager)

Disks, Filesystems, Booting Todd Kelley CST8177 Todd Kelley 1

Chapter 5: User Management. Chapter 5 User Management

Disks, Filesystems Todd Kelley CST8177 Todd Kelley 1

Linux File System Quotas

System Administration. Startup Process

Booting up and Shutting down A primer for troubleshooting

Linux-Kurs Themen -Quotas -19 January 2005

Disks, Filesystems 1

Actual4Test. Actual4test - actual test exam dumps-pass for IT exams

Certification. System Initialization and Services

Exam Linux-Praxis - 1 ( From )

RH133. Red Hat Linux System Administration

The Linux IPL Procedure

TestOut Linux Pro - English 4.0.x OBJECTIVE MAPPING: CompTIA Linux+ LX0-103

Services, logging, accounting Todd Kelley CST8177 Todd Kelley 1

File systems and Filesystem quota

CSE 265: System and Network Administration

CSE 265: System and Network Administration

LPIC-1 System Administrator

Exam Name: Red Hat Certified Engineer on Redhat

RH202. Redhat Certified Technician on Redhat Enterprise Linux 4 (Labs) Exam.

Welcome to getting started with Ubuntu Server. This System Administrator Manual. guide to be simple to follow, with step by step instructions

Chapter 6. Boot time configuration. Chapter 6 Boot time configuration

Accurate study guides, High passing rate! IT TEST BOOK QUESTION & ANSWER. Ittestbook provides update free of charge in one year!

RHCE BOOT CAMP. The Boot Process. Wednesday, November 28, 12

Course 55187B Linux System Administration

Exam Questions RH133

Authored by: Brian E. Brzezicki Copyright 2013, Paladin Group LLC Reuse without permission is strictly prohibited

CST8177 Linux II. Linux Boot Process

Shell Scripting. Todd Kelley CST8207 Todd Kelley 1

"Charting the Course... MOC B: Linux System Administration. Course Summary

Please choose the best answer. More than one answer might be true, but choose the one that is best.

5/8/2012. Creating and Changing Directories Chapter 7

CompTIA Linux+/LPIC-1 COPYRIGHTED MATERIAL

Exam LFCS/Course 55187B Linux System Administration

NETW 110 Lab 5 Creating and Assigning Users and Groups Page 1

Linux Kung Fu. Stephen James UBNetDef, Spring 2017

At course completion. Overview. Audience profile. Course Outline. : 55187B: Linux System Administration. Course Outline :: 55187B::

LPIC 102. be familiar with standard runlevels in a Linux system

LiLo Crash Recovery. 1.0 Preparation Tips. 2.0 Quick Steps to recovery

Introduction. What is Linux? What is the difference between a client and a server?

The Linux Boot Process

This is Worksheet and Assignment 12. Disks, Partitions, and File Systems

RocketRAID 2680/2684 SAS Controller Red Hat Enterprise/CentOS Linux Installation Guide

Linux+ Guide to Linux Certification, Third Edition. Chapter 2 Linux Installation and Usage

Unix System Architecture, File System, and Shell Commands

exam.30q. Number: Passing Score: 800 Time Limit: 120 min File Version: 1 LPI

Comptia LX0-101 Exam Questions & Answers

NASA Lab. Partition/Filesystem/Bootloader. TinRay, Yu-Chuan

Commands are in black

HOW LINUX BOOTS. As it turns out, there isn t much to the boot process:

Exam Questions RH202

More Scripting and Regular Expressions. Todd Kelley CST8207 Todd Kelley 1

RocketRAID 231x/230x SATA Controller Red Hat Enterprise/CentOS Linux Installation Guide

Initialization: runlevels

Actual4Test. Actual4test - actual test exam dumps-pass for IT exams

Lab E2: bypassing authentication and resetting passwords

. Fill in the Blank: A directory named mydir has just been... Points:10. Add Question Success: 64 questions added as a copy.

Chapter 6. Linux File System

OPS235. Linux File Systems Partitioning Mounting File Systems

Fedora Linux Installation Guide

RocketRAID 231x/230x SATA Controller Fedora Linux Installation Guide

CST8207: GNU/Linux Operating Systems I Lab Nine Disks, Partitions, and File Systems Part 2. Disks, Partitions, and File Systems - Part 2 of 2

Fedora Linux Installation Guide

RHCSA BOOT CAMP. Filesystem Administration

Embedded System Design

The Ultimate Linux/Windows System

Linux/Citrix Virtual Environment Documentation

Week 10 Project 3: An Introduction to File Systems. Classes COP4610 / CGS5765 Florida State University

minit Felix von Leitner September 2004 minit

Vendor: RedHat. Exam Code: RH133. Exam Name: Red Hat Linux System Administration. Version: Demo

OPERATING SYSTEMS LINUX

PL-I Assignment Broup B-Ass 5 BIOS & UEFI

How To Startup Windows Service Windows 7. Repair Dual Boot >>>CLICK HERE<<<

Linux Systems Administration Getting Started with Linux

Booting Up and Shutting Down. lctseng / Liang-Chi Tseng

SUSE Advanced Troubleshooting: The Boot Process Lecture

client X11 Linux workstation

How To Reinstall Grub In Windows 7 Without Losing Data And Programs

Ubuntu Manual Fsck Must Performed Debian

Physics REU Unix Tutorial

How To Reinstall Grub In Windows 7 With Cd Rom

Installation of the OS

Project 3: An Introduction to File Systems. COP4610 Florida State University

Lab 3a Using the vi editor

Oracle 1Z Enterprise Linux System Administration. Download Full Version :

Linux Files and the File System

University of Pennsylvania Zachary Goldberg. CIS c. More Kernel Bits. 10/03/09 Slide 1

CompTIA Linux+ Guide to Linux Certification Fourth Edition. Chapter 2 Linux Installation and Usage

Chapter 2 Booting Up and Shutting Down

Chapter Two. Lesson A. Objectives. Exploring the UNIX File System and File Security. Understanding Files and Directories

Basic Shell Commands. Bok, Jong Soon

Manually Mount Usb Flash Drive Linux Command Line Redhat

Testpassport.

How to Restrict a Login Shell Using Linux Namespaces

CST8207: GNU/Linux Operating Systems I Lab Ten Boot Process and GRUB. Boot Process and GRUB

Please note that CNE 216 is a brand new course that has never been taught on the George campus; it will be taught for the first time in the fall of

This is Lab Worksheet 3 - not an Assignment

Transcription:

More on file systems, Booting Todd Kelley kelleyt@algonquincollege.com CST8177 Todd Kelley 1

bind mounts quotas Booting process and SysVinit Installation Disk rescue mode 2

A bind mount is used to mount a directory onto a mount point: man mount use the bind option for the mount command # mount o bind /some/dir /anotherdir now /some/dir and /anotherdir are the same directory Be careful with bind mounts, because they make it possible to form cycles in the file system e.g. dangerous: "mount o bind /home /home/user/dir" serious repercussions for rm rf /home/user # will remove all of /home find /home/user # will never stop any program that recursively descends directories CST8177 Todd Kelley 3

make an inaccessible directory accessible: mount o bind /home/user/private/public /public make disk space in one file system available in another file system suppose you have a large separate file system with lots of free space on /var, and root file system with /home is nearly full: mkdir /var/local/home/{user1,user2} move contents of /home/{user1,user2,...} to /var/local/home mount o bind /var/local/home /home beware: new /home has same mount options as /var CST8177 Todd Kelley 4

share directories across chroot environments mount o bind /dev /home/user/myroot/dev chroot /home/user/myroot/dev in the chroot-ed environment, /dev will be the same as the un-chroot-ed /dev CST8177 Todd Kelley 5

https://access.redhat.com/knowledge/docs/en- US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/c h-disk-quotas.html Quotas give us the ability to keep track of users' disk usage: both blocks (disk space) and inodes (number of files) quota rpm must be installed For both blocks and inodes, quotas allow hard limits and soft limits: Soft limit: user is allowed to exceed a soft limit, but they will be warned, and after a grace period, they cannot increase usage Hard limit: user is never allowed to exceed the hard limit We enable quotas for a file system Quotas can be applied to users and/or groups System administrator can report on all users' disk usage status Each user can see their own disk usage status (quota information) CST8177 Todd Kelley 6

Example: enabling quotas on /home (separate /home filesystem) In /etc/fstab, add the usrquota,grpquota mount options for the file system mounted on the /home mount point Initialize the quota database files for /home with the command quotacheck cug /home c: don't read quota files, create new quota database files u: do user quotas g: do group quotas Turn quotas on quotaon vaug # turn quotas on v: display a message for each filesystem affected a: turn quotas on for all automatically mounted file systems according to /etc/fstab u: user quotas g: group quotas repquota a # report on quotas Turn quotas off quotaoff vaug # turn quotas off quotaoff -vaug; quotacheck vaug; quotaon vaug #single user mode CST8177 Todd Kelley 7

To set a quota for a user, as root edquota username where you'll see (example) DO NOT edit blocks or inodes, just soft and hard limits! Disk quotas for user tgk (uid 107): Filesystem blocks soft hard inodes soft hard /dev/sda8 108 1000 2000 1 0 0 or this command can be used in scripts setquota -u username soft hard isoft ihard fs where username is the name of the user soft is the block soft limit hard is the block hard limit isoft is the inode soft limit ihard is the inode hard limit fs is the file system mount point (e.g. /home) CST8177 Todd Kelley 8

To set the grace period for all users edquota t # edit grace period where you'll see something like this (note units) Grace period before enforcing soft limits for users: Time units may be: days, hours, minutes, or seconds Filesystem Block grace period Inode grace period /dev/mapper/volgroup00-logvol00 8days 8days To set the grace period for an individual user edquota -T tgk where you'll see something like this (note units) Times to enforce softlimit for user tgk (uid 498): Time units may be: days, hours, minutes, or seconds Filesystem block grace inode grace /dev/mapper/volgroup00-logvol00 unset unset CST8177 Todd Kelley 9

individual users can check their individual quota status with quota command: shows block usage and limits inode usage and limits remainder on grace period if over soft limit System administrator can print report of all users quota status (see also warnquota): repquota -a shows for each user what they've used, soft limits, hard limits, and remainder of grace periods if that user has entered one of their grace periods CST8177 Todd Kelley 10

http://teaching.idallen.com/cst8207/14w/no tes/750_booting_and_grub.html page numbers for Fifth Edition Sobell: Chapter 11: 424-431 Chapter 15: 551-552 CST8177 Todd Kelley 11

Power button pressed BIOS POST MBR : contains grub stage 1 grub stage 1 : to find grub stage 2 grub stage 2 : to launch kernel kernel running init process (PID 1) : consults inittab /etc/inittab /etc/rc.d/rc.sysinit /etc/rc.d/rc 3 : assuming default runlevel 3 CST8177 Todd Kelley 12

/etc/inittab contains records of the form id:runlevels:action:process id: identifies an entry runlevels: the runlevels in which the action should be taken action: the action that should be taken process: the process to be executed Because CentOS 6.5 is migrating to a successor of sysvinit (upstartd, which will be replaced with systemd), only the initdefault action is present in our /etc/inittab CST8177 Todd Kelley 13

Even in CentOS 6.5, with upstartd, when the system boots to runlevel 3, the following happens as it did with sysvinit /etc/init.d/rc.sysinit /etc/init.d/rc 3 #default runlevel 3 The sysinit action now is invoked due to the upstartd /etc/init/rcs.conf file The /etc/init.d/rc script being called with argument 3 is due to the upstartd /etc/init/rc.conf file Under sysvinit, this was controlled by /etc/inittab CST8177 Todd Kelley 14

Even with upstartd, sysvinit is supported /etc/init.d/* these are scripts for starting, stopping, restarting services /etc/rc.d/rc.n.d/* #where N is a runlevel these are symbolic links to service's script begins with K means service should not be running in that runlevel: call it with "stop" argument begins with S means service should be running in that runlevel: call it with "start" argument chkconfig maintains these scripts CST8177 Todd Kelley 15

all /etc/init.d/* scripts manageable by chkconfig have two or more commented lines first tells chkconfig what runlevels, and start and stop priority runlevels is "-" if by default should not be started in any runlevel second is a description For example: /etc/init.d/ntpd # chkconfig: - 58 74 # description: ntpd is the NTPv4 daemon. \ # The Network... CST8177 Todd Kelley 16

The /etc/rc.d/rcn.d/ (N=0,1,2,3,4,5,6) directories contain symbolic links to scripts in /etc/init.d These links are maintained by chkconfig (links created or removed by commands like chkconfig <service> on) When entering a new runlevel during boot as controlled by /etc/inittab or by root running a telinit <newlevel> command (example telinit 2 to enter runlevel 2) The system will call scripts to stop services that should not run in that runlevel, and start services that should run in that runlevel CST8177 Todd Kelley 17

When entering a new runlevel, the system needs to stop the services that should not be running in that runlevel, and start the services that should be running in that runlevel To do this, the system calls the scripts in that runlevel's directory, /etc/rc<lev>.d/, where <lev> is a runlevel Scripts whose names begin with K are called with a stop argument (if that service is running) Scripts whose names begin with S are called with a start argument (if that service is not running) CST8177 Todd Kelley 18

Upon entering runlevel 3 (for example): each /etc/rc3.d/k* script is called with "stop" (if that service is running) each /etc/rc3.d/s* script is called with "start" (if that service is not running) The ordering of the scripts being called is given by the chkconfig priority, which is a number in the symlink-ed name of each script These numbers in the link names put the scripts in a certain order chkconfig created the link with this number in the link name because of those commented lines in the script itself (we talked about those a few slides ago) CST8177 Todd Kelley 19

example /etc/rc3.d/s55sshd sshd is configured to run in runlevel 3 otherwise, there would be a K25sshd script there instead (why 25?) 55 is the priority of starting the sshd service when entering that run level This S55sshd script is a symlink to /etc/init.d/sshd Again, the chkconfig command creates and removes these links when we use it to enable or disable a service for a runlevel CST8177 Todd Kelley 20

service SCRIPT COMMAND [OPTIONS] SCRIPT is /etc/init.d/script COMMAND is an argument to the script start stop restart etc start and stop must be recognized by SCRIPT Example: service ntpd start same effect as /etc/init.d/ntpd start Example: service ntpd stop same effect as /etc/init.d/ntpd stop CST8177 Todd Kelley 21

There are dangers associated with doing file system operations on "system directories" that might be used in system operation. For example, many programs will use the shared libraries in /usr/lib, which disappear if we move /usr as we did earlier when we had to run /usr1/bin/rsync Also, there may come a time when the system won't boot properly: MBR corrupted, bad entry in /etc/fstab, inconsistent / file system CST8177 Todd Kelley 22

When you boot with a CD/DVD into rescue mode, you are running a different Linux system installation (from the CD) However, because the rescue Linux system is running on your hardware, it can access the hard disks you have attached (where your "real" Linux system installation resides) Your "real" Linux installation is not running in rescue mode it might even be broken The rescue system can let you make changes/repairs to that "real" Linux system which isn't even running CST8177 Todd Kelley 23

To boot into rescue mode ensure BIOS boot order is set for booting from CD/DVD before Hard Drive (even in VMware F2 to enter setup) insert the installation DVD into drive (or the iso image into the virtual DVD drive) boot the system type "linux rescue" at the prompt, or select the "Rescue" menu item Linux will run "from" the DVD (Live CD), not from your file systems (your system is not running) It will offer to search for and mount your Linux file systems on /mnt/sysimage CST8177 Todd Kelley 24

The Live CD Linux system can see your hard drives, and this is how you can repair or alter what is on those hard drives You need to remember that a Live CD Linux system is running from its own root filesystem (like dual boot?), so this means the users are different /etc/passwd /etc/shadow, etc (or should we say all of /etc) are different the services running, firewalling, and so on, are different CST8177 Todd Kelley 25

ramdisk (the root file system of the rescue system / etc/ bin/ dev/ passwd ls sda shadow bash sda1 sda2 /dev/sda1 (your "real" root file system) / etc/ home/ dev/ fstab idallen/ passwd donnelr CST8177 Todd Kelley 26

Fix /etc/fstab mount /dev/sda1 /mnt/sysimage (if it isn't already mounted the rescue boot process probably offered to mount this for you) vi /mnt/sysimage/etc/fstab fix the problem save and quit exit (to reboot) CST8177 Todd Kelley 27

fix MBR # our root file system is mounted on /mnt/sysimage chroot /mnt/sysimage # now / is our root file system! # our boot filesystem is mounted on /boot grub-install /dev/sda Whoa! That chroot thing was neat chroot runs a program or interactive shell using the named directory as the root directory Default program is ${SHELL} i This simulates running off our system's root file system without going through its boot process CST8177 Todd Kelley 28

That chroot command did something very special, so let's be sure we understand what it did chroot /some/dir gives us a shell process where the /some/dir is / for that shell process In that shell process, any commands you run from its prompt and those resulting processes will work with that changed "root" They will use the /bin, /lib/, /etc... in the changed root CST8177 Todd Kelley 29

When we are running in rescue mode, and our "real" root file system is mounted on /mnt/sysimage then the shell prompt we get from chroot /mnt/sysimage will "use" (because that's what it sees) our "real" /bin, /lib/, /etc... (our "real" root file system that resides on our disk) We can even start services from that chrooted prompt they will run with our "real" root file system binaries(/bin) libraries (/lib) and configuration (/etc), but on the rescue kernel CST8177 Todd Kelley 30

The /dev directory on modern Linux systems contains the device nodes, and these are managed by udev at boot time When booting in rescue mode, udev puts device nodes for your hardware (disks, partitions, etc) into /dev Your "real" (non-rescue) root file system contains an empty /dev directory (it looks full to you because udev populates it when you boot your real system! CST8177 Todd Kelley 31

When the rescue system mounts your "real" root file system on /mnt/sysimage, it first creates a bind mount from /dev to /mnt/sysimage/dev so that when you do chroot /mnt/sysimage the shell you get will see a populated /dev instead of the empty directory This is a good reason to know about bind mounts! CST8177 Todd Kelley 32