File:  [NetBSD Developer Wiki] / wikisrc / ports / evbarm / install_using_sysinst.mdwn
Revision 1.11: download - view: text, annotated - select for diffs
Mon Nov 19 22:00:10 2018 UTC (2 years, 5 months ago) by leot
Branches: MAIN
CVS tags: HEAD
Try to address most TODOs (document u-boot commands and boot.cmd on how to load
the kernel from the SATA hard disk).

    1: [[!meta title="NetBSD/evbarm install via sysinst(8) on a SATA hard disk, USB stick or (u)SD card"]]
    2: 
    3: In this document we will see step by step how to install NetBSD/evbarm on an
    4: external media (SATA hard disk, USB stick or (u)SD card) using
    5: [[!template id=man name="sysinst" section="8"]].
    6: 
    7: As practical example a BananaPI and a SATA hard disk will be used.
    8: However, the following instructions can be probably easily applied
    9: on other SoCs and medias with little adjustments.
   10: 
   11: 
   12: # Populating (u)SD card with `armv7.img`
   13: 
   14: - Download or build `armv7.img`, e.g.:
   15: 
   16: [[!template id=programlisting text="""
   17: $ ftp http://cdn.NetBSD.org/pub/NetBSD/NetBSD-8.0/evbarm-earmv7hf/binary/gzimg/armv7.img.gz
   18: $ gunzip armv7.img.gz
   19: """]]
   20: 
   21: - Write the image to (u)SD card:
   22: 
   23: [[!template id=programlisting text="""
   24: # dd if=armv7.img of=/dev/rsd0d bs=1m conv=sync
   25: """]]
   26: 
   27: - Write u-boot to (u)SD card. `u-boot` images are provided by
   28: `sysutils/u-boot-<boardname>` packages, for example for Allwinner SoC:
   29: 
   30: [[!template id=programlisting text="""
   31: # dd if=/usr/pkg/share/u-boot/&lt;boardname&gt;/u-boot-sunxi-with-spl.bin of=/dev/rld0d bs=1k seek=8 conv=sync
   32: """]]
   33: 
   34: NetBSD/evbarm 8.0 does not automatically boot on the BananaPI.
   35: We can use the following commands to boot from the (u)SD cards in u-boot:
   36: 
   37: [[!template id=programlisting text="""
   38: mmc dev 0
   39: setenv kernel netbsd-BPI.ub
   40: fatload mmc 0:1 82000000 $kernel
   41: bootm 82000000 root=ld0a console=fb
   42: """]]
   43: 
   44: Or, to avoid typing them at every boot we can prepare an u-boot script via
   45: [[!template id=man name="mkubootimage" section="1"]].
   46: 
   47: [[!template id=programlisting text="""
   48: $ cat boot.cmd
   49: mmc dev 0
   50: setenv kernel netbsd-BPI.ub
   51: fatload mmc 0:1 82000000 $kernel
   52: bootm 82000000 root=ld0a console=fb
   53: $ mkubootimage -A arm -n armv7 -T script boot.cmd boot.scr
   54: """]]
   55: 
   56: ...and copy it on the populated (u)SD card:
   57: 
   58: [[!template id=programlisting text="""
   59: # mount /dev/sd0e /mnt
   60: # cp /mnt/boot.scr /mnt/boot.scr.orig
   61: # cp boot.scr /mnt/
   62: """]]
   63: 
   64: 
   65: # Installing via sysinst(8)
   66: 
   67: Now that the SD card is populated with `armv7.img` we can login as `root` (by
   68: default the password is empty) and run `sysinst`:
   69: 
   70: [[!template id=programlisting text="""
   71: # sysinst
   72: """]]
   73: 
   74: The first menu is about the system type (Respberry PI or Other), we select the
   75: latter ("Other"):
   76: 
   77: [[!template id=programlisting text="""
   78: 
   79: 
   80: 
   81: 
   82: 
   83: 
   84: 
   85: 
   86: 
   87: 
   88:                     +-------------------------------------+
   89:                     | What kind of system do you have?    |
   90:                     |                                     |
   91:                     | a: Raspberry PI                     |
   92:                     |>b: Other                            |
   93:                     +-------------------------------------+
   94: 
   95: 
   96: 
   97: 
   98: 
   99: 
  100: 
  101: 
  102: 
  103: 
  104: """]]
  105: 
  106: We want to install NetBSD/evbarm on the hard disk so let's select
  107: "Install NetBSD to hard disk":
  108: 
  109: [[!template id=programlisting text="""
  110: 
  111:  NetBSD/evbarm 8.0
  112: 
  113:  This menu-driven tool is designed to help you install NetBSD to a hard disk,
  114:  or upgrade an existing NetBSD system, with a minimum of work.
  115:  In the following menus type the reference letter (a, b, c, ...) to select an
  116:  item, or type CTRL+N/CTRL+P to select the next/previous item.
  117:  The arrow keys and Page-up/Page-down may also work.
  118:  Activate the current selection from the menu by typing the enter key.
  119: 
  120:  If you booted from a floppy, you may now remove the disk.
  121:  Thank you for using NetBSD!
  122:                +-----------------------------------------------+
  123:                | NetBSD-8.0 Install System                     |
  124:                |                                               |
  125:                |>a: Install NetBSD to hard disk                |
  126:                | b: Upgrade NetBSD on a hard disk              |
  127:                | c: Re-install sets or install additional sets |
  128:                | d: Reboot the computer                        |
  129:                | e: Utility menu                               |
  130:                | f: Config menu                                |
  131:                | x: Exit Install System                        |
  132:                +-----------------------------------------------+
  133: 
  134: 
  135: 
  136: """]]
  137: 
  138: Before proceeding with the installation, if the hard disk had any important data
  139: it is better to stop and doing a backup before proceeding. If it is empty and/or
  140: we can safetely remove its data we can proceed:
  141: 
  142: [[!template id=programlisting text="""
  143: 
  144:  You have chosen to install NetBSD on your hard disk.  This will change
  145:  information on your hard disk.  You should have made a full backup before
  146:  this procedure!  This procedure will do the following things:
  147:          a) Partition your disk
  148:          b) Create new BSD file systems
  149:          c) Load and install distribution sets
  150:          d) Some initial system configuration
  151: 
  152:  (After you enter the partition information but before your disk is changed,
  153:  you will have the opportunity to quit this procedure.)
  154: 
  155:  Shall we continue?
  156:                                +---------------+
  157:                                | yes or no?    |
  158:                                |               |
  159:                                | a: No         |
  160:                                |>b: Yes        |
  161:                                +---------------+
  162: 
  163: 
  164: 
  165: 
  166: 
  167: 
  168: 
  169: """]]
  170: 
  171: Now we can see all the available disks. The hard disk attached via SATA is a
  172: 120GB SSD recognized as `wd0`:
  173: 
  174: [[!template id=programlisting text="""
  175: 
  176:  On which disk do you want to install NetBSD?
  177: 
  178: 
  179:                      +-----------------------------------+
  180:                      | Available disks                   |
  181:                      |                                   |
  182:                      |>a: wd0 (112G, SanDisk SDSSDA120G) |
  183:                      | b: Extended partitioning          |
  184:                      | x: Exit                           |
  185:                      +-----------------------------------+
  186: 
  187: 
  188: 
  189: 
  190: 
  191: 
  192: 
  193: 
  194: 
  195: 
  196: 
  197: 
  198: 
  199: 
  200: 
  201: """]]
  202: 
  203: We now need to edit MBR partition table. We will create two MBR partitions: the
  204: first one a FAT32 for `/boot` and the other for NetBSD. We select "Edit the MBR
  205: partition table":
  206: 
  207: [[!template id=programlisting text="""
  208: 
  209:  We are now going to install NetBSD on the disk wd0.
  210: 
  211:  NetBSD requires a single partition in the disk's MBR partition table, this is
  212:  split further by the NetBSD disklabel.  NetBSD can also access file systems
  213:  in other MBR partitions.
  214: 
  215:  If you select 'Use the entire disk' then the previous contents of the disk
  216:  will be overwritten and a single MBR partition used to cover the entire disk.
  217:  If you want to install more than one operating system then edit the MBR
  218:  partition table and create a partition for NetBSD.
  219: 
  220:  A few hundred MB is enough for a basic installation, but you should allow
  221:  extra for additional software and user files.
  222:  Allow at least 5GB if you want to build NetBSD itself.
  223:                       +---------------------------------+
  224:                       | Which would you like to do?     |
  225:                       |                                 |
  226:                       |>a: Edit the MBR partition table |
  227:                       | b: Use the entire disk          |
  228:                       +---------------------------------+
  229: 
  230: 
  231: 
  232: 
  233: 
  234: """]]
  235: 
  236: First we select the second entry ("b"), set the "type:" to "NetBSD":
  237: 
  238: [[!template id=programlisting text="""
  239: 
  240:  The Current MBR partition table is shown below.
  241:  Flgs: a => Active partition, I => Install here.
  242:  Select the partition you wish to change:
  243: 
  244:     Total disk size 114473 MB.
  245:                +-----------------------------------------------------------+
  246:     Start( MB) |>a:       type: unused                                     |
  247:     ---------- | b:      start: 0 MB                                       |
  248:  a:            | c:       size: 0 MB                                       |
  249: >b:            | d:        end: 0 MB                                       |
  250:  c:            | e:     active: No                                         |
  251:  d:          +-----------------------------------+                         |
  252:  e: Change in| a: Don't change                   |linders/MB)              |
  253:  x: Partition| b: Delete partition               |                         |
  254:              |>c: NetBSD                         |-------------------------+
  255:              | d: Extended partition, LBA        |
  256:              | e: FreeBSD/386BSD                 |
  257:              | f: OpenBSD                        |
  258:              | g: Linux native                   |
  259:              | h: Linux swap                     |
  260:              | i: DOS FAT12                      |
  261:              | &lt;: page up, &gt;: page down          |
  262:              +-----------------------------------+
  263: 
  264: 
  265: """]]
  266: 
  267: We reserve for the NetBSD MBR partition all the end of the disk,
  268: starting at 92MB (1MB that will be empty and 91MB that will be for
  269: the FAT32), we also select to make it active ("active: Yes") and
  270: we will use it to install NetBSD ("install: Yes"):
  271: 
  272: [[!template id=programlisting text="""
  273: 
  274:  The Current MBR partition table is shown below.
  275:  Flgs: a => Active partition, I => Install here.
  276:  Select the partition you wish to change:
  277: 
  278:     Total disk size 114473 MB.
  279:                +-----------------------------------------------------------+
  280:     Start( MB) | a:       type: NetBSD                                     |
  281:     ---------- | b:      start: 92 MB                                      |
  282:  a:            | c:       size: 114381 MB                                  |
  283: >b:            | d:        end: 114473 MB                                  |
  284:  c:            | e:     active: Yes                                        |
  285:  d:            | f:    install: Yes                                        |
  286:  e: Change inpu| g: Change input units (sectors/cylinders/MB)              |
  287:  x: Partition t|>x: Partition OK                                           |
  288:                +-----------------------------------------------------------+
  289: 
  290: 
  291: 
  292: 
  293: 
  294: 
  295: 
  296: 
  297: 
  298: 
  299: """]]
  300: 
  301: We now select the first partition ("a") and create a "Windows FAT32", starting
  302: at 1MB and ending at 92MB before the "NetBSD" partition. We also make it active
  303: ("active: Yes"):
  304: 
  305: [[!template id=programlisting text="""
  306: 
  307:  The Current MBR partition table is shown below.
  308:  Flgs: a => Active partition, I => Install here.
  309:  Select the partition you wish to change:
  310: 
  311:     Total disk size 114473 MB.
  312:                +-----------------------------------------------------------+
  313:     Start( MB) | a:       type: Windows FAT32                              |
  314:     ---------- | b:      start: 1 MB                                       |
  315: >a:            | c:       size: 91 MB                                      |
  316:  b:         92 | d:        end: 92 MB                                      |
  317:  c:            | e:     active: Yes                                        |
  318:  d:            | f:    install: No                                         |
  319:  e: Change inpu| g: Change input units (sectors/cylinders/MB)              |
  320:  x: Partition t|>x: Partition OK                                           |
  321:                +-----------------------------------------------------------+
  322: 
  323: 
  324: 
  325: 
  326: 
  327: 
  328: 
  329: 
  330: 
  331: 
  332: """]]
  333: 
  334: Here the final MBR partition table:
  335: 
  336: [[!template id=programlisting text="""
  337: 
  338:  The Current MBR partition table is shown below.
  339:  Flgs: a => Active partition, I => Install here.
  340:  Select the partition you wish to change:
  341: 
  342:     Total disk size 114473 MB.
  343: 
  344:     Start( MB)  Size( MB) Flg Kind
  345:     ---------- ---------- --- ----------------
  346: >a:          1         91 a   Windows FAT32
  347:  b:         92     114381   I NetBSD
  348:  c:                           unused
  349:  d:                           unused
  350:  e: Change input units (sectors/cylinders/MB)
  351:  x: Partition table OK
  352: 
  353: 
  354: 
  355: 
  356: 
  357: 
  358: 
  359: 
  360: 
  361: 
  362: 
  363: """]]
  364: 
  365: Now that the MBR partition table is written we can proceed to set
  366: sizes of NetBSD partitions:
  367: 
  368: [[!template id=programlisting text="""
  369: 
  370:  NetBSD uses a BSD disklabel to carve up the NetBSD portion of the disk into
  371:  multiple BSD partitions.  You must now set up your BSD disklabel.
  372: 
  373:  You can use a simple editor to set the sizes of the NetBSD partitions, or
  374:  keep the existing partition sizes and contents.
  375: 
  376:  You will then be given the opportunity to change any of the disklabel fields.
  377: 
  378:  The NetBSD part of your disk is 114381 Megabytes.  A full installation
  379:  requires at least 288 Megabytes without X and at least 348 Megabytes if the X
  380:  sets are included.
  381:                      +-----------------------------------+
  382:                      | Choose your installation          |
  383:                      |                                   |
  384:                      |>a: Set sizes of NetBSD partitions |
  385:                      | b: Use existing partition sizes   |
  386:                      +-----------------------------------+
  387: 
  388: 
  389: 
  390: 
  391: 
  392: 
  393: 
  394: 
  395: """]]
  396: 
  397: We set the swap size to 4G and we reserve the rest of the space for "/":
  398: 
  399: [[!template id=programlisting text="""
  400: 
  401:  You can now change the sizes for the system partitions.  The default is to
  402:  allocate all the space to the root file system.  However, you may wish to
  403:  have separate /usr (additional system files), /var (log files etc) or /home
  404:  (users' home directories) file systems.
  405: 
  406:  Free space will be added to the partition marked with a '+'.
  407: 
  408:         MB         Cylinders   Sectors   Filesystem
  409:     a:   2208(110284)      4488   4523904 + /
  410:     b:   4096              8323   8389584   swap
  411:     c:      0                 0         0   /tmp (mfs)
  412:     d:      0                 0         0   /usr
  413:     e:      0                 0         0   /var
  414:     f:      0                 0         0   /home
  415:     g: Add a user defined partition
  416:     h: Change input units (sectors/cylinders/MB)
  417:    >x: Accept partition sizes.  Free space 108076 MB, 13 free partitions.
  418: 
  419: 
  420: 
  421: 
  422: 
  423: 
  424: 
  425: 
  426: """]]
  427: 
  428: The summary of the current BSD disklabel is:
  429: 
  430: [[!template id=programlisting text="""
  431: 
  432:  We now have your BSD disklabel partitions as:
  433:  This is your last chance to change them.
  434: 
  435:     Start  MB   End  MB  Size  MB FS type    Newfs Mount Mount point
  436:     --------- --------- --------- ---------- ----- ----- -----------
  437: >a:        92    110375    110284 FFSv1      Yes   Yes   /
  438:  b:    110376    114472      4096 swap
  439:  c:         0    114472    114473 Whole disk
  440:  d:         0         0         0 unused
  441:  e:         1        91        91 Boot partition
  442:  f:         0         0         0 unused
  443:  g: Show all unused partitions
  444:  h: Change input units (sectors/cylinders/MB)
  445:  x: Partition sizes ok
  446: 
  447: 
  448: 
  449: 
  450: 
  451: 
  452: 
  453: 
  454: 
  455: 
  456: 
  457: """]]
  458: 
  459: We can adjust the disklabel, for example we can use FFSv2 for "/"
  460: and for the disklabel "e" set its mount point to "/boot" in order
  461: that an `/etc/fstab` entry will be populated (please note
  462: that "/boot" will not be automatically mounted by default):
  463: 
  464: [[!template id=programlisting text="""
  465: 
  466:  We now have your BSD disklabel partitions as:
  467:  This is your last chance to change them.
  468: 
  469:     Start  MB   End  MB  Size  MB FS type    Newfs Mount Mount point
  470:     --------- --------- --------- ---------- ----- ----- -----------
  471:  a:        92    110375    110284 FFSv2      Yes   Yes   /
  472:  b:    110376    114472      4096 swap
  473:  c:         0    114472    114473 Whole disk
  474:  d:         0         0         0 unused
  475:  e:         1        91        91 Boot partition             /boot
  476:  f:         0         0         0 unused
  477:  g: Show all unused partitions
  478:  h: Change input units (sectors/cylinders/MB)
  479: >x: Partition sizes ok
  480: 
  481: 
  482: 
  483: 
  484: 
  485: 
  486: 
  487: 
  488: 
  489: 
  490: 
  491: """]]
  492: 
  493: We have finally ready to proceed with
  494: [[!template id=man name="sysinst" section="8"]] as usual and install
  495: the installation sets.  If you choose to install via FTP/HTTP please
  496: note that the "Binary set directory" needs to be adjusted from
  497: `/evbarm/binary/sets` to `/evbarm-earmv7hf/binary/sets` (it's
  498: missing an `-earmv7hf' due different evbarm-s):
  499: 
  500: [[!template id=programlisting text="""
  501: 
  502:  The following are the http site, directory, user, and password that will be
  503:  used.  If "user" is "ftp", then the password is not needed.
  504: 
  505:  a: Host                      ftp.NetBSD.org
  506:  b: Base directory            pub/NetBSD/NetBSD-8.0
  507: >c: Binary set directory      /evbarm-earmv7hf/binary/sets
  508:  d: Source set directory      /source/sets
  509:  e: User                      ftp
  510:  f: Password
  511:  g: Proxy
  512:  h: Transfer directory        /usr/INSTALL
  513:  i: Delete after install      No
  514:  j: Configure network
  515:  k: Exit
  516:  x: Get Distribution
  517: 
  518: 
  519: 
  520: 
  521: 
  522: 
  523: 
  524: 
  525: 
  526: 
  527: """]]
  528: 
  529: The installation will proceed as usual and for more information
  530: please give a look to
  531: [The NetBSD Guide](https://www.netbsd.org/docs/guide/en/chap-exinst.html#exinst-choose-media).
  532: 
  533: When the installation is completed, back to the shell we can populate
  534: `/boot` partition of the hard disk ("wd0e") by just copying all
  535: files of the `/boot` partition of the (u)SD card (`armv7.img`):
  536: 
  537: [[!template id=programlisting text="""
  538: # mount /dev/wd0e /mnt
  539: # cp -r /boot/* /mnt/
  540: # umount /mnt
  541: """]]
  542: 
  543: Finally we can prepare a u-boot script (`boot.scr`) to load the kernel from the
  544: SATA hard disk and boot it:
  545: 
  546: [[!template id=programlisting text="""
  547: $ cat boot.cmd
  548: scsi scan
  549: scsi dev 0
  550: setenv kernel netbsd-BPI.ub
  551: fatload scsi 0:1 82000000 $kernel
  552: bootm 82000000 root=wd0a console=fb
  553: $ mkubootimage -A arm -n armv7 -T script boot.cmd boot.scr
  554: """]]
  555: 
  556: ...and copy them to the (u)SD `/boot`:
  557: 
  558: [[!template id=programlisting text="""
  559: # cp boot.scr /boot
  560: """]]
  561: 
  562: Please remember that in the early boot phase, u-boot and `boot.scr`
  563: are loaded from the (u)SD card and it loads the kernel present in
  564: the `/boot` partition of the hard disk.
  565: 
  566: 
  567: # References
  568: 
  569: *TODOleot*: add a reference to the instructions shared via PR port-evbarm/50806.

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb