GästebuchIhr Eintrag in unser Gästebuch KontaktNehmen Sie Kontakt mit den Autoren auf ArchivAlle Unixwerk- Artikel seit 2003
18. März 2004

Rücksicherung von Linux nach System-Crash

Inhalt

  1. Rettunssystem von CD booten
  2. Festplatte partitionieren mit »fdisk«
  3. Formatieren der Partitionen
  4. Einhängen der Zielpartitionen in den Verzeichnisbaum mit »mount«
  5. Rücksicherung von Band
  6. Schreiben des Bootloaders (LILO)

Voraussetzung für das hier beschriebene Verfahren ist eine Komplettsicherung, die mit tar auf Band vorgenommen wurde.

 

I. Rettunssystem von CD booten

Dies ist praktisch mit jeder Distributions-CD möglich.

 

II. Festplatte partitionieren mit »fdisk«

Im folgenden wird die Vorgehensweise zur Partitionierung der Festplatte auf Linux-Systemen beschrieben. Im Beispiel gehen wir von einer IDE-Platte am ersten Kanal als Master aus (/dev/hda). Dabei geht man nach folgender Reihenfolge (in eckigen Klammern das entsprechende fdisk-Kommando) vor:

  1.  Anmelden
  2.  Start des Programms auf der Kommandozeile
  3.  Kommandoübersicht [m]
  4.  Anzeigen der Partitionstabelle [p]
  5.  Entfernen vorhandener Partitionen (optional) [d]
  6.  Anlegen der Partitionen [n]
  7.  Änderung des Partitionstyps für den Auslagerungsbereich [t]
  8.  Bootpartition startklar machen [a]
  9.  Partitionstabelle schreiben [w]

 

1. Anmelden

 linux login:  root

 linux:~ #  _

 

2. Start des Programms auf der Kommandozeile

Nach der Anmeldung wird das Programm »fdisk« gestartet. Es erscheint der Prompt

 

Command (m for help):
an dem die Befehle eingegeben werden, die immer nur aus einem Buchstaben bestehen. Benutzereingaben sind im folgenden fett dargestellt:

 linux:~ # fdisk /dev/hda

 The number of cylinders for this disk is set to 1232.
 There is nothing wrong with that, but this is larger than 1024,
 and could in certain setups cause problems with:
 1) software that runs at boot time (e.g., old versions of LILO)
 2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

 Command (m for help):

 

3. Kommandoübersicht

Mit dem Kommando »m« kann man sich eine Liste aller Kommandos anzeigen lassen:

 Command (m for help):  m
 Command action
    a   toggle a bootable flag
    b   edit bsd disklabel
    c   toggle the dos compatibility flag
    d   delete a partition
    l   list known partition types
    m   print this menu
    n   add a new partition
    o   create a new empty DOS partition table
    p   print the partition table
    q   quit without saving changes
    s   create a new empty Sun disklabel
    t   change a partition's system id
    u   change display/entry units
    v   verify the partition table
    w   write table to disk and exit
    x   extra functionality (experts only)

 

4. Anzeigen der Partitionstabelle

Mit dem Kommando »p« kann man sich die derzeitige Partitionstabelle anzeigen lassen:

 Command (m for help):  p

 Disk /dev/hda: 255 heads, 63 sectors, 1232 cylinders
 Units = cylinders of 16065 * 512 bytes

    Device Boot    Start       End    Blocks   Id  System
 /dev/hda1             1        13    104391   82  Linux swap
 /dev/hda2   *        14       906   7173022+  83  Linux
 /dev/hda3           907       970    514080   83  Linux
 /dev/hda4           971      1232   2104515   83  Linux

 

5. Entfernen vorhandener Partitionen (optional)

Falls auf der Platte bereits Partitionen angelegt sind, müssen diese mit dem Kommando »d« zunächst entfernt werden:

 Command (m for help):  d
 Partition number (1-4):  1

 Command (m for help):  d

 Partition number (1-4):  2

 Command (m for help):  d
 Partition number (1-4):  3

 Command (m for help):  d

 Partition number (1-4):  4

 Command (m for help):  p

 Disk /dev/hda: 255 heads, 63 sectors, 1232 cylinders
 Units = cylinders of 16065 * 512 bytes

    Device Boot    Start       End    Blocks   Id  System

 

