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