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

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