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

Similar documents
Arch Linux with an SSD Cache using LVM on BCache. Jeremy Runyan

Linux Kernel Update - from scratch (almost) Platform: Archlinux, UEFI, GRUB2, and initramfs. Prof. Rossano Pablo Pinto

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

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

System Administration. Storage Systems

Recovering GRUB: Dual Boot Problems and Solutions

Linux File System Study Guide

Using grub to Boot various Operating Systems

How to Dual-Boot OS X and Ubuntu

SUSE Advanced Troubleshooting: The Boot Process Lecture

Fedora Linux Installation Guide

Linux Systems Security. Backup and Change Management NETS Fall 2016

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

CREATION OF A MINIMAL STAND ALONE RTAI SYSTEM ================================================

Linux Files and the File System

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

OPS235. Linux File Systems Partitioning Mounting File Systems

ECE 550D Fundamentals of Computer Systems and Engineering. Fall 2017

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

2018/04/11 18:35 (UTC) 1/13 UEFI dual or more boot using refind

How To Reinstall Grub In Windows 7 With Cd Bootcamp Partition

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

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

Installation of the OS

CST8177 Linux II. Linux Boot Process

Manually Mount Usb Flash Drive Linux Command Line Redhat

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

Adding a block devices and extending file systems in Linux environments

How To Resize ext3 Partitions Without Losing Data

CIS UNIX System Administration

An introduction to Logical Volume Management

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

Linux Howtos. Red Hat 9 and Trouble (116) CIS Fall Red Hat 9 and Trouble (116)

Installing caos with Cinch on Floppy Disk

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

Lecture 2: The file system

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

Boot Process in details for (X86) Computers

Linux Howtos. Fedora 9 Install (114) CIS Fall Fedora 9 Install (114) Fedora 9 installation with custom partitions.

Manual File System Check Linux Command Line

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

File System. Computadors Grau en Ciència i Enginyeria de Dades. Xavier Verdú, Xavier Martorell

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

Grub Manual Install Ubuntu Without >>>CLICK HERE<<<

File systems and Filesystem quota

Boot. How OS boots

How To Reinstall Grub In Windows 7 With Cd Rom

LPIC-1 System Administrator

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

iscsi storage is used as shared storage in Redhat cluster, VMware vsphere, Redhat Enterprise Virtualization Manager, Ovirt, etc.

Clonezilla Clone As Free As You Want

CSE 265: System and Network Administration

Embedded System Design

Course 55187B Linux System Administration

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

CST Algonquin College 2

LiveCD Customization. Creating your own Linux distribution

Project 3: An Introduction to File Systems. COP 4610 / CGS 5765 Principles of Operating Systems

This line defines Therefore, if your windows entry on the GRUB menu is 8 you should set this value to 7.

Installation of Fedora 12 with CD

Disk Imaging with Knoppix

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

Filesystem Hierarchy Operating systems I800 Edmund Laugasson

Arch Linux Grub You Need To Load The Kernel First

MINI-HOWTO backup and/or restore device or partition using zsplit/unzsplit

GL-280: Red Hat Linux 7 Update. Course Description. Course Outline

Guide to Linux+, Fourth Edition Chapter 2 Solutions

How To Reinstall Grub In Windows 7 Without Cd Dell

Disks, Filesystems 1

Booting Up & Processes

FC SAN Boot Configuration Guide

Partitioning Disks with parted

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

Linux Manually Mount External Hard Drive Ntfs 3g Could Not

CIS 191A Final Exam. Fall CIS 191 Final Exam

Linux Manually Mount External Hard Drive Ntfs-3g Could Not

Manually Mount Usb Flash Drive Ubuntu Server Command Line

(Ubuntu 10.04), the installation command is slightly different.

Novell SUSE Linux Enterprise Server

Linux System Administration, level 1. Lecture 4: Partitioning and Filesystems Part II: Tools & Methods

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

Fedora Linux Installation Guide

