File:  [NetBSD Developer Wiki] / wikisrc / tutorials / how_to_install_netbsd_from_an_usb_memory_stick.mdwn
Revision 1.6: download - view: text, annotated - select for diffs
Tue Dec 18 12:07:02 2012 UTC (7 years, 11 months ago) by wiki
Branches: MAIN
CVS tags: HEAD
web commit by spz: formatting

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