Linux fdisk
Master Boot Record
- Jede Festplatte hat einen Masterbootrecord, dies ist ein 512 Byte grosser Bereich am Anfang der Festplatte.
- Dieser ist folgendermassen aufgebaut.
Der 512 Byte grosse MBR besteht aus
Bootcode
- 446 Byte groß.
- Hier wird die erste Stufe des Bootloaders unter Linux plaziert!
Partitionstabelle
- 64 Byte gross
- enthält die Kenndaten von 4 primären Partition.
- Die jeweils 16 Byte Bereiche beinhalten
- Bootindikator
- Angang der Partion in der CHS und LBS Notation
- Partitionstyp
- Ende der Partition in CHS Format
- Länge der Partition.
Kennung
- 2 Byte gross
- enthält immer den Wert AA55
Anzeigen des MBRs
- od -N 512 -x /dev/nvme0n1
0000000 c033 d08e 00bc 8e7c 8ec0 bed8 7c00 00bf 0000020 b906 0200 f3fc 50a4 1c68 cb06 b9fb 0004 0000040 bebd 8007 007e 7c00 0f0b 0e85 8301 10c5 0000060 f1e2 18cd 5688 5500 46c6 0511 46c6 0010 0000100 41b4 aabb cd55 5d13 0f72 fb81 aa55 0975 0000120 c1f7 0001 0374 46fe 6610 8060 107e 7400 0000140 6626 0068 0000 6600 76ff 6808 0000 0068 0000160 687c 0001 1068 b400 8a42 0056 f48b 13cd 0000200 839f 10c4 eb9e b814 0201 00bb 8a7c 0056 0000220 768a 8a01 024e 6e8a cd03 6613 7361 fe1c 0000240 114e 0c75 7e80 8000 840f 008a 80b2 84eb 0000260 3255 8ae4 0056 13cd eb5d 819e fe3e 557d 0000300 75aa ff6e 0076 8de8 7500 fa17 d1b0 64e6 0000320 83e8 b000 e6df e860 007c ffb0 64e6 75e8 0000340 fb00 00b8 cdbb 661a c023 3b75 8166 54fb 0000360 5043 7541 8132 02f9 7201 662c 0768 00bb 0000400 6600 0068 0002 6600 0868 0000 6600 6653 0000420 6653 6655 0068 0000 6600 0068 007c 6600 0000440 6861 0000 cd07 5a1a f632 00ea 007c cd00 0000460 a018 07b7 08eb b6a0 eb07 a003 07b5 e432 0000500 0005 8b07 acf0 003c 0974 07bb b400 cd0e 0000520 eb10 f4f2 fdeb c92b 64e4 00eb 0224 f8e0 0000540 0224 49c3 766e 6c61 6469 7020 7261 6974 0000560 6974 6e6f 7420 6261 656c 4500 7272 726f 0000600 6c20 616f 6964 676e 6f20 6570 6172 6974 0000620 676e 7320 7379 6574 006d 694d 7373 6e69 0000640 2067 706f 7265 7461 6e69 2067 7973 7473 0000660 6d65 0000 6300 9a7b 983b e6cc 0000 2080 0000700 0021 1cef 0c10 0800 0000 f000 0002 1c00 0000720 0c11 fe83 ffff f800 0002 1800 3b9b 0000 0000740 0000 0000 0000 0000 0000 0000 0000 0000 0000760 0000 0000 0000 0000 0000 0000 0000 aa55
Partitonstabelle
fdisk der Partitionstabelleneditor für Linux
fdisk teilt eine Festplatte in verschiedene Partitionen ein, löscht bestehende Partitionen oder gibt vorhandenen Partitionen eine andere Systemkennung.fdisk kennt zwei modi interaktiv und list Modus
List Modus
root@zero:~# fdisk -l /dev/sdb Platte /dev/sdb: 1073 MByte, 1073741824 Byte 255 Köpfe, 63 Sektoren/Spuren, 130 Zylinder Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes Disk identifier: 0x20aaf2c3 Gerät boot. Anfang Ende Blöcke Id System /dev/sdb1 1 65 522081 83 Linux /dev/sdb2 66 130 522112+ 83 Linux
Interaktiver Modus
root@zero:~# fdisk /dev/sdb Befehl (m für Hilfe):
Kommandos
Command (m for help): m Help: DOS (MBR) a toggle a bootable flag b edit nested BSD disklabel c toggle the dos compatibility flag Generic d delete a partition F list free unpartitioned space l list known partition types n add a new partition p print the partition table t change a partition type v verify the partition table i print information about a partition e resize a partition T discard (trim) sectors Misc m print this menu u change display/entry units x extra functionality (experts only) Script I load disk layout from sfdisk script file O dump disk layout to sfdisk script file Save & Exit w write table to disk and exit q quit without saving changes Create a new label g create a new empty GPT partition table G create a new empty SGI (IRIX) partition table o create a new empty MBR (DOS) partition table s create a new empty Sun partition table
Die Partitionstabelle anzeigen
Befehl (m für Hilfe): p Platte /dev/sdb: 1073 MByte, 1073741824 Byte 255 Köpfe, 63 Sektoren/Spuren, 130 Zylinder Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes Disk identifier: 0x20aaf2c3 Gerät boot. Anfang Ende Blöcke Id System /dev/sdb1 1 65 522081 83 Linux /dev/sdb2 66 130 522112+ 83 Linux
Partitionen löschen
Befehl (m für Hilfe): d Partitionsnummer (1-4): 2 Befehl (m für Hilfe): d Partition 1 ausgewählt
Neue Partitionen anlegen
Eine primäre Partition anlegen
Befehl (m für Hilfe): n
Befehl Aktion
e Erweiterte
p Primäre Partition (1-4)
p
Partitionsnummer (1-4): 1
Erster Zylinder (1-130, Vorgabe: 1):
Benutze den Standardwert 1
Last Zylinder, +Zylinder or +size{K,M,G} (1-130, Vorgabe: 130): +250M
Eine erweiterte Partition anlegen
Befehl (m für Hilfe): n
Befehl Aktion
e Erweiterte
p Primäre Partition (1-4)
e
Partitionsnummer (1-4): 2
Erster Zylinder (34-130, Vorgabe: 34):
Benutze den Standardwert 34
Last Zylinder, +Zylinder or +size{K,M,G} (34-130, Vorgabe: 130):
Benutze den Standardwert 130
Logische Partitionen anlegen
Befehl (m für Hilfe): n
Befehl Aktion
l Logische Partition (5 oder größer)
p Primäre Partition (1-4)
l
Erster Zylinder (34-130, Vorgabe: 34):
Benutze den Standardwert 34
Last Zylinder, +Zylinder or +size{K,M,G} (34-130, Vorgabe: 130): +250M
Befehl (m für Hilfe): n
Befehl Aktion
l Logische Partition (5 oder größer)
p Primäre Partition (1-4)
l
Erster Zylinder (67-130, Vorgabe: 67):
Benutze den Standardwert 67
Last Zylinder, +Zylinder or +size{K,M,G} (67-130, Vorgabe: 130):
Benutze den Standardwert 130
Den Dateisystemtyp einer Partition ändern
Befehl (m für Hilfe): t Partitionsnummer (1-6): 6 Hex code (L um eine Liste anzuzeigen): l 0 Leer 1e Verst. W95 FAT1 80 Old Minix bf Solaris 1 FAT12 24 NEC DOS 81 Minix / old Lin c1 DRDOS/sec (FAT- 2 XENIX root 39 Plan 9 82 Linux Swap / So c4 DRDOS/sec (FAT- 3 XENIX usr 3c PartitionMagic 83 Linux c6 DRDOS/sec (FAT- 4 FAT16 <32M 40 Venix 80286 84 OS/2 verst. C:- c7 Syrinx 5 Erweiterte 41 PPC PReP Boot 85 Linux erweitert da Nicht-DS-Daten 6 FAT16 42 SFS 86 NTFS volume set db CP/M / CTOS / 7 HPFS/NTFS 4d QNX4.x 87 NTFS volume set de Dell Utility 8 AIX 4e QNX4.x 2nd part 88 Linux Plaintext df BootIt 9 AIX bootfähig 4f QNX4.x 3rd part 8e Linux LVM e1 DOS access a OS/2 Bootmanage 50 OnTrack DM 93 Amoeba e3 DOS R/O b W95 FAT32 51 OnTrack DM6 Aux 94 Amoeba BBT e4 SpeedStor c W95 FAT32 (LBA) 52 CP/M 9f BSD/OS eb BeOS fs e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi ee GPT f W95 Erw. (LBA) 54 OnTrackDM6 a5 FreeBSD ef EFI (FAT-12/16/ 10 OPUS 55 EZ-Drive a6 OpenBSD f0 Linux/PA-RISC b 11 Verst. FAT12 56 Golden Bow a7 NeXTSTEP f1 SpeedStor 12 Compaq Diagnost 5c Priam Edisk a8 Darwin UFS f4 SpeedStor 14 Verst. FAT16 <3 61 SpeedStor a9 NetBSD f2 DOS sekundär 16 Verst. FAT16 63 GNU HURD / SysV ab Darwin boot fb VMware VMFS 17 Verst. HPFS/NTF 64 Novell Netware b7 BSDI fs fc VMware VMKCORE 18 AST SmartSleep 65 Novell Netware b8 BSDI swap fd Linux raid auto 1b Verst. W95 FAT3 70 DiskSecure Mult bb Boot Wizard ver fe LANstep 1c Verst. W95 FAT3 75 PC/IX be Solaris boot ff BBT Hex code (L um eine Liste anzuzeigen):c Der Dateisystemtyp der Partition 6 ist nun c (W95 FAT32 (LBA)
Ende ohne Speichern der Änderungen
Befehl (m für Hilfe): q root@zero:~#
Die Tabelle auf die Festplatte schreiben und das Programm beenden
Befehl (m für Hilfe): w Die Partitionstabelle wurde verändert! Rufe ioctl() um Partitionstabelle neu einzulesen. WARNUNG: Neueinlesen der Partitionstabelle führte zu Fehler 16: Device or resource busy. Der Kernel benutzt noch die alte Tabelle. Die neue Tabelle wird beim nächsten Neustart verwendet

