mbr.rst 2.5 KB

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