The kernel constitutes the core part of the Linux operating system. Kernel duties:

RocketRAID 2522 SATA Controller Ubuntu Linux Installation Guide

Initial Bootloader > Flash Drive. Warning. If not used carefully this process can be dangerous

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

RocketRAID 2310/2300 Controller Fedora Linux Installation Guide

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

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

Lab E2: bypassing authentication and resetting passwords

DM-Multipath Guide. Version 8.2

minit Felix von Leitner September 2004 minit

CSE 265: System and Network Administration

CSE 265: System and Network Administration

Turtles all the Way Down. Image 2013 CC-BY-NC-SA by Tony Gray

Manually Mount Usb Flash Drive Ubuntu Server 12.04

Exam LFCS/Course 55187B Linux System Administration

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

Linux+ Guide to Linux Certification, Third Edition. Chapter 6 Advanced Installation

Rocket RAID 2644 SAS Controller opensuse Linux Installation Guide

Transcription:

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

Agenda Conceptual Storage Structure Bootloader Practical & \Exercise/ Linux Device File Storage Related Commands Boot Related Commands 2

Before we start... Download the image we will use first. VirtualBox.ova file CentOS Installation Minimal CD (.iso) 3

Storage Structure 4

Levels of Storage Application Read/Write file on filesystem. Filesystem Handle lock, permission, journal, index EXT 2/3/4, ZFS, FAT32, NFS... Application Filesystem Level Block Device Disk (?) What really stores things Block Device/Level 5

Network Filesystem (NFS) Client use remote filesystem. Host provides a filesystem. Single host for multiple client. Multiple host for multiple client. high performance (scalability) high availability (redundancy) Ex. NFS, CephFS, GlusterFS Client Application Host Filesystem Level Block Device/Level 6

Simulated Block Device OS views as block devices (disks). May not really be disks. can be fiber, SATA cable, network Application Filesystem Level Block Device/Level Hardware RAID Software Defined Storage 7

Example: Hardware RAID (Pic) 8

9

Example: Hardware RAID Multiple disks form a RAID and constitute a storage pool (or whatever). Then on that storage pool, allocate space for virtual disks (image). OS can only see those virtual disks not those physical. Virtual Disk Disk Disk Disk Disk Disk RAID 5 Virtual Disk OS 10

Question Will hardware RAID know how many partitions are there on disks? So does partition belongs to block device level? 11