6. Anlegen der Partitionen

Mit dem Kommando »n« werden die neuen Partitionen angelegt. Die Werte unten sind als Beispiel zu sehen. Sie sollten die Größe laut Originalsystem wählen. Wir gehen hier von vier primären Partitionen aus:

 Command (m for help):  n
 Command action
    e   extended
    p   primary partition (1-4)
  p
 Partition number (1-4):  1
 First cylinder (1-1232, default 1): 
 Using default value 1
 Last cylinder or +size or +sizeM or +sizeK (1-1232, default 1232):  13

 Command (m for help):  n
 Command action
    e   extended
    p   primary partition (1-4)
  p
 Partition number (1-4):  2
 First cylinder (14-1232, default 14): 
 Using default value 14
 Last cylinder or +size or +sizeM or +sizeK (14-1232, default 1232):  906

 Command (m for help):  n
 Command action
    e   extended
    p   primary partition (1-4)
  p
 Partition number (1-4):  3
 First cylinder (907-1232, default 907): 
 Using default value 907
 Last cylinder or +size or +sizeM or +sizeK (907-1232, default 1232):  970

 Command (m for help):  n
 Command action
    e   extended
    p   primary partition (1-4)
  p
 Partition number (1-4):  4
 First cylinder (971-1232, default 971): 
 Using default value 971
 Last cylinder or +size or +sizeM or +sizeK (971-1232, default 1232): 
 Using default value 1232

 Command (m for help):  p

 Disk /dev/hda: 255 heads, 63 sectors, 1232 cylinders
 Units = cylinders of 16065 * 512 bytes

    Device Boot    Start       End    Blocks   Id  System
 /dev/hda1             1        13    104391   83  Linux
 /dev/hda2            14       906   7173022+  83  Linux
 /dev/hda3           907       970    514080   83  Linux
 /dev/hda4           971      1232   2104515   83  Linux

 

7. Änderung des Partitionstyps für den Auslagerungsbereich

