File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_install_netbsd_from_an_usb_memory_stick.mdwn
Revision 1.12: download - view: text, annotated - select for diffs
Wed Jun 21 10:25:20 2017 UTC (3 years, 3 months ago) by leot
Branches: MAIN
CVS tags: HEAD
Add a reference to rawrite32 that can be used by Windows users to copy the image
on the disk.

From <martin>

    1: This describes how to install NetBSD (i386/amd64) using a Memory Stick instead
    2: of a CD-ROM Drive.
    3: 
    4: **Contents**
    5: 
    6: [[!toc levels=3]]
    7: 
    8: 
    9: # With an downloaded image
   10: From NetBSD 5.1.2 on for the i386 and amd64 ports it is possible to download a 
   11: memory stick image for installing instead of downloading and transforming a CD image.
   12: 
   13: This section describes in detail how to use this method. If you want to create 
   14: an image yourself, please see below.
   15: 
   16: ## Downloading the installation image
   17: Installation images are available on the [NetBSD
   18: mirrors](http://www.netbsd.org/mirrors/) under the images/ directory, their
   19: filenames match the *install.img.gz pattern.
   20: 
   21: For example if we want to download NetBSD 7.0 for amd64:
   22: 
   23:     # ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-7.0/images/NetBSD-7.0-amd64-install.img.gz
   24: 
   25: ## Copying the installation image to the memory stick
   26: To prepare the memory stick under a Unix system you can just use
   27: [[!template id=man name="dd" section="1"]].
   28: Whenever using dd(1), remember to set the blocksize by specifying the 
   29: <code>bs</code> parameter in order to speed up the write to the installation
   30: media a bit (e.g. 1m).
   31: For example if the memory stick is recognized as `sd0` (**Warning: this will
   32: overwrite all the contents on your memory stick**):
   33: 
   34:     # gunzip NetBSD-7.0-amd64-install.img.gz
   35:     # dd if=NetBSD-7.0-amd64-install.img of=/dev/rsd0d bs=1m
   36: 
   37: In the previous command we have used `rsd0d` in order to refer to the *whole*
   38: `sd0` disk.
   39: 
   40: On Linux the command is similar although it need some minor adjustments, if the
   41: memory stick is recognized as `sdb` (**Warning: this will overwrite all the
   42: contents on your memory stick**):
   43: 
   44:     # gunzip NetBSD-7.0-amd64-install.img.gz
   45:     # dd if=NetBSD-7.0-amd64-install.img of=/dev/sdb bs=1M
   46: 
   47: On Windows you can use [rawrite32](//www.netbsd.org/~martin/rawrite32/) to copy
   48: the image to the stick.
   49: 
   50: ## Installation process
   51: After NetBSD is booted from the memory stick the installation process is
   52: usual (you can find an example in
   53: [The NetBSD Guide](http://www.netbsd.org/docs/guide/en/chap-exinst.html)).
   54: Just pay attention when choosing the installation media: if you want
   55: to install using the installation sets on the memory stick when
   56: [choosing the installation 
   57: media](http://www.netbsd.org/docs/guide/en/chap-exinst.html#exinst-choose-media)
   58: select <code>g: local directory</code> and then clear the *base* (by default it points
   59: to release/).
   60: 
   61: 
   62: # Build your own image
   63: Use <code>build.sh -U release install-image</code>
   64: with your usual build settings from your src directory.
   65: 
   66: Carry on with [the instructions after download](#index2h2) above.
   67: 
   68: 
   69: # Manual method
   70: 
   71: ## Make the Memory Stick bootable
   72: 
   73: First, install the Master Boot Record (MBR):
   74: 
   75:     # fdisk -i /dev/rsd0d
   76: 
   77: Then, create an fdisk partition for NetBSD:
   78: 
   79:     # fdisk -u /dev/rsd0d
   80:     Disk: /dev/rsd0d
   81:     NetBSD disklabel disk geometry:
   82:     cylinders: 974, heads: 128, sectors/track: 8 (1024 sectors/cylinder)
   83:     total sectors: 997375
   84:     BIOS disk geometry:
   85:     cylinders: 974, heads: 128, sectors/track: 8 (1024 sectors/cylinder)
   86:     total sectors: 997375
   87:     Do you want to change our idea of what BIOS thinks? [n] n
   88:     Partition table:
   89:     0: Primary DOS with 32 bit FAT (sysid 11)
   90:        start 8, size 997367 (487 MB, Cyls 0-973/127/8)
   91:     1: <UNUSED>
   92:     2: <UNUSED>
   93:     3: <UNUSED>
   94:     Bootselector disabled.
   95:     Which partition do you want to change?: [none] 0
   96:     The data for partition 0 is:
   97:     Primary DOS with 32 bit FAT (sysid 11)
   98:        start 8, size 997367 (487 MB, Cyls 0-973/127/8)
   99:     sysid: [0..255 default: 11] 169
  100:     start: [0..974cyl default: 8, 0cyl, 0MB] (RETURN)
  101:     size: [0..974cyl default: 997367, 974cyl, 487MB]
  102:     bootmenu: [] (RETURN)
  103:     Partition table:
  104:     0: NetBSD (sysid 169)
  105:        start 8, size 997367 (487 MB, Cyls 0-973/127/8)
  106:     1: <UNUSED>
  107:     2 :<UNUSED>
  108:     3: <UNUSED>
  109:     Bootselector disabled.
  110:     Which partition do you want to change?: [none] (RETURN)
  111:     We haven't written the MBR back to disk yet.  This is your last chance.
  112:     Partition table:
  113:     0: NetBSD (sysid 169)
  114:        start 8, size 997367 (487 MB, Cyls 0-973/127/8)
  115:     1: <UNUSED>
  116:     2: <UNUSED>
  117:     3: <UNUSED>
  118:     Bootselector disabled.
  119:     Should we write new partition table? [n] y
  120: 
  121: 
  122: 
  123: After that, set the NetBSD partition active (it's partition Number 0):
  124: 
  125:     # fdisk -a /dev/rsd0d
  126:     Disk: /dev/rsd0d
  127:     NetBSD disklabel disk geometry:
  128:     cylinders: 974, heads: 128, sectors/track: 8 (1024 sectors/cylinder)
  129:     total sectors: 997375
  130:     BIOS disk geometry:
  131:     cylinders: 974, heads: 128, sectors/track: 8 (1024 sectors/cylinder)
  132:     total sectors: 997375
  133:     Partition table:
  134:     0: NetBSD (sysid 169)
  135:        start 8, size 997367 (487 MB, Cyls 0-973/127/8)
  136:     1: <UNUSED>
  137:     2: <UNUSED>
  138:     3: <UNUSED>
  139:     Bootselector disabled.
  140:     Do you want to change the active partition? [n] y
  141:     Choosing 4 will make no partition active.
  142:     active partition: [0..4 default: 4] 0
  143:     Are you happy with this choice? [n] y
  144: 
  145: Then, create the NetBSD disklabel and add the partitions "a" and "d":
  146: 
  147:     # disklabel -i -I sd0
  148:     partition> a
  149:     Filesystem type [?] [MSDOS]: 4.2BSD
  150:     Start offset ('x' to start after partition 'x') [0.0078125c, 8s, 0.00390625M]: 63
  151:     Partition size ('$' for all remaining) [973.991c, 997367s, 486.996M]: $
  152:     partition> d
  153:     Filesystem type [?] [unused]: (RETURN)
  154:     Start offset ('x' to start after partition 'x') [0c, 0s, 0M]: (RETURN)
  155:     Partition size ('$' for all remaining) [973.999c, 997375s, 487M]: (RETURN)
  156:     partition> W
  157:     Label disk [n]? y
  158:     Label written
  159:     We haven't written the MBR back to disk yet.  This is your last chance.
  160:     Should we write new partition table? [n] y
  161: 
  162: Next, create a new NetBSD filesystem on partition sd0a:
  163: 
  164:     # newfs /dev/rsd0a
  165: 
  166: Now, make the partition sd0a bootable:
  167: 
  168:     # mkdir /stick
  169:     # mount /dev/sd0a /stick
  170:     # cp /usr/mdec/boot /stick
  171:     # umount /stick
  172:     # installboot -v -o timeout=1 /dev/rsd0a /usr/mdec/bootxx_ffsv1
  173: 
  174: 
  175: ## Copy the installation sets to the Memory Stick
  176: 
  177: For the installation you need an installation kernel and the installation sets. To get them, fetch for example a NetBSD CD-image file from a local FTP-Mirror [1](http://www.netbsd.org/mirrors/#ftp):
  178: 
  179:     $ cd /home/mark
  180:     $ ftp -a ftp://ftp.netbsd.org/pub/NetBSD/iso/4.0.1/i386cd-4.0.1.iso
  181: 
  182: Now mount the CD-image file:
  183: 
  184:     $ su
  185:     # mkdir /image
  186:     # vnconfig -c vnd0 /home/mark/i386cd-4.0.1.iso
  187:     # mount_cd9660 /dev/vnd0d /image
  188: 
  189: And then, mount the Memory Stick and copy the **Install kernel** and **sets**:
  190: 
  191:     # mount /dev/sd0a /stick
  192:     # cp /image/i386/binary/kernel/netbsd-INSTALL.gz /stick/netbsd.gz
  193:     # cp -R /image/i386/binary/sets /stick/sets
  194:     # umount /stick
  195:     # rmdir /stick
  196: 
  197: Now you can unmount the CD-image:
  198: 
  199:     # umount /image
  200:     # vnconfig -u vnd0
  201:     # rmdir /image
  202: 
  203: The Memory Stick is now ready to boot the NetBSD-Install system. Just reboot and change your BIOS to boot the USB Memory Stick.
  204: 
  205: ## The installation process
  206: 
  207: If the Memory Stick boots fine, proceed with the Installation as usual, but the selection of the Install-sets is not quite intuitive:
  208: 
  209:     "Your disk is now ready for installing the kernel and the distributions sets [...]"
  210:     [...]
  211:     Install from
  212:     f: Unmounted fs
  213: 
  214: Press RETURN and the following screen appears:
  215: 
  216:     "Enter the unmounted local device and directory on that device where the distribution is located. [...]"
  217: 
  218: Choose the following options:
  219: 
  220:     a: Device             sd0a
  221:     b: File system        ffs
  222:     c: Base directory       
  223:     d: Set directory      /sets
  224: 
  225: Yes, "c: Base directory" is left empty, because we had copied the distribution .tgz files to the /sets directory on the Memory Stick (9.)
  226: 
  227: Now continue with the installation as usual. Good luck!
  228: 
  229: 
  230: ## Alternative Method
  231: 
  232: An alternative setup method saves space on the Stick at the expense of sysinst automation and is therefore more advanced. This method skips the sysinst tool by copying the sets and the **normal** GENERIC Kernel instead of the install-Kernel.
  233: 
  234: Extract the sets from the harddisk directly on to the Memory stick (/mnt):
  235: 
  236:     # tar xvfzp sets.tgz -C /mnt 
  237: 
  238: Extract the Kernel to the target root:
  239: 
  240:     # tar xvfzp GENERIC-kernel.tgz -C /mnt
  241: 
  242: All you need to do is now to create a valid /etc/fstab and modify /etc/rc.conf to RC_CONFIGURED=yes on the target root (/mnt) and reboot. All fine tuning can be done, when you're logged in. 

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