File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_install_netbsd_from_an_usb_memory_stick.mdwn
Revision 1.5: download - view: text, annotated - select for diffs
Tue Dec 18 12:02:39 2012 UTC (7 years, 9 months ago) by wiki
Branches: MAIN
CVS tags: HEAD
web commit by spz: replace jmcneills script with build.sh, since all supported versions should be able to handle it

    1: This describes how to install NetBSD (i386/amd64) using a Memory Stick instead of a CD-ROM Drive.
    2: 
    3: 
    4: 
    5: **Contents**
    6: 
    7: 
    8: 
    9: [[!toc levels=3]]
   10: 
   11: 
   12: #With an downloaded image
   13: From NetBSD 5.1.2 on for the i386 and amd64 ports it is possible to download a 
   14: memory stick image for installing instead of downloading and transforming a CD image.
   15: 
   16: This section describes in detail how to use this method. If you want to create 
   17: an image yourself, please see below.
   18: 
   19: ##Downloading the installation image
   20: Installation images are available on the [NetBSD
   21: mirrors](http://www.netbsd.org/mirrors/) under the images/ directory, their
   22: filenames match the *install.img.gz pattern.
   23: 
   24: For example if we want to download NetBSD 6.0 for i386:
   25: 
   26:     # ftp ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-6.0/images/NetBSD-6.0-i386-install.img.gz
   27: 
   28: ##Copying the installation image to the memory stick
   29: To prepare the memory stick under a Unix system you can just use
   30: [[!template id=man name="dd" section="1"]].
   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-6.0-i386-install.img.gz
   35:     # dd if=NetBSD-6.0-i386-install.img of=/dev/rsd0d
   36: 
   37: Whenever using dd(1), remember to set the blocksize by specifying the 
   38: <code>bs</code> parameter, at least with a value of 4K, i.e. the call would end 
   39: up with:
   40: 
   41:     # dd if=NetBSD-6.0-i386-install.img of=/dev/rsd0d bs=4K
   42: 
   43: ##Installation process
   44: After NetBSD is booted from the memory stick the installation process is
   45: usual (you can find an example in
   46: [The NetBSD Guide](http://www.netbsd.org/docs/guide/en/chap-exinst.html)).
   47: Just pay attention when choosing the installation media: if you want
   48: to install using the installation sets on the memory stick when
   49: [choosing the installation 
   50: media](http://www.netbsd.org/docs/guide/en/chap-exinst.html#exinst-choose-media)
   51: select <code>g: local directory</code> and then clear the *base* (by default it points
   52: to release/).
   53: 
   54: 
   55: #Build your own image
   56: Use
   57:    build.sh -U release install-image
   58: with your usual build settings from your src directory.
   59: 
   60: Carry on with [the instructions after download](#index2h2) above.
   61: 
   62: 
   63: #Manual method
   64: 
   65: ##Make the Memory Stick bootable
   66: 
   67: 
   68: 
   69: 1 Install the Master Boot Record (MBR):
   70: 
   71: 
   72: 
   73:     # fdisk -i /dev/rsd0d
   74: 
   75: 
   76: 
   77: 2 Create an fdisk partition for NetBSD:
   78: 
   79: <pre><code>
   80: 
   81: # fdisk -u /dev/rsd0d
   82: 
   83: Disk: /dev/rsd0d
   84: 
   85: NetBSD disklabel disk geometry:
   86: 
   87: cylinders: 974, heads: 128, sectors/track: 8 (1024 sectors/cylinder)
   88: 
   89: total sectors: 997375
   90: 
   91: BIOS disk geometry:
   92: 
   93: cylinders: 974, heads: 128, sectors/track: 8 (1024 sectors/cylinder)
   94: 
   95: total sectors: 997375
   96: 
   97: Do you want to change our idea of what BIOS thinks? [n] n
   98: 
   99: Partition table:
  100: 
  101: 0: Primary DOS with 32 bit FAT (sysid 11)
  102: 
  103:    start 8, size 997367 (487 MB, Cyls 0-973/127/8)
  104: 
  105: 1: <UNUSED>
  106: 
  107: 2: <UNUSED>
  108: 
  109: 3: <UNUSED>
  110: 
  111: Bootselector disabled.
  112: 
  113: Which partition do you want to change?: [none] 0
  114: 
  115: The data for partition 0 is:
  116: 
  117: Primary DOS with 32 bit FAT (sysid 11)
  118: 
  119:    start 8, size 997367 (487 MB, Cyls 0-973/127/8)
  120: 
  121: sysid: [0..255 default: 11] 169
  122: 
  123: start: [0..974cyl default: 8, 0cyl, 0MB] (RETURN)
  124: 
  125: size: [0..974cyl default: 997367, 974cyl, 487MB]
  126: 
  127: bootmenu: [] (RETURN)
  128: 
  129: Partition table:
  130: 
  131: 0: NetBSD (sysid 169)
  132: 
  133:    start 8, size 997367 (487 MB, Cyls 0-973/127/8)
  134: 
  135: 1: <UNUSED>
  136: 
  137: 2 :<UNUSED>
  138: 
  139: 3: <UNUSED>
  140: 
  141: Bootselector disabled.
  142: 
  143: Which partition do you want to change?: [none] (RETURN)
  144: 
  145: We haven't written the MBR back to disk yet.  This is your last chance.
  146: 
  147: Partition table:
  148: 
  149: 0: NetBSD (sysid 169)
  150: 
  151:    start 8, size 997367 (487 MB, Cyls 0-973/127/8)
  152: 
  153: 1: <UNUSED>
  154: 
  155: 2: <UNUSED>
  156: 
  157: 3: <UNUSED>
  158: 
  159: Bootselector disabled.
  160: 
  161: Should we write new partition table? [n] y
  162: 
  163: </code></pre>
  164: 
  165: 
  166: 
  167: 3 Set the NetBSD partition active (it's partition Number 0):
  168: 
  169: <pre><code>
  170: 
  171: # fdisk -a /dev/rsd0d
  172: 
  173: Disk: /dev/rsd0d
  174: 
  175: NetBSD disklabel disk geometry:
  176: 
  177: cylinders: 974, heads: 128, sectors/track: 8 (1024 sectors/cylinder)
  178: 
  179: total sectors: 997375
  180: 
  181: BIOS disk geometry:
  182: 
  183: cylinders: 974, heads: 128, sectors/track: 8 (1024 sectors/cylinder)
  184: 
  185: total sectors: 997375
  186: 
  187: Partition table:
  188: 
  189: 0: NetBSD (sysid 169)
  190: 
  191:    start 8, size 997367 (487 MB, Cyls 0-973/127/8)
  192: 
  193: 1: <UNUSED>
  194: 
  195: 2: <UNUSED>
  196: 
  197: 3: <UNUSED>
  198: 
  199: Bootselector disabled.
  200: 
  201: Do you want to change the active partition? [n] y
  202: 
  203: Choosing 4 will make no partition active.
  204: 
  205: active partition: [0..4 default: 4] 0
  206: 
  207: Are you happy with this choice? [n] y
  208: 
  209: </code></pre>
  210: 
  211: 
  212: 
  213: 4 Create the NetBSD disklabel and add the partitions "a" and "d":
  214: 
  215: <pre><code>
  216: 
  217: # disklabel -i -I sd0
  218: 
  219: partition> a
  220: 
  221: Filesystem type [?] [MSDOS]: 4.2BSD
  222: 
  223: Start offset ('x' to start after partition 'x') [0.0078125c, 8s, 0.00390625M]: 63
  224: 
  225: Partition size ('$' for all remaining) [973.991c, 997367s, 486.996M]: $
  226: 
  227: partition> d
  228: 
  229: Filesystem type [?] [unused]: (RETURN)
  230: 
  231: Start offset ('x' to start after partition 'x') [0c, 0s, 0M]: (RETURN)
  232: 
  233: Partition size ('$' for all remaining) [973.999c, 997375s, 487M]: (RETURN)
  234: 
  235: partition> W
  236: 
  237: Label disk [n]? y
  238: 
  239: Label written
  240: 
  241: We haven't written the MBR back to disk yet.  This is your last chance.
  242: 
  243: Should we write new partition table? [n] y
  244: 
  245: </code></pre>
  246: 
  247: 
  248: 
  249: 5 Create a new NetBSD filesystem on partition sd0a:
  250: 
  251: 
  252: 
  253:     # newfs /dev/rsd0a
  254: 
  255: 
  256: 
  257: 
  258: 
  259: 6 Make the partition sd0a bootable:
  260: 
  261: <pre><code>
  262: 
  263: # mkdir /stick
  264: 
  265: # mount /dev/sd0a /stick
  266: 
  267: # cp /usr/mdec/boot /stick
  268: 
  269: # umount /stick
  270: 
  271: # installboot -v -o timeout=1 /dev/rsd0a /usr/mdec/bootxx_ffsv1
  272: 
  273: </code></pre>
  274: 
  275: ##Copy the installation sets to the Memory Stick
  276: 
  277: 
  278: 
  279: 7 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):
  280: 
  281: 
  282: 
  283:     $ cd /home/mark
  284: 
  285:     $ ftp -a ftp://ftp.netbsd.org/pub/NetBSD/iso/4.0.1/i386cd-4.0.1.iso
  286: 
  287: 
  288: 
  289: 
  290: 
  291: 8 Mount the CD-image file:
  292: 
  293: 
  294: 
  295:     $ su
  296: 
  297:     # mkdir /image
  298: 
  299:     # vnconfig -c vnd0 /home/mark/i386cd-4.0.1.iso
  300: 
  301:     # mount_cd9660 /dev/vnd0d /image
  302: 
  303: 
  304: 
  305: 9 Mount the Memory Stick and copy the **Install kernel** and **sets**:
  306: 
  307: 
  308: 
  309:     # mount /dev/sd0a /stick
  310: 
  311:     # cp /image/i386/binary/kernel/netbsd-INSTALL.gz /stick/netbsd.gz
  312: 
  313:     # cp -R /image/i386/binary/sets /stick/sets
  314: 
  315:     # umount /stick
  316: 
  317:     # rmdir /stick
  318: 
  319: 
  320: 
  321: 10 Umount the CD-image:
  322: 
  323: 
  324: 
  325:     # umount /image
  326: 
  327:     # vnconfig -u vnd0
  328: 
  329:     # rmdir /image
  330: 
  331: 
  332: 
  333: The Memory Stick is now ready to boot the NetBSD-Install system. Just reboot and change your BIOS to boot the USB Memory Stick.
  334: 
  335: ##The installation process
  336: 
  337: 
  338: 
  339: If the Memory Stick boots fine, proceed with the Installation as usual, but the selection of the Install-sets is not quite intuitive:
  340: 
  341: 
  342: 
  343:     "Your disk is now ready for installing the kernel and the distributions sets [...]"
  344: 
  345:     [...]
  346: 
  347:     Install from
  348: 
  349:     f: Unmounted fs
  350: 
  351: 
  352: 
  353: 
  354: 
  355: Press RETURN and the following screen appears:
  356: 
  357: 
  358: 
  359:     "Enter the unmounted local device and directory on that device where the distribution is located. [...]"
  360: 
  361: 
  362: 
  363: 
  364: 
  365: Choose the following options:
  366: 
  367: 
  368: 
  369:     a: Device             sd0a
  370: 
  371:     b: File system        ffs
  372: 
  373:     c: Base directory       
  374: 
  375:     d: Set directory      /sets
  376: 
  377: 
  378: 
  379: Yes, "c: Base directory" is left empty, because we had copied the distribution .tgz files to the /sets directory on the Memory Stick (9.)
  380: 
  381: 
  382: 
  383: Now continue with the installation as usual. Good luck!
  384: 
  385: ###Alternative Method
  386: 
  387: 
  388: 
  389: 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.
  390: 
  391: 
  392: 
  393: Extract the sets from the harddisk directly on to the Memory stick (/mnt).
  394: 
  395: 
  396: 
  397:     # tar xvfzp sets.tgz -C /mnt 
  398: 
  399: 
  400: 
  401: Extract the Kernel to the target root
  402: 
  403: 
  404: 
  405:     # tar xvfzp GENERIC-kernel.tgz -C /mnt
  406: 
  407: 
  408: 
  409: 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