Mit dem Kommando »t« wird nun der Typ der Swap-Partition geändert:

 Command (m for help):  t

 Partition number (1-4):  1
 Hex code (type L to list codes):  L

  0  Empty           1c  Hidden Win95 FA 65  Novell Netware  bb  Boot Wizard hid
  1  FAT12           1e  Hidden Win95 FA 70  DiskSecure Mult c1  DRDOS/sec (FAT-
  2  XENIX root      24  NEC DOS         75  PC/IX           c4  DRDOS/sec (FAT-
  3  XENIX usr       39  Plan 9          80  Old Minix       c6  DRDOS/sec (FAT-
  4  FAT16 <32M      3c  PartitionMagic  81  Minix / old Lin c7  Syrinx         
  5  Extended        40  Venix 80286     82  Linux swap      da  Non-FS data    
  6  FAT16           41  PPC PReP Boot   83  Linux           db  CP/M / CTOS / .
  7  HPFS/NTFS       42  SFS             84  OS/2 hidden C:  de  Dell Utility   
  8  AIX             4d  QNX4.x          85  Linux extended  df  BootIt         
  9  AIX bootable    4e  QNX4.x 2nd part 86  NTFS volume set e1  DOS access     
  a  OS/2 Boot Manag 4f  QNX4.x 3rd part 87  NTFS volume set e3  DOS R/O        
  b  Win95 FAT32     50  OnTrack DM      8e  Linux LVM       e4  SpeedStor      
  c  Win95 FAT32 (LB 51  OnTrack DM6 Aux 93  Amoeba          eb  BeOS fs        
  e  Win95 FAT16 (LB 52  CP/M            94  Amoeba BBT      ee  EFI GPT        
  f  Win95 Ext'd (LB 53  OnTrack DM6 Aux 9f  BSD/OS          ef  EFI (FAT-12/16/
 10  OPUS            54  OnTrackDM6      a0  IBM Thinkpad hi f0  Linux/PA-RISC b
 11  Hidden FAT12    55  EZ-Drive        a5  FreeBSD         f1  SpeedStor      
 12  Compaq diagnost 56  Golden Bow      a6  OpenBSD         f4  SpeedStor      
 14  Hidden FAT16 <3 5c  Priam Edisk     a7  NeXTSTEP        f2  DOS secondary  
 16  Hidden FAT16    61  SpeedStor       a9  NetBSD          fd  Linux raid auto
 17  Hidden HPFS/NTF 63  GNU HURD or Sys b7  BSDI fs         fe  LANstep        
 18  AST SmartSleep  64  Novell Netware  b8  BSDI swap       ff  BBT            
 1b  Hidden Win95 FA
 Hex code (type L to list codes):  82
 Changed system type of partition 1 to 82 (Linux swap)

 Command (m for help):  p

 Disk /dev/hda: 255 heads, 63 sectors, 1232 cylinders
 Units = cylinders of 16065 * 512 bytes

    Device Boot    Start       End    Blocks   Id  System
 /dev/hda1             1        13    104391   82  Linux swap
 /dev/hda2            14       906   7173022+  83  Linux
 /dev/hda3           907       970    514080   83  Linux
 /dev/hda4           971      1232   2104515   83  Linux

 

8. Bootpartition startklar machen

Mit dem Kommando »a« wird die Partition markiert, die vom BIOS gebootet wird:

 Command (m for help):  a

 Partition number (1-4):  2

 Command (m for help):  p

 Disk /dev/hda: 255 heads, 63 sectors, 1232 cylinders
 Units = cylinders of 16065 * 512 bytes

    Device Boot    Start       End    Blocks   Id  System
 /dev/hda1             1        13    104391   82  Linux swap
 /dev/hda2   *        14       906   7173022+  83  Linux
 /dev/hda3           907       970    514080   83  Linux
 /dev/hda4           971      1232   2104515   83  Linux

 

9. Partitionstabelle schreiben

Mit dem Kommando »w« wird die Partitionstabelle dann tatsächlich auf die Platte geschrieben und das Programm verlassen:

 Command (m for help):  w
 The partition table has been altered!

 Calling ioctl() to re-read partition table.

 Syncing disks.

 linux:~ # _

 

III. Formatieren der Partitionen

Wenn Sie, wie im Beispiel, ausschließlich primäre Partitionen angelegt haben, können Sie direkt mit der Formatierung beginnen. Haben Sie jedoch auch logische Partitionen (hda5 (bzw. sda5) und höher) angelegt, müssen Sie zunächst einen Reboot durchführen.

Für die Formatierung der Partitionen stehen bei Linux mittlerweile eine ganz ansehnliche Anzahl verschiedener Dateisysteme zur Verfügung: ext2, ext3, jfs, reiserfs, xfs. Eine Bewertung würde über den Rahmen dieses Dokumentes hinausgehen. Für das Beispiel gehen wir von ext2 aus:

 linux:~ # mkswap /dev/hda1
 linux:~ # mke2fs /dev/hda2 
 linux:~ # mke2fs /dev/hda3 
 linux:~ # mke2fs /dev/hda4 

 

IV. Einhängen der Zielpartitionen in den Verzeichnisbaum mit »mount«

Zunächst muss die root-Partition (d.h. die Partition, die später unter / zu finden ist) mit dem Befehl mount in den Verzeichnisbaum eingehängt werden:

 linux:~ # mount /dev/hda3 /mnt 

Dann müssen alle Mount-Points angelegt werden (im Beispiel gehen wir mal von /boot und /home aus):

 linux:~ # mkdir /mnt/boot
 linux:~ # mkdir /mnt/home

Nun können die anderen Partitionen eingehängt werden:

 linux:~ # mount /dev/hda2 /mnt/boot
 linux:~ # mount /dev/hda4 /mnt/home

 

V. Rücksicherung von Band

Nun ist alles vorbereitet. Die Rücksicherung von Band kann beginnen:

 linux:~ # cd /mnt
 linux:/mnt # tar xvpf /dev/st0

 

VI. Schreiben des Bootloaders (LILO)

Ist das Backup zurückgeschrieben, muss noch der Bootloader (LILO) geschrieben werden. Dazu muss man mit dem Befehl »chroot« zunächst das rückgesicherte System zum Wurzelverzeichnis machen:

 linux:/mnt # chroot /mnt

Dann kann der LILO geschrieben werden:

 tux:~ # lilo
 Added Linux *
 tux:~ # _

Nach einem Reboot von Platte steht das System wieder zur Verfügung.