Example SAN (https://en.wikipedia.org/wiki/storage_area_network) iscsi (https://en.wikipedia.org/wiki/iscsi) Ceph (http://ceph.com/) 12

Bootloader Everything is mysterious If I am wrong please tell me.

How does W1nd0ws boot? Not necessary. https://zh.wikipedia.org/wiki/%e7%aa%9 7#/media/File:Window1.jpg By 顾震弘 14

:( Your PC ran into a problem and need to restart. We re just collecting some error info, and there we will restart for you. (99% complete) 15

:O 16

:D Solution: Install Linux!! 17

How does Linux Boot? (Legacy/MBR) (Roughly, if anything incorrect please tell me.) 1. BIOS self test 2. Read and test MBR in the order of bootable devices configured in BIOS. 3. Load bootstrap in MBR. 4. Bootstrap load bootloader. 5. Then bootloader load initrd ramdisk image, as well as kernel. 6. Then kernel magically bring up whole system :D 18

Boot Step 2, 3, 4 Step 2. Read and test MBR in the order of bootable devices configured in BIOS. Stupid BIOS can only see block level. MBR = Master Boot Record 0 ~ 446 Bytes: Bootstrap (program) code 446 ~ 510 Bytes: Partition table 510 ~ 512 Bytes: Boot signature Step 3, 4 BIOS load bootstrap -> bootstrap load bootloader 19

Boot Step 5 Then bootloader load initrd ramdisk image, as well as kernel. For GRUB2, GRUB menu shows up. It can handle some basic filesystem. Pass some parameters to kernel. Then its kernel s term. For more, see Jserv DA DA der blog. Who is Jserv? 20

Question Why MBR can only support 4 primary partition? 21

What is load? Do you remember From NAND to Tetris? Load Put into memory. Pass control Set proper PC. So first hard-coded BIOS loads bootstrap. Then bootstrap loads bootloader. Then bootloader loads ramdisk. Then... 22

EFI mode Different from MBR/Legacy mode. Only works with GPT partition table. (HW bonus) 23

Story of bootstrap It is conjectured that Mr. Murphee will now be enabled to hand himself over the Cumberland river or a barn yard fence by the straps of his boots. From wikipedia Image from Wikipedia https://en.wikipedia.org/wiki/bootstrapping#/m edia/file:dr_martens,_black,_old.jpg 24

Practical 25

Unix device files Block devices /dev/sdx, /dev/vdx (virtualized) Partition /dev/sdx1, etc /dev/mapper/cl-root (LVM) /dev/cl/root (same as above) Pseudo devices /dev/null /dev/zero /dev/urandom For more: https://en.wikipedia.org/wiki/device_file 26

Dangerous Command dd if=[device] of=[file] ex. dd if=/dev/zero of=/dev/sda when you want to reinstall OS :D 27

\Exercise/ You get a PC (VM image) that can not boot. Fix it with CentOS installation CD! Download VM from Google Drive So why not just reinstall it? Since we took NASA!! (And it is not Windows) 28

How was the exercise created? su root rm -rf /boot/* dd if=/dev/zero of=/dev/sda1 bs=1 count=446 Then delete /boot partition. 29

Step 0. Try to boot it. No grub -> 30

How does Linux Boot? (Legacy/MBR) 1. BIOS self test 2. Read and test MBR in the order of bootable devices configured in BIOS. MBR destroyed! 3. Load bootstrap in MBR. 4. Bootstrap load bootloader. /boot vanished! 5. Then bootloader load initrd ramdisk image, as well as kernel. /boot/initramfs, vmlinuz deleted! 6. Then kernel magically bring up whole system :( 31

Overview of what we will do Boot with Installation CD. Fix broken stuffs with the broken system. So will use /usr/bin/ in broken system. 32

Step 1. Inject CentOS CD and boot from it. Then select Troubleshooting > Rescue a CentOS Linux system Then choose 3) Skip to shell 33

Inject CD in VirtualBox 34

Step 2: Gather some information about the PC (VM). 35

Commands to Get Information lsblk -f See block devices as well as partitions even not mounted. -f to see partition UUID. df -h See usage of mounted partitions. -h to show in human friendly way. 36

Step 3: In step2, find that /boot disappeared. So create a partition for /boot. 37

How does Linux Boot? (Legacy/MBR) 1. BIOS self test 2. Read and test MBR in the order of bootable devices configured in BIOS. MBR destroyed! 3. Load bootstrap in MBR. 4. Bootstrap load bootloader. /boot vanished! 5. Then bootloader load initrd ramdisk image, as well as kernel. /boot/initramfs, vmlinuz deleted! 6. Then kernel magically bring up whole system :( 38

parted Used to partition disk help tell you everything mktable/mklabel: GPT/msdos mkpart Note it will apply changes as soon as you press enter!! 39

mkfs mkfs -t [fs_type] [device] or mkfs.ext4 mkfs.xfs dosfstools required for fat family. 40

Step 3: Solution parted print mkpart \n primary \n ext4 \n 2048s \n 1024MB quit mkfs.ext4 /dev/sda1 41

Step 4. mount and chroot into the broken system. mount the broken system on /mnt Then go into the broken system. (command chroot) 42

mount mount /dev/sda1 /mnt then files in /dev/sda1 are under /mnt. -o to specify options ex. -o ro to mount read only Mount special devices 43

You need to mount... root partition to /mnt boot partition to /mnt/boot And some special partitions as follow mount mount mount mount -t -t -B -B proc /mnt/proc sysfs sys /mnt/sys dev /mnt/dev /run /mnt/run # for socket file of lvmetad 44

Step 4: Solution mount mount mount mount mount mount /dev/mapper/cl-root /mnt /dev/sda1 /mnt/boot -t proc proc /mnt/proc -t sysfs sys /mnt/sys -B dev /mnt/dev -B /run/ /mnt/run/ chroot /mnt # arch-chroot for Arch 45

Step 5. Edit /etc/fstab for new /boot 46

/etc/fstab Looks like UUID=953-sdsd /dev/sda2 /dev/sda3 /boot / /home xfs xfs xfs mount automatically when booting mount with less arguments. UUID is more robust! Arch has a command to generate it. defaults 0 0 rw 0 0 rw 0 0 47

Step 5: Solution From something like UUID=9016f079-6b2f-4d59-9420-07e97e997767 /boot xfs defaults 0 0 to /dev/sda1 /boot ext4 defaults Though UUID is more robust. 0 0 48

How does Linux Boot? (Legacy/MBR) 1. BIOS self test 2. Read and test MBR in the order of bootable devices configured in BIOS. MBR destroyed! 3. Load bootstrap in MBR. 4. Bootstrap load bootloader. /boot vanished! 5. Then bootloader load initrd ramdisk image, as well as kernel. /boot/initramfs, vmlinuz deleted! 6. Then kernel magically bring up whole system :( 49

Step 6. Get back removed /boot/vmlinuz Originally there are at least two files that looks like vmlinuz-linux initramfs-linux.img 50

Making Initrd ramdisk Arch: mkinitcpio CentOS: mkinitrd mkinitrd and it will tell what to type. 51

Where can I get vmlinuz? From installation CD!! mount /dev/sr0 /mnt rpm -i --replacepkgs \ /mnt/packages/kernel-3.10.0-514.el7.x86_64.rpm 52

Step 7. Install GRUB 53

How does Linux Boot? (Legacy/MBR) 1. BIOS self test 2. Read and test MBR in the order of bootable devices configured in BIOS. MBR destroyed! 3. Load bootstrap in MBR. 4. Bootstrap load bootloader. /boot vanished! 5. Then bootloader load initrd ramdisk image, as well as kernel. /boot/initramfs, vmlinuz deleted! 6. Then kernel magically bring up whole system :( 54

GRUB-Related commands Arch CentOS grub-install, grub2-install Install MBR on device grub2-install --target i386_pc [device] grub-mkconfig, grub2-mkconfig Detect existence of OSs and generate configuration file (/boot/grub/grub.cfg /boot/grub2/grub.cfg). grub2-mkconfig > /boot/grub2/grub.cfg Best practice: Do not modify grub.cfg with hand!!! 55

Step 7: Solution grub2-install /dev/sda grub2-mkconfig > /boot/grub2/grub.cfg 56

Finish!! Remove the installation CD and reboot. Boot from local drive option on CD menu will not work. 57

Wrap up Order of those steps is important!! a. b. c. d. boot gather information create /boot partition mount and chroot the broken system require /boot created e. edit fstab f. get back vmlinuz g. install grub (grub2-mkconfig detects existence of vmlinuz) Only e. can be done earlier or latter. 58

How does Linux Boot? (Legacy/MBR) 1. BIOS self test 2. Read and test MBR in the order of bootable devices configured in BIOS. MBR destroyed! 3. Load bootstrap in MBR. 4. Bootstrap load bootloader. /boot vanished! 5. Then bootloader load initrd ramdisk image, as well as kernel. /boot/initramfs, vmlinuz deleted! 6. Then kernel magically bring up whole system :( 59

Misc: ext family commands e2label Change/See partition label. tune2fs Adjust tunable filesystem parameters on ext2/ext3/ext4 filesystems. (from its man page) 60

License This slide is under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. 61