Annotation of wikisrc/ports/evbarm/install_using_sysinst.mdwn, revision 1.17

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

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