File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_install_netbsd_from_an_usb_memory_stick.mdwn
Revision 1.2: download - view: text, annotated - select for diffs
Sun Aug 12 22:57:40 2012 UTC (8 years, 3 months ago) by jdf
Branches: MAIN
CVS tags: HEAD
Insert description of how to install NetBSD from a downloaded USB stick,
instead of creating one yourself.
Patch submitted by Leonardo Taccari on the 9th August 2012 on netbsd-docs:
http://mail-index.netbsd.org/netbsd-docs/2012/08/09/msg000286.html

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