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

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

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