Add instructions on manual crypto and non-crypto installations
[ikiwiki.git] / docs / handbook / Installation / index.mdwn
1 # Chapter 2 Installation from CD or USB
2
3 This document describes the installation of DragonFly BSD. This process uses a bootable DragonFly CD or USB disk image, usually referred to as a 'live CD' or 'USB disk image'.  These are available at one of the current mirrors, which distribute the images by various protocols. The authoritative list can be found at the [DragonFly website](http://www.dragonflybsd.org/download/).
4
5 We recommend installing from a USB disk image, which has more pre-installed packages (including X).
6
7
8 [[!toc  levels=3]]
9
10 <!-- XXX: add stuff about usb stick -->
11
12
13 ----
14
15
16
17 ## First steps 
18
19
20
21 Upon booting, you see the following screen:
22
23 <img src="http://leaf.dragonflybsd.org/~alexh/images/2.png"/>
24 <!-- XXX: insert image 2.png -->
25
26
27 As you can see, it gives you the option of logging in as `root` to run the live CD and play around or logging in as `installer` to install DragonFly to your hard drive. 
28
29 Log in as `installer`. You will then see the following screen:
30
31 <img src="http://leaf.dragonflybsd.org/~alexh/images/3.png"/>
32 <!-- XXX: insert image 3.png -->
33
34
35
36 ## Set up Disk for Installation 
37
38 Note the warning to backup important data. Things can always go wrong and if, for example, you have another partition with important files, a mistype or other error might lose all the information on that partition. Assuming this is done, or that you aren't worried about other data on the machine, again, select install DragonFly BSD and you will be taken to the next screen:
39
40 <img src="http://leaf.dragonflybsd.org/~alexh/images/5.png"/>
41 <!-- XXX: insert image 5.png -->
42
43 If you have multiple disks installed, chose one where you want to install DragonFly.  We chose `da0` here.
44
45 <img src="http://leaf.dragonflybsd.org/~alexh/images/6.png"/>
46 <!-- XXX: insert image 6.png -->
47
48 After selecting the disk we need to decide how much of the disk we want to use.  We choose to use the entire disk and see the next screen.  Now we can chose between the two file systems on DragonFly.  HAMMER is the brand-new file system with a big number of features like snapshots, history tracking, mirroring etc.  UFS is the old BSD file system.
49 <!-- XXX: mention stuf about UFS+HAMMER being the default setup, and why. -->
50
51 <img src="http://leaf.dragonflybsd.org/~alexh/images/8.png"/>
52 <!-- XXX: insert image 8.png -->
53
54 We select HAMMER and see now the following screen:
55
56 <img src="http://leaf.dragonflybsd.org/~alexh/images/9.png"/>
57 <!-- XXX: insert image 9.png -->
58
59 The screen (shown above) gives the default partition scheme for this drive. As the screen says, the * indicates that it will use remainder of the disk.  If you chose HAMMER as your file system there is no need to change the default settings.  One swap partition is created and the remaining space is assigned to the root partition.  The installer will automatically add sub-partitions (called Pseudo File Systems (PFS) in HAMMER) for /home, /usr, /var, /var/crash, /var/tmp and /tmp for you.  If you want to get more information about HAMMER, have a look in the man page.
60
61
62
63
64
65 ## Install to Disk 
66
67 The following steps show how DragonFly can be installed to your hard disk:
68
69 <img src="http://leaf.dragonflybsd.org/~alexh/images/10.png"/>
70 <!-- XXX: image 10.png -->
71
72 Depending on your hardware installing DragonFly will take some time. Once installation is complete, you are given an option to install bootblocks. Note that if you are installing bootblocks and the DragonFly installation is above the 1024th cylinder (approximately 8 gigs) accept the default of having packet mode selected:
73
74 <img src="http://leaf.dragonflybsd.org/~alexh/images/12.png"/>
75 <!-- XXX: image 12.png -->
76
77 Next, we are given an option to configure the system or reboot:
78
79 <img src="http://leaf.dragonflybsd.org/~alexh/images/13.png"/>
80 <!-- XXX: image 13.png -->
81
82
83
84
85
86 ## Set up your system 
87
88
89 The following menu of the installer allows you to configure your previously installed system.
90
91 <img src="http://leaf.dragonflybsd.org/~alexh/images/14.png"/>
92 <!-- XXX: image 14.png -->
93
94 This includes setting a password for your `root` account:
95
96 <img src="http://leaf.dragonflybsd.org/~alexh/images/15.png"/>
97 <!-- XXX: image 15.png -->
98
99 Be sure to select the correct keyboard map for your system, and configure a hostname.
100
101
102 ### Add a new user 
103
104 To perform your daily work, it is recommended to work as an unprivileged user.  Use the following screen to create such an account.  If you want to allow your user to use [su(1)](http://leaf.dragonflybsd.org/cgi/web-man?command=su&section1), also add him to the `wheel` group:
105
106 <img src="http://leaf.dragonflybsd.org/~alexh/images/16.png"/>
107 <!-- XXX: image 16.png -->
108
109 ### Configure the Network 
110
111 The next screen allows you to setup your network.  The installed card seen here is an Intel Ethernet 1000 powered by [em(4)](http://leaf.dragonflybsd.org/cgi/web-man?command=em&section4):
112
113 <img src="http://leaf.dragonflybsd.org/~alexh/images/17.png"/>
114 <!-- XXX: image 17.png -->
115
116 After finishing your configuration you can escape into a live shell or reboot the system into your installation.
117
118 If you find that your network is working with numeric ips but not working with domain names, you might want to make sure you have a file called `/etc/resolv.conf` and that it has your local DNS server in it, something like this:
119
120     nameserver 192.168.1.1
121
122
123 If you find that the ethernet auto-configuration feature is unable to reach your DHCP server, you can still let it create your network configuration file which is called `/etc/rc.conf`.  If you are familiar with Linux device names you might notice that in BSD flavour Unixes, device names like `/dev/de0` or `/dev/em0` are the BSD equivalent of the Linux name `/dev/eth0`.
124
125 # Manual Installation (all types) (assumes whole disk)
126
127 WARNING! These instructions assume that 'da0' is the drive you are installing to and that you booted from somewhere else.  'da0' in these instructions must not contain anything you used to boot the system from.  Normally you will have booted from some other media, such as a USB stick, CD, or the network.  
128
129 WARNING! These instructions assume that you are not sharing the drive with any other operating system and have no data on the drive that you wish to keep.  Generally speaking, my recommendation is to not have multi-OS boot setups (its too easy to mistakenly wipe them when messing around with other installations).  Instead, invest in a hot-swap drive bay and put each OS on its own SSD.
130
131 To do a manual installation you need to initialize the disk.  DragonFlyBSD uses a modified fdisk which works on any-sized disk by having the kernel recognize the maximum size fdisk supports and translate that to the whole disk's actual size.  You need to install the boot sector and also setup a bootable DragonFlyBSD disklabel.
132
133 fdisk -IB /dev/da0
134
135 disklabel -r -w -B /dev/da0s1 auto
136
137 Edit the label and create three partitions: a, b, and c.  The 'a' partition is going to be /boot and needs to be a 1GB UFS partition.  'b' is your swap and should be roughly 2x main memory (we recommend at least 4GB or more, particularly if you will be running browsers).  'd' is your root partition.
138
139 disklabel -e da0s1
140
141 a: 1G 0 4.2BSD
142
143 b: 8G * swap
144
145 d: * * HAMMER
146
147 # Manual Non-Crypto Installation
148
149 Format the filesystems and mount them:
150
151 newfs /dev/da0s1a
152
153 newfs_hammer -L ROOT /dev/da0s1d
154
155 mount /dev/da0s1d /mnt
156
157 mkdir /mnt/boot
158
159 mount /dev/da0s1a /mnt/boot
160
161 Once you have them mounted, copy from a working DragonFly installation.  This can be from installation media or via NFS if you have setup the network and have a server somewhere.  Two cpdup commands are needed since we have two partitions.  If the source of your image is broken up into additional partitions, you may have to cpdup each one (cpdup nominally stops at mount boundaries on the source):
162
163 cpdup /boot /mnt/boot
164
165 cpdup / /mnt
166
167 Finally, edit "/mnt/boot/loader.conf", "/mnt/etc/fstab", and "/mnt/etc/rc.conf" to point to your disk.  At a minimum you will need this line in your "/mnt/boot/loader.conf" (we recommend configuring by serial number, which you can get from the dmesg output, but if you don't want to then use the drive name which might be something like 'da0s1d').
168
169 vfs.root.mountfrom="hammer:serno/SERIALNUMOFDISK.s1d"
170
171 Your "/etc/fstab" file should contain something like the below:
172
173 serno/SERIALNUMOFDISK.s1a    /boot           ufs     rw              1 1
174
175 serno/SERIALNUMOFDISK.s1b    none            swap    sw              0 0
176
177 serno/SERIALNUMOFDISK.s1d    /               hammer  rw              1 1
178
179 # Manual Crypto Installation
180
181 To setup a crypto system follow the generic non-crypto steps above.  Make sure that your boot drive has a "/boot/kernel/initrd.img.gz" file in as the system will need to bootstrap through MD0 in order to mount an encrypted root.  In this example I am also encrypting swap.
182
183 If your drive partitions previously contained unencrypted data and you want to wipe it, you can dd /dev/urandom to the target partitions.  It can take many hours to do this so you might decide to skip this optional step:
184
185 dd if=/dev/urandom of=/dev/da0s1b bs=32k
186
187 dd if=/dev/urandom of=/dev/da0s1d bs=32k
188
189 Setup an encrypted swap and root partition as shown below:
190
191 kldload dm
192
193 cryptsetup --key-size 256 --hash sha512 -y luksFormat /dev/da0s1b
194
195 cryptsetup --key-size 256 --hash sha512 -y luksFormat /dev/da0s1d
196
197 cryptsetup luksOpen /dev/da0s1b swap
198 cryptsetup luksOpen /dev/da0s1d root
199
200 Format the filesystems and mount them.  Note that the boot partition is not encrypted.
201
202 newfs /dev/da0s1a
203
204 newfs_hammer -L ROOT /dev/mapper/root
205
206 mount /dev/mapper/root /mnt
207
208 mkdir /mnt/boot
209
210 mount /dev/da0s1a /mnt/boot
211
212 Once you have them mounted, copy from a working DragonFly installation.  This can be from installation media or via NFS if you have setup the network and have a server somewhere.  Two cpdup commands are needed since we have two partitions.  If the source of your image is broken up into additional partitions, you may have to cpdup each one (cpdup nominally stops at mount boundaries on the source):
213
214 cpdup /boot /mnt/boot
215
216 cpdup / /mnt
217
218 Finally, edit "/mnt/boot/loader.conf", "/mnt/etc/fstab", and "/mnt/etc/rc.conf" to point to your disk.  At a minimum you will need this line in your "/mnt/boot/loader.conf" (we recommend configuring by serial number, which you can get from the dmesg output, but if you don't want to then use the drive name which might be something like 'da0s1d').
219
220 initrd.img_load="YES"
221
222 initrd.img_type="md_image"
223
224 vfs.root.mountfrom="ufs:md0s0"
225
226 vfs.root.mountfrom="crypt:hammer:serno/SERIALNUMOFDISK.s1d:root"
227
228 dm_load="YES"
229
230 dm_target_crypt_load="YES"
231
232 Your "/etc/fstab" file should contain something like the below:
233
234 serno/SERIALNUMOFDISK.s1a    /boot           ufs     rw              1 1
235
236 /dev/mapper/root              /               hammer  rw              1 1
237
238 You can setup the encrypted swap via the "/etc/rc.local" file with the following lines:
239
240 cryptsetup luksOpen /dev/serno/SERIALNUMOFDISK.s1b swap
241 swapon /dev/mapper/swap
242