"Das U-Boot" Source Tree
at master 97 lines 2.6 kB view raw
1.. SPDX-License-Identifier: GPL-2.0+ 2 3.. index:: 4 single: mbr (command) 5 6mbr command 7=========== 8 9Synopsis 10-------- 11 12:: 13 14 mbr verify [interface] [device no] [partition list] 15 mbr write [interface] [device no] [partition list] 16 17Description 18----------- 19 20The mbr command lets users create or verify the MBR (Master Boot Record) 21partition layout based on the provided text description. The partition 22layout is alternatively read from the 'mbr_parts' environment variable. 23This can be used in scripts to help system image flashing tools to ensure 24proper partition layout. 25 26The syntax of the text description of the partition list is similar to 27the one used by the 'gpt' command. 28 29Supported 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 37If one wants to create more than 4 partitions, an 'Extended' primary 38partition (with 0x05 ID) has to be explicitly provided as a one of the 39first 4 entries. 40 41Here is an example how to create a 6 partitions (3 on the 'extended 42volume'), 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 55To check if the layout on the MMC #0 storage device matches the provided 56text description one has to issue following command (assuming that 57mbr_parts environment variable is set): 58 59:: 60 61 => mbr verify mmc 0 62 63The 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 72The 'mbr write' command returns 0 on success write or 1 on failure. 73 74The 'mbr verify' returns 0 if the layout matches the one on the storage 75device or 1 if not. 76 77Configuration 78------------- 79 80To use the mbr command you must specify CONFIG_CMD_MBR=y. 81 82Return value 83------------ 84 85The 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+---+------------------------------+