Előadást letölteni
Az előadás letöltése folymat van. Kérjük, várjon
KiadtaBence Barna Megváltozta több, mint 9 éve
1
Unix/Linux basics 0110 - Partitioning, FS, LVM, RAID Operating systems lab Gergely Windisch windisch.gergely@nik.bmf.hu room 4.12 http://nik.bmf.hu/gwindisch/os_2010
2
Hacking lost root password exercise We have a linux machine that has some problems. It won't boot. The system installed on it is very important, it needs to be recovered. All the passwords are forgotten Exercise: – Start the system – Mend GRUB so that it can start automatically – Change the GRUB admin password to rootpw. – Change the root user's password to rootpw Hints – There's a floppy disk in the drive – To make changes, the / partition needs to be remounted as rw – /etc/fstab holds the name of the root partition – name of the kernel: linux24 Good luck!
3
Exercise hints hintek Állítsuk be a BIOSban, hogy bootoljon floppyról. grub prompton: Keressük meg a root devicét Keressük meg a kernelt! (Fájnévkiegészítés megy (TAB)) Keressük ki, hogy mi a root fájlrendszer neve linuxban - /etc/fstab fájl A fájlrendszer most még read-only, újra kell mountolni rwnek: mount -o remount,rw / Szerkeszteni kell a /boot/grub/menu.lst -t: passwd root passwd dsluser (talán ez a neve)
4
Exercise solution "Elfelejtett" jelszavak (ezek nem kellenek a megoldáshoz) – root: elfelejt – dsluser: dslaaa – grub jelszó: elfelejt Visszaállítás lépései – Állítsuk be a BIOSban, hogy bootoljon floppyról. bootgrubimg.img nevű image betöltődik, egy üres grubot tartalmaz – grub prompton: find /sbin/init - root devicét megkeressük – root (hd0,1) - vagy amit az előző parancs adott – Keressük meg a kernelt! asd /boot (TAB), nálunk linux24 – Keressük ki, hogy mi a root fájlrendszer neve linuxban cat /etc/fstab - és itt nézzük meg, hogy mi van a / mellett. (/dev/hda2) – Grub parancs: kernel /boot/linux24 root=/dev/hda2 init=/bin/bash a single nem megy, mivel az is jelszavazott. init=/bin/bash szükséges – A fájlrendszer most még read-only, újra kell mountolni rwnek: mount -o remount,rw / – Szerkeszteni kell a /boot/grub/menu.lst -t: vim /boot/grub/menu.lst - módosítsunk Írjuk át a DSL bejegyzést a jó kernelfájlra és a jó meghajtónévre Írjuk át a jelszót, ehhez md5sum segítségével generálhatunk jelszót (vagy jelszó nélkül is mehet) – passwd root – passwd dsluser (talán ez a neve)
5
Hard disks (reminder) Az ábrák nagy szeretettel lopva innen: http://kac.duf.hu/~balage/szakdoga/hdd.htm
6
Tracks,sectors,cylinders
7
Partitions Filesystems are created on partitions (at least one) In the beginning: 4 partition / disk 15 partition/disk using extended partitions http://www.linuxplanet.com/graphics/screenshots/partitions4.png http://www.win.tue.nl/~aeb/partitions/partition_types-2.html
8
MBR First sector of HDD Contains – Bootloader – Partition table
9
Limits of MBR Legacy system - always updated (=hacked) – 4 primary partitions – can have 15 with extended partitions – addresses: 24 bits (CHS), later 32 bits (LBA) – CHS: 8 GB limit - sometimes even today (boot) – LBA: 32 bit address --> maximum disk capacity: 2 Terabyte Seagate 2000GB-s lemez 59e Ft áfával http://www.ipon.hu/webshop/product/seagate_2000gb_lp_5900rpm_32mb_sata2/116689 – MBR stored in only one sector - prone to dataloss
10
GUID Partition Table (GPT) Intel: Extended Firmware Interface (EFI) – To get rid of the BIOS GTP properties – only LBA addressing – 64 bit pointers - 9.4 zettabyte (9.4*10^21) – 128 partitions (all primary) – GTP data structure is stored at multiple locations - more secure – important parts are CRCd – partitions can have names http://www.ibm.com/developerworks/linux/library/l-gpt/index.html
11
GPT layout
12
GPT support Not everyone supports it yet, so don't depend on it – Hibrid MBR - http://www.rodsbooks.com/gdisk/hybrid.html
14
Disk management in linux hard disk – IDE disks: hd /dev/hda /dev/hdb … – SCSI disks: sd (sata as well) /dev/sda /dev/sdb
15
Partitions hdaX, where X: 1..15 (128) sdaX
16
Partitioning scheme Desktop computer
17
Partitioning scheme (2) Server computer – boot – root – swap – home – var – usr – tmp /home, /usr can also be a network drive – available from every machine
18
Drive management Get free disk space: df Space occupied by directory: du Hard disk info: fdisk Mount drives: mount Unmount drives: umount
19
df: disk free $ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/md2 4881472 793508 4087964 17% / $ df -h -T Filesystem Type Size Used Avail Use% Mounted on /dev/md2 xfs 4.7G 775M 3.9G 17% / df -hT Filesystem Type Size Used Avail Use% Mounted on /dev/md2 xfs 4.7G 786M 3.9G 17% / /dev/md0 ext2 145M 7.2M 130M 6% /boot atlas:/mnt/BIG nfs 465G 306G 160G 66% /.automount/atlas/root/mnt/BIG //surtr/Files smbfs 254G 140G 115G 55% /mnt/Files
20
du: disk utilization $ du svn/ports... 32 svn/ports/vnstat/.svn 48 svn/ports/vnstat 6248 svn/ports $ du -sh svn/ports 6.2M svn/ports Switches: s: summarize h: human readable --max-depth=1
21
Partition types under linux ext2 - exists since 1993. – http://en.wikipedia.org/wiki/Ext2 http://en.wikipedia.org/wiki/Ext2 ext3 - journaling version of ext2 – file operations go into the journal. – in case of a system failure, the system knows where to look for inconsistencies. – (Which is good because there is no need for a full system check - the computer can boot faster. Part of the kernel since 2.4.15
22
File systems(2) ext4 - Extended version of ext3. – More files in directories – more secure journaling (crc) – nanoseconds in time stamps ReiserFS – V3 Journaling Optimized for small files (store database natively) – V4: Upgrade to ReiserFS. – Development is uncertain.
23
File systems (3) BTRFS – New generation file system for linux – Similar to Sun ZFS – pools, snapshots, crc, resizability, etc. – online filesystem check – available in the testing branch since 2.6.29 - promised to be ready by the end of 2008 – It is said to be the future - ext4 is just a temporary solution
24
Filesystem creation fdisk -l : check which disks are available partitioning tools – fdisk – cfdisk – parted – gparted – gui tools
25
Gparted
27
Exercise Create a bunch of disks on SuSE (4 of them) Make it ready for use using the tools sdb: keep it in one part, reiserfs sdc: split it to three parts, create two filesystems for the first two, leave the third untouched – use a different tool to create a filesystem on the third sdd: create an ntfs partition (used by windows) – resize it with gparted (if available), split it, create filesystems on it
28
mount, umount The file systems need to be attached to be used (hdds, CDs, floppys) They need to be removed after use attach disk: mount – Attached fs goes into the / file system Layout of physical disks is hidden mount -o remount,rw / - RW mód
29
mount usage What are the currently mounted disks? – mount Mount a disk – mount -t ext3 /dev/sdb1 /mnt/backuphd umount /mnt/backuphd Attached fs hides previous content mount -t ext3 /dev/sdb1 /mnt/backuphd mount -t ext3 /dev/sdc1 /mnt/backuphd
30
Remount read-only filesystem as rw: – mount -t / -o remount -o rw Mount CD image – mount -t auto Britney.iso /home/hallgato/Britni -o loop
31
Automatic mounting Currently mounted volumes – /etc/mtab Volumes to be mounted – /etc/fstab He who is not present in fstab needs to be mounted manually He who is, doesn't – or can be mounted easier
32
fstab layout #device mount point file system options dump check /dev/hda1 / reiserfs defaults 0 1 /dev/hdb1 /home ext2 auto,notail 1 1 /dev/hdc /mnt/cdrom iso9660 defaults 0 0 /dev/hdd /mnt/dvdrw iso9660 ro,users,noauto 0 0 /dev/sda1 /usr reiserfs ro, owner 0 1 /dev/fd0 /mnt/floppy auto user 0 0 /dev/hda5 swap swap defaults 0 0 host:/var /root/var nfs uid=0,gid=0 1 0 proc /proc proc proc defaults 0 0 http://www.linuxquestions.org/linux/answers/Hardware/etc_fstab_broken_down_and_explained
33
Fstab options Opciók: auto: bootláskor automatikus csatlakoztatás noauto: nem csatlakozik magától (de nem kell mindenét megadni) owner: csak root és a tulajdonos mountolhatja user: bármelyik felhasználó mountolhat, csak root és a tulaj umountolhat users: umount is mehet bárkinek ro: csak olvasás defaults: alapértelmezett opciók uid=x: x felhasználó lesz a csatolt fájlok tulajdonosa gid=x: x csoport lesz a csatolt fájlok tulajdonosa noexec: a fájlrendszer fájljai nem futtathatóak
34
Fstab options auto: automount at boot noauto: won't boot automatically (de nem kell mindenét megadni) owner: only root and the owner can mount it user: every user can mount, only root can unmount users: every user can mount and unmount ro: read only defaults: default options uid=x: set the owner of the files on the volume gid=x: set the group owner of the files on the volume noexec: the files cannot be executed
35
Exercise Put your newly created filesystems in fstab All but the last should be mounted automatically One should only be readable The last one should be rw, but should not be mounted automatically. Every user needs to be able to mount it. Create a symbolic link in the users home directories that point to the new drives Extra exercise: create a script that creates symbolic links to all the drives in each and every user's home directory. – The program should take a look at the available users and their home directories
36
Exercise (optional) Move the /home directory to another disk Resize the / partition Use the newly freed space to create a swap partition
37
LVM Logical Volume Management – Virtual space on disks PE: Physical extent
38
Properties of LVM Pros – More flexible – can be resized easier – somewhat independent of hdd structure Filesystems can span across multiple disks Cons – Disaster recovery is hard – online resizing is not possible
39
Creating LVM Try under SUSE. Try resizing it
40
RAID Redundant Array of Inexpensive Disks Use multiple disks – Performance: RAID0 – Data security: RAID1 – Security + disk space: RAID5
41
RAID 0 - Striping Data is split between the disks Combined disk space equals the sum of the parts Quite fast Quite dangerous (one disk fails - no data) Data: 11011000 – 1st disk: 1101 – 2nd disk: 1000
42
RAID 1 - mirror All the data is present on all the disks Combined disk space = size of smallest disk Slow write Quick read Safe
43
RAID5 At least three disks data on 2, checksum (XOR) on the third for example: – Disk A 1st byte: 10010110 - data 1 – Disk B 1st byte: 11101100 - data 2 – Disk C 1st byte: 01111010 - checksum Either one fails - no problem
44
Further RAID variants RAID6: 2 checksum disks - can survive 2 bad hdd RAID0+1: 4 hdd-s: striped and mirrored
45
OpenSolaris file management Disk names – /dev/dsk - filesystem level access – /dev/rdsk - raw data access
Hasonló előadás
© 2024 SlidePlayer.hu Inc.
All rights reserved.