More on file systems, Booting Todd Kelley CST8177– Todd Kelley1.

Slides:



Advertisements
Similar presentations
Chapter 9 Part III Linux File System Administration
Advertisements

Basic Unix system administration
Booting and Shuting Down WeeSan Lee. Roadmap Bootstrapping Boot Loaders Startup/Init Scripts Reboot & Shutdown Q&A.
Genesis: from raw hardware to processes System booting sequence: how does a machine come into life.
Chapter 9: Understanding System Initialization The Complete Guide To Linux System Administration.
Week 8 System Initialization and X Windows. Objectives  Summarize the major steps necessary to boot a Linux system  Configure the LILO and GRUB boot.
Booting and Shutting Down the UNIX Operating System Arcadio A. Sincero Jr. 6/6/2001 CMSC 691X, Section 6080.
Linux+ Guide to Linux Certification Chapter Nine System Initialization.
Linux can be generally divided into four major components: 1. KERNEL – OS, ultimate boss The kernel is the core program that runs programs and manages.
Linux+ Guide to Linux Certification, Third Edition
Linux Installation LINUX INSTALLATION. Download LINUX Linux Installation To install Red Hat, you will need to download the ISO images (CD Images) of the.
5-9/12/2005 CPE How to format your computer and re-install Windows XP.
Linux+ Guide to Linux Certification, Second Edition Chapter 3 Linux Installation and Usage.
Processes & Daemons Chapter IV / Part III. Commands Internal commands: alias, cd, echo, pwd, time External commands, code is in a file: grep, ls, more.
System Startup and Shutdown
Linux System Administration LINUX SYSTEM ADMINISTRATION.
Configuring Disk Quotas Linux System Administration To implement disk quotas, use the following steps: Enable quotas per file system by modifying /etc/fstab.
Booting and boot levels
Hands-On Microsoft Windows Server 2008
Lesson 7-Creating and Changing Directories. Overview Using directories to create order. Managing files in directories. Using pathnames to manage files.
System Startup & Shutdown Objectives –to interpret the Unix startup and shutdown configuration files –to be able to create a customised run level Contents.
Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks.
2/19/2003 Lecture 3 Computer System Administration Lecture 3 Setup (continued)
COSC 4750 Customizing and maintenance. Installing software Redhat/Fedora (and linux in general) has a package installer, called rpm Many programs will.
Disks, Filesystems 1.  sudo and PATH (environment)  disks  partitioning  formatting file systems: mkfs command  checking file system integrity: fsck.
UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2010 by Scott Orr and the Trustees of Indiana University.
IT2204: Systems Administration I 1 6b). Introduction to Linux.
Chapter 6: Linux Filesystem Administration
Installation Overview Lab#2 1Hanin Abdulrahman. Installing Ubuntu Linux is the process of copying operating system files from a CD, DVD, or USB flash.
Chapter 1 Managing Storage. Contents Understanding Partitioning Understanding LVM Understanding RAID Understanding Clustering and GFS Using Access Control.
1 Objectives Manage and install new file systems.
The Linux Operating System Lecture 3: Becoming the Superuser and Users and Groups The Tonga Institute of Higher Education.
System Startup & Shutdown
CIS Lesson 5 Lesson 5 New Skills Boot time GRUB edits (review) Changing BIOS boot order on a VM (review) Mounting CD ISO and floppy Image files on.
More on file systems, Booting Todd Kelley CST8177– Todd Kelley1.
Chapter 3 & 6 Root Status and users File Ownership Every file has a owner and group –These give read,write, and execute priv’s to the owner, group, and.
Creating and Managing File Systems. Module 5 – Creating and Managing File Systems ♦ Overview This module deals with the structure of the file system,
Linux Startup Process Presenter: Dipu Gupta.
1 FreeBSD Installation AFNOG X Cairo, Egypt May 2009 Hervey Allen.
Linux+ Guide to Linux Certification, Third Edition
Linux+ Guide to Linux Certification Chapter Six Linux Filesystem Administration.
System Administration – Part 2. Devices in UNIX are files: A device can be accessed with different file names All device files are stored in /dev or its.
PTA Linux Series Copyright Professional Training Academy, CSIS, University of Limerick, 2006 © Workshop V Files and the File System Part B – File System.
Review Please turn in any homework/practicals you may have Folders Paths Services Processes.
SQL SERVER 2008 Installation Guide A Step by Step Guide Prepared by Hassan Tariq.
UNIX Startup and Shutdown CSCI N321 – System and Network Administration Copyright © 2000, 2009 by Scott Orr and the Trustees of Indiana University.
CSC414 “Introduction to UNIX/ Linux” Lecture 6. Schedule 1. Introduction to Unix/ Linux 2. Kernel Structure and Device Drivers. 3. System and Storage.
Lecture 02 File and File system. Topics Describe the layout of a Linux file system Display and set paths Describe the most important files, including.
Sys Admin Course Service Management Fourie Joubert.
Basic UNIX system administration CS 2204 Class meeting 14 *Notes by Doug Bowman and other members of the CS faculty at Virginia Tech. Copyright
System initialization Unit objectives A.Outline steps necessary to boot a Linux system, configure LILO and GRUB boot loaders, and dual boot Linux with.
Materi managing user & groups, file system Managing Software Packages and File Systems The Complete Guide to Linux System Administration Chapter 10.
1 C1-UD 6-6 BASIC LINUX FILE MANAGEMENT. Part IV. File System Administration Academic Year DAI. Credit 1 (Single and Multiuser Operating Systems)
ORAFACT The Linux File System. ORAFACT Filesystem Support Support for dozens of filesystem types including: Minix, ext2, MS-DOS, UMSDOS, VFAT, NTFS, NFS,
1 C1-UD 6-2 INSTALLING LINUX Academic Year DAI. Credit 1 (Single and Multiuser Operating Systems) Ferran Chic PELE-08/09 (Pla Experimental Llengües.
Linux Filesystem Administration
System Administration Startup Process. Why Care? ● Every process on your system comes about by following a specific chain of events from the machine startup.
Getting Started with Linux
Configuring Disk Quotas
Guide to Linux Installation and Administration, 2e
Chapter 6 File Systems CSNB113 SYSTEM ADMINISTRATION
Basic Commands ls cp ls –l (in detail format) echo ls –a
Advanced Operating Systems
Linux Start Sequence Summary
Operating System Module 1: Linux Installation
SUSE Linux Enterprise Desktop Administration
LINUX SYSTEM ADMINISTRATION
COP 4343 Unix System Administration
Devices, Linux Filesystems,and the Filesystem Hirarchy standard
Configuring Disk Quotas
Presentation transcript:

More on file systems, Booting Todd Kelley CST8177– Todd Kelley1

 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 Kelley3

 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 Kelley4

 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 Kelley5

 US/Red_Hat_Enterprise_Linux/6/html/Storage_Administration_Guide/c h-disk-quotas.html 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, we 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 filesystem  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 Kelley6

 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 Kelley7

 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/sda 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 Kelley8

 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 Kelley9

 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 Kelley10

 That LVM tutorial link again: ◦  When a file system resides on a LVM Logical Volume, we can ◦ add a hard disk ◦ create a partition on that hard disk ◦ # or, maybe we already had an unused partition, such as a reclaimed Windows partition ◦ set up that partition as a physical volume ◦ add that physical volume to the Volume Group where that Logical Volume resides ◦ grow the Logical Volume on the Volume Group ◦ grow the file system on that Logical Volume CST8177 – Todd Kelley11

 set up our "new" or "spare" partition as a physical volume for LVM (suppose it's /dev/sdb1): ◦ pvcreate /dev/sdb1  Add this new physical volume to a volume group (in this case VolGroup00): ◦ vgextend VolGroup00 /dev/sdb1  See how many free extents (Free PE) are available in this volume group (VolGroup00) ◦ vgdisplay CST8177 – Todd Kelley12

 Suppose the previous "vgdisplay" command showed that VolGroup00 had 319 free extents ("Free PE") and we use them all: ◦ lvextend –l+319 /dev/VolGroup00/LogVol00  Now LogVol00, which contains our root file system, is bigger, but the files ystem is still the same size.  Grow the filesystem (ext4) to fill the added space (even if the file system is mounted): ◦ resize2fs /dev/VolGroup00/LogVol00  Use df command so see we have bigger file system now! CST8177 – Todd Kelley13

 tes/750_booting_and_grub.html  page numbers for Fifth Edition Sobell: ◦ Chapter 11: ◦ Chapter 15: CST8177 – Todd Kelley14

 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 Kelley15

 /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 Kelley16

 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 Kelley17

 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 Kelley18

 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: # description: ntpd is the NTPv4 daemon. \ # The Network.... CST8177 – Todd Kelley19

 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 on )  When entering a new runlevel ◦ during boot as controlled by /etc/inittab ◦ or by root running a telinit 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 Kelley20

 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.d/, where is a runlevel ◦ Scripts whose names begin with K are called with a stop argument ◦ Scripts whose names begin with S are called with a start argument CST8177 – Todd Kelley21

 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 symlinked 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 its name because of those commented lines in the script itself (we talked about those a few slides ago) CST8177 – Todd Kelley22

 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 CST8177 – Todd Kelley23

 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 Kelley24

 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  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 Kelley25

 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 Kelley26

 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 I say all of /etc) are different ◦ the services running, firewalling, and so on, are different CST8177 – Todd Kelley27

CST8177 – Todd Kelley28 / etc/ bin/ dev/ passwd ls sda shadow bash VolGroup00/ LogVol00 ramdisk / etc/ home/ dev/ fstab idallen/ VolGroup00/ passwd donnelr LogVol00 /dev/VolGroup00/LogVol00

 Fix /etc/fstab ◦ mount /dev/sda1 /mnt/sysimage (if it isn't already mounted) ◦ vi /mnt/sysimage/etc/fstab  fix the problem  save and quit ◦ exit CST8177 – Todd Kelley29

 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 Kelley30