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