Annotation of wikisrc/tutorials/how_to_install_netbsd_from_an_usb_memory_stick.mdwn, revision 1.11

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