Marek Szyprowski | 6427b5b | 2020-12-23 13:55:15 +0100 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+ |
| 2 | |
Heinrich Schuchardt | 1b0c316 | 2024-01-14 14:53:13 +0100 | [diff] [blame] | 3 | .. index:: |
| 4 | single: mbr (command) |
| 5 | |
Marek Szyprowski | 6427b5b | 2020-12-23 13:55:15 +0100 | [diff] [blame] | 6 | mbr command |
| 7 | =========== |
| 8 | |
| 9 | Synopsis |
| 10 | -------- |
| 11 | |
| 12 | :: |
| 13 | |
| 14 | mbr verify [interface] [device no] [partition list] |
| 15 | mbr write [interface] [device no] [partition list] |
| 16 | |
| 17 | Description |
| 18 | ----------- |
| 19 | |
| 20 | The mbr command lets users create or verify the MBR (Master Boot Record) |
| 21 | partition layout based on the provided text description. The partition |
| 22 | layout is alternatively read from the 'mbr_parts' environment variable. |
| 23 | This can be used in scripts to help system image flashing tools to ensure |
| 24 | proper partition layout. |
| 25 | |
| 26 | The syntax of the text description of the partition list is similar to |
| 27 | the one used by the 'gpt' command. |
| 28 | |
| 29 | Supported partition parameters are: |
| 30 | |
| 31 | * name (currently ignored) |
| 32 | * start (partition start offset in bytes) |
| 33 | * size (in bytes or '-' to expand it to the whole free area) |
| 34 | * bootable (boolean flag) |
| 35 | * id (MBR partition type) |
| 36 | |
| 37 | If one wants to create more than 4 partitions, an 'Extended' primary |
| 38 | partition (with 0x05 ID) has to be explicitly provided as a one of the |
| 39 | first 4 entries. |
| 40 | |
| 41 | Here is an example how to create a 6 partitions (3 on the 'extended |
| 42 | volume'), some of the predefined sizes: |
| 43 | |
| 44 | :: |
| 45 | |
| 46 | => setenv mbr_parts 'name=boot,start=4M,size=128M,bootable,id=0x0e; |
| 47 | name=rootfs,size=3072M,id=0x83; |
| 48 | name=system-data,size=512M,id=0x83; |
| 49 | name=[ext],size=-,id=0x05; |
| 50 | name=user,size=-,id=0x83; |
| 51 | name=modules,size=100M,id=0x83; |
| 52 | name=ramdisk,size=8M,id=0x83' |
| 53 | => mbr write mmc 0 |
| 54 | |
| 55 | To check if the layout on the MMC #0 storage device matches the provided |
| 56 | text description one has to issue following command (assuming that |
| 57 | mbr_parts environment variable is set): |
| 58 | |
| 59 | :: |
| 60 | |
| 61 | => mbr verify mmc 0 |
| 62 | |
| 63 | The verify sub-command is especially useful in the system update scripts: |
| 64 | |
| 65 | :: |
| 66 | |
| 67 | => if mbr verify mmc 0; then |
| 68 | echo MBR layout needs to be updated |
| 69 | ... |
| 70 | fi |
| 71 | |
| 72 | The 'mbr write' command returns 0 on success write or 1 on failure. |
| 73 | |
| 74 | The 'mbr verify' returns 0 if the layout matches the one on the storage |
| 75 | device or 1 if not. |
| 76 | |
| 77 | Configuration |
| 78 | ------------- |
| 79 | |
| 80 | To use the mbr command you must specify CONFIG_CMD_MBR=y. |
| 81 | |
| 82 | Return value |
| 83 | ------------ |
| 84 | |
| 85 | The variable *$?* takes the following values |
| 86 | |
| 87 | +---+------------------------------+ |
| 88 | | 0 | mbr write was succesful | |
| 89 | +---+------------------------------+ |
| 90 | | 1 | mbr write failed | |
| 91 | +---+------------------------------+ |
| 92 | | 0 | mbr verify was succesful | |
| 93 | +---+------------------------------+ |
| 94 | | 1 | mbr verify was not succesful | |
| 95 | +---+------------------------------+ |
| 96 | |-1 | invalid arguments | |
| 97 | +---+------------------------------+ |