saving your ass(ets) with chroot

13
Saving Your Ass(ets) with chroot Alan Bailward <alan@ufies.org> April 15, 2004 For the Fraser Valley Linux Users Group

Upload: ralph-alvarez

Post on 31-Dec-2015

36 views

Category:

Documents


4 download

DESCRIPTION

Saving Your Ass(ets) with chroot. Alan Bailward April 15, 2004 For the Fraser Valley Linux Users Group. What is chroot?. Allows running of commands with an arbitrary root directory Syntax: chroot NEWROOT [command] Used to “jail” applications - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Saving Your Ass(ets) with chroot

Saving Your Ass(ets) with chroot

Alan Bailward <[email protected]>April 15, 2004

For the Fraser Valley Linux Users Group

Page 2: Saving Your Ass(ets) with chroot

What is chroot?

Allows running of commands with an arbitrary root directory

Syntax: chroot NEWROOT [command]

Used to “jail” applications

Mostly used for security applications

i.e.: servers

Page 3: Saving Your Ass(ets) with chroot

Getting in Trouble

Easy to have Linux problems

Errors on install

Broken kernel

Broken lilo

Normally you’re out of luck, to a degree, or need to deal with accessing things from a BootCD

Page 4: Saving Your Ass(ets) with chroot

Getting Out of Trouble

The old way

Page 5: Saving Your Ass(ets) with chroot

The Old way

Get to your system

Floppy

BootCD

Fix it

Mess with lilo/lilo.conf

Compile kernel, hope it works

Page 6: Saving Your Ass(ets) with chroot

Getting Out of Trouble

The New Way

Page 7: Saving Your Ass(ets) with chroot

Using chroot

Lets you access your system as it was

Full access to accurate /proc and /dev

No funky pathing

Easy to jump in and out of

Page 8: Saving Your Ass(ets) with chroot

How To Use chroot 1

Boot with BootCD

mkdir /mnt/new

mount /dev/hda1 /mnt/new

mount /dev/hda2 /mnt/new/boot

mount /dev/hda3 /mnt/new/var

Page 9: Saving Your Ass(ets) with chroot

How To Use chroot 2

mount -o bind /proc /mnt/new/proc/

link the “real” /proc into your new file structure

mount -o bind /dev /mnt/new/dev/

ditto for /dev (only for devfs systems)

Page 10: Saving Your Ass(ets) with chroot

How To Use chroot 3

cp /etc/resolv.conf /mnt/new/etc/

need accurate network info

chroot /mnt/new /bin/bash

enter the system

env-update # gentoo only

update environment settings

Page 11: Saving Your Ass(ets) with chroot

How To Use chroot 4

You are now in a shell that is your old system

cd / puts you in your old / (really /mnt/new/)

Can run lilo, compile kernels, etc

To exit, type ‘exit’ to exit, then unmount disks and reboot

Page 12: Saving Your Ass(ets) with chroot

Live Demo

Page 13: Saving Your Ass(ets) with chroot

Questions?