90b26003675ab02910f16afcd9c1bab85689c34f
[ikiwiki.git] / docs / newhandbook / environmentquickstart / index.mdwn
1 # DragonFly BSD Quick Start
2
3 This QuickStart is part of the [[NewHandbook|/docs/newhandbook/]].
4
5 This document describes the DragonFly environment one will find on a newly installed system.  While you are getting started please pay careful attention to the version or level of DragonFly that the documentation was written for.  Some documentation on this site may be out of date. Watch for the marker `(obsolete)` on items that are out of date or need updating.
6
7
8 [[!toc levels=3 ]]
9 ## Some Unix and BSD Fundamentals
10
11 If you have used another Unix flavor, another BSD or Linux before, you may need to spend some time learning basic subjects.  If you have never used any flavor of Unix, BSD or otherwise, and have only used Windows before, please be prepared for a lengthy period of learning.
12
13 If you already know your way around a Unix filesystem, and already know what the `/etc` folder is, how to use `vi` or `vim` to edit a file, how to use a shell like `tcsh` or `bash`, how to configure that shell, or change what shell you're using, how `su` and `sudo` work, and what a `root` account is, then you may get a lot farther in using any BSD variant (like Dragonfly BSD) then the rest of this page may be enough to orient you to your surroundings.
14
15 You should understand everything in the [[Unix Basics|/docs/newhandbook/UnixBasics/]] section before you proceed with trying to use your new system.
16
17
18 ## Disk layout of a New Dragonfly BSD System using the HAMMER filesystem
19
20 If you chose to install on the HAMMER file system during installation you will be left with a system with the following disk configuration:
21
22     # df -h
23     Filesystem                Size   Used  Avail Capacity  Mounted on
24     ROOT                      288G    12G   276G     4%    /
25     devfs                     1.0K   1.0K     0B   100%    /dev
26     /dev/serno/9VMBWDM1.s1a   756M   138M   558M    20%    /boot
27     /pfs/@@-1:00001           288G    12G   276G     4%    /var
28     /pfs/@@-1:00002           288G    12G   276G     4%    /tmp
29     /pfs/@@-1:00003           288G    12G   276G     4%    /usr
30     /pfs/@@-1:00004           288G    12G   276G     4%    /home
31     /pfs/@@-1:00005           288G    12G   276G     4%    /usr/obj
32     /pfs/@@-1:00006           288G    12G   276G     4%    /var/crash
33     /pfs/@@-1:00007           288G    12G   276G     4%    /var/tmp
34     procfs                    4.0K   4.0K     0B   100%    /proc
35
36 In this example
37
38 * `/dev/serno/9VMBWDM1` is the hard disk specified with serial number,
39 * `/dev/serno/9VMBWDM1.s1` is the first slice on the hard disk.
40
41 The disklabel looks at follows
42
43     # disklabel /dev/serno/9VMBWDM1.s1
44
45     # /dev/serno/9VMBWDM1.s1:
46     #
47     # Informational fields calculated from the above
48     # All byte equivalent offsets must be aligned
49     #
50     # boot space:    1044992 bytes
51     # data space:  312567643 blocks # 305241.84 MB (320069266944 bytes)
52     #
53     # NOTE: If the partition data base looks odd it may be
54     #       physically aligned instead of slice-aligned
55     #
56     diskid: e67030af-d2af-11df-b588-01138fad54f5
57     label:
58     boot2 data base:      0x000000001000
59     partitions data base: 0x000000100200
60     partitions data stop: 0x004a85ad7000
61     backup label:         0x004a85ad7000
62     total size:           0x004a85ad8200    # 305242.84 MB
63     alignment: 4096
64     display block size: 1024        # for partition display only
65
66     16 partitions:
67     #          size     offset    fstype   fsuuid
68       a:     786432          0    4.2BSD    #     768.000MB
69       b:    8388608     786432      swap    #    8192.000MB
70       d:  303392600    9175040    HAMMER    #  296281.836MB
71       a-stor_uuid: eb1c8aac-d2af-11df-b588-01138fad54f5
72       b-stor_uuid: eb1c8aec-d2af-11df-b588-01138fad54f5
73       d-stor_uuid: eb1c8b21-d2af-11df-b588-01138fad54f5
74
75
76 The slice has 3 partitions:
77
78 * `a` - for `/boot`
79 * `b` - for swap
80 * `d` - for `/`, a HAMMER file system labeled ROOT
81
82 When you create a HAMMER file system you must give it a label, here the installer labeled it as "ROOT" and mounted it as
83
84     ROOT                      288G    12G   276G     4%    /
85
86 A PFS is a Pseudo File System inside a HAMMER file system. The HAMMER file system in which the PFSes are created is referred to as the root file system. You should not confuse the "root" file system with the Label "ROOT", the label can be anything. It is just that the installer labeled it as ROOT because it is mounted as `/`.
87
88 Now inside the ROOT HAMMER file system you find the installed created 7 PFSes from the `df -h` output above, let us see how they are mounted in `/etc/fstab`:
89
90     # cat /etc/fstab
91
92     # Device                Mountpoint      FStype  Options         Dump    Pass#
93     /dev/serno/9VMBWDM1.s1a         /boot           ufs     rw      1       1
94     /dev/serno/9VMBWDM1.s1b         none            swap    sw      0       0
95     /dev/serno/9VMBWDM1.s1d         /               hammer  rw      1       1
96     /pfs/var                /var            null    rw              0       0
97     /pfs/tmp                /tmp            null    rw              0       0
98     /pfs/usr                /usr            null    rw              0       0
99     /pfs/home               /home           null    rw              0       0
100     /pfs/usr.obj    /usr/obj                null    rw              0       0
101     /pfs/var.crash  /var/crash              null    rw              0       0
102     /pfs/var.tmp    /var/tmp                null    rw              0       0
103     proc                    /proc           procfs  rw              0       0
104
105
106 The PFSes are mounted using a NULL mount because they are also HAMMER file systems. You can read more on NULL mounts here [mount_null(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=mount_null&section=8).
107
108 You don't need to specify a size for the PFSes like you do for logical volumes inside a volume group for LVM. All the free space in the root HAMMER file system is available to all the PFSs. That is the reason in the `df -h` output above you saw free space is same for all PFSes and the root HAMMER file system.
109
110 Now if you look in `/var`
111
112     # cd /var/
113     # ls
114     account   backups   caps   cron    empty   log   msgs   run   spool   yp  at        
115     cache     crash     db     games   lib     mail  preserve   rwho  tmp
116
117 you will find the above directories.
118
119 If you look at the status of one of the PFSes, e.g. `/usr` you will see `/var/hammer` is the default snapshot directory.
120
121     # hammer pfs-status /usr/
122     /usr/   PFS #3 {
123         sync-beg-tid=0x0000000000000001
124         sync-end-tid=0x0000000117ac6270
125         shared-uuid=f33e318e-d2af-11df-b588-01138fad54f5
126         unique-uuid=f33e31cb-d2af-11df-b588-01138fad54f5
127         label=""
128         prune-min=00:00:00
129         operating as a MASTER
130         snapshots directory defaults to /var/hammer/<pfs>
131     }
132
133 There is no "hammer" directory in `/var` now. That is because no snapshots are yet taken. You can verify this by checking the snapshots available for `/usr`
134
135     # hammer snapls /usr
136     Snapshots on /usr       PFS #3
137     Transaction ID          Timestamp               Note
138
139 Snapshots will appear automatically each night as the system performs housekeeping on the Hammer filesystem.  For a new volume, an immediate snapshot can be taken by running the command 'hammer cleanup'.  Among other activites, it will take a snapshot of the filesystem.
140
141     # sudo hammer cleanup
142     cleanup /                    - HAMMER UPGRADE: Creating snapshots
143             Creating snapshots in /var/hammer/root
144      handle PFS #0 using /var/hammer/root
145                snapshots - run
146                    prune - run
147                rebalance - run..
148                  reblock - run....
149                   recopy - run....
150     cleanup /var                 - HAMMER UPGRADE: Creating snapshots
151     [...]
152     cleanup /tmp                 - HAMMER UPGRADE: Creating snapshots
153     [...]
154     cleanup /usr                 - HAMMER UPGRADE: Creating snapshots
155     [...]
156     cleanup /home                - HAMMER UPGRADE: Creating snapshots
157     [...]
158     cleanup /usr/obj             - HAMMER UPGRADE: Creating snapshots
159     [...]
160     cleanup /var/crash           - HAMMER UPGRADE: Creating snapshots
161     [...]
162     cleanup /var/tmp             - HAMMER UPGRADE: Creating snapshots
163     [...]
164     cleanup /var/isos            - HAMMER UPGRADE: Creating snapshots
165     [...]
166
167 No snapshots were taken for `/tmp`, `/usr/obj` and `/var/tmp`. This is because the PFSes are flagged as `nohistory`. HAMMER tracks history for all files in a PFS, naturally this consumes disk space until the history is pruned. To prevent that temporary files on the mentioned PFSes (e.g., object files, crash dumps) consume disk space, the PFSes are marked as `nohistory`.
168
169 In `/var` will be a new directory called *hammer* with the following sub directories
170
171
172     # cd hammer/
173     # ls -l
174     total 0
175     drwxr-xr-x  1 root  wheel  0 Oct 13 11:51 home
176     drwxr-xr-x  1 root  wheel  0 Oct 13 11:42 root
177     drwxr-xr-x  1 root  wheel  0 Oct 13 11:43 tmp
178     drwxr-xr-x  1 root  wheel  0 Oct 13 11:51 usr
179     drwxr-xr-x  1 root  wheel  0 Oct 13 11:54 var
180
181
182 Well let us look inside `/var/hammer/usr`
183
184
185     # cd usr/
186     # ls -l
187     total 0
188     drwxr-xr-x  1 root  wheel   0 Oct 13 11:54 obj
189     lrwxr-xr-x  1 root  wheel  25 Oct 13 11:43 snap-20101013-1143 -> /usr/@@0x0000000117ac6cb0
190
191
192 We have a symlink pointing to the snapshot transaction ID shown below.
193
194
195     # hammer snapls /usr
196     Snapshots on /usr       PFS #3
197     Transaction ID          Timestamp               Note
198     0x0000000117ac6cb0      2010-10-13 11:43:04 IST -
199     #
200
201
202 You can read more about snapshots, prune, reblance, reblock, recopy etc from [hammer(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=hammer&section=8) especially look under the heading "cleanup [filesystem ...]"
203
204 You can learn more about PFS mirroring [here](http://www.dragonflybsd.org/docs/how_to_implement_hammer_pseudo_file_system__40___pfs___41___slave_mirroring_from_pfs_master/)
205
206 In order to correctly map hard disk sernos to device names you can use the 'devattr' command.
207
208     # udevd
209     # devattr -d "ad*" -p serno
210     Device ad4:
211             serno = Z2AD9WN4
212     Device ad4s1:
213     Device ad4s1d:
214
215     Device ad5:
216             serno = 9VMRFDSY
217     Device ad5s1:
218     Device ad5s1d:
219
220     Device ad3:
221             serno = Z2AD9WLW
222     Device ad3s1:
223     Device ad3s1a:
224     Device ad3s1b:
225     Device ad3s1d:
226
227 Or if your disks are 'da', just change it as appropiate.
228
229 ## Configuring and Starting the SSH Server
230
231 Described in detail [[here|/docs/newhandbook/sshserver/]]
232
233 ## Software/Programs and Configuration Files Location 
234
235 DragonFly default installation contains the base software/programs from the DragonFly project itself and few other software from [pkgsrc](http://www.netbsd.org/docs/software/packages.html) which is the DragonFly official package management system. Ready to install binary software from pkgsrc is referred to as *packages*.
236
237 The base programs are located in the folders 
238
239     /bin    /sbin
240     /usr/bin   /usr/sbin
241
242 The configuration files for the base system can be found in `/etc`. There is also `/usr/local/etc` which is used by third-party programs. The software/programs from pkgsrc are located in `/usr/pkg/bin` and `/usr/pkg/sbin`. Their configuration files are found in `/usr/pkg/etc`.
243
244 ## Installing Third-party Software
245
246 Have a look at the [[dports howto|/docs/howtos/HowToDPorts/]] for an in-depth description about dealing with packaging systems. Note that DragonFly BSD has several older package managers (like `pkgin`), but that the most modern binary package installation system as of 2014, is `pkg`.
247
248 ### Using pkg
249
250 Read [[dports howto|/docs/howtos/HowToDPorts/]] then for some errata, read [[this|http://lists.dragonflybsd.org/pipermail/users/2013-November/090339.html]].
251
252
253 You can look at the help and the man page for the pkg tool like this:
254
255 `pkg help install`
256
257 Example: Read man page for pkg-install
258
259 `man pkg-install`
260
261
262 ### Installing an X desktop environment
263
264 If it's already on your system run X by typing `startx`. If it's not, install
265 it using `pkg install`.
266
267 `(obsolete)`
268 Slightly out of date instructions on installing a GUI (X desktop) environment  are in the [new handbook](http://www.dragonflybsd.org/docs/newhandbook/X/).
269