blob: bddf2f612aa9764843cd9a70435146967743e1b0 [file] [log] [blame]
Marek Szyprowski6427b5b2020-12-23 13:55:15 +01001.. SPDX-License-Identifier: GPL-2.0+
2
3mbr command
4===========
5
6Synopsis
7--------
8
9::
10
11 mbr verify [interface] [device no] [partition list]
12 mbr write [interface] [device no] [partition list]
13
14Description
15-----------
16
17The mbr command lets users create or verify the MBR (Master Boot Record)
18partition layout based on the provided text description. The partition
19layout is alternatively read from the 'mbr_parts' environment variable.
20This can be used in scripts to help system image flashing tools to ensure
21proper partition layout.
22
23The syntax of the text description of the partition list is similar to
24the one used by the 'gpt' command.
25
26Supported 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
34If one wants to create more than 4 partitions, an 'Extended' primary
35partition (with 0x05 ID) has to be explicitly provided as a one of the
36first 4 entries.
37
38Here is an example how to create a 6 partitions (3 on the 'extended
39volume'), 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
52To check if the layout on the MMC #0 storage device matches the provided
53text description one has to issue following command (assuming that
54mbr_parts environment variable is set):
55
56::
57
58 => mbr verify mmc 0
59
60The 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
69The 'mbr write' command returns 0 on success write or 1 on failure.
70
71The 'mbr verify' returns 0 if the layout matches the one on the storage
72device or 1 if not.
73
74Configuration
75-------------
76
77To use the mbr command you must specify CONFIG_CMD_MBR=y.
78
79Return value
80------------
81
82The 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+---+------------------------------+