File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_install_netbsd_from_an_usb_memory_stick.mdwn
Revision 1.8: download - view: text, annotated - select for diffs
Wed Sep 2 15:04:09 2015 UTC (5 years, 2 months ago) by leot
Branches: MAIN
CVS tags: HEAD
Suggest to use a block size (dd bs= option) to 1m (instead of 4k).

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