Correct "rebalance"
[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 flavour, another BSD, or Linux before, you may need to spend some time learning the differences between DragonFly and the system you are experienced in.  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, 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 ## Disk layout of a New Dragonfly BSD System using the HAMMER filesystem
18
19 If you chose to install on the HAMMER file system during installation you will be left with a system with the following disk configuration:
20
21     # df -h
22     Filesystem                Size   Used  Avail Capacity  Mounted on
23     ROOT                      288G    12G   276G     4%    /
24     devfs                     1.0K   1.0K     0B   100%    /dev
25     /dev/serno/9VMBWDM1.s1a   756M   138M   558M    20%    /boot
26     /pfs/@@-1:00001           288G    12G   276G     4%    /var
27     /pfs/@@-1:00002           288G    12G   276G     4%    /tmp
28     /pfs/@@-1:00003           288G    12G   276G     4%    /usr
29     /pfs/@@-1:00004           288G    12G   276G     4%    /home
30     /pfs/@@-1:00005           288G    12G   276G     4%    /usr/obj
31     /pfs/@@-1:00006           288G    12G   276G     4%    /var/crash
32     /pfs/@@-1:00007           288G    12G   276G     4%    /var/tmp
33     procfs                    4.0K   4.0K     0B   100%    /proc
34
35 In this example
36
37 * `/dev/serno/9VMBWDM1` is the hard disk specified with serial number,
38 * `/dev/serno/9VMBWDM1.s1` is the first slice on the hard disk.
39
40 The disk label looks as follows:
41
42     # disklabel /dev/serno/9VMBWDM1.s1
43
44     # /dev/serno/9VMBWDM1.s1:
45     #
46     # Informational fields calculated from the above
47     # All byte equivalent offsets must be aligned
48     #
49     # boot space:    1044992 bytes
50     # data space:  312567643 blocks # 305241.84 MB (320069266944 bytes)
51     #
52     # NOTE: If the partition data base looks odd it may be
53     #       physically aligned instead of slice-aligned
54     #
55     diskid: e67030af-d2af-11df-b588-01138fad54f5
56     label:
57     boot2 data base:      0x000000001000
58     partitions data base: 0x000000100200
59     partitions data stop: 0x004a85ad7000
60     backup label:         0x004a85ad7000
61     total size:           0x004a85ad8200    # 305242.84 MB
62     alignment: 4096
63     display block size: 1024        # for partition display only
64
65     16 partitions:
66     #          size     offset    fstype   fsuuid
67       a:     786432          0    4.2BSD    #     768.000MB
68       b:    8388608     786432      swap    #    8192.000MB
69       d:  303392600    9175040    HAMMER    #  296281.836MB
70       a-stor_uuid: eb1c8aac-d2af-11df-b588-01138fad54f5
71       b-stor_uuid: eb1c8aec-d2af-11df-b588-01138fad54f5
72       d-stor_uuid: eb1c8b21-d2af-11df-b588-01138fad54f5
73
74
75 The slice has 3 partitions:
76
77 * `a` - for `/boot`
78 * `b` - for swap
79 * `d` - for `/`, a HAMMER file system labeled ROOT
80
81 When you create a HAMMER file system, you must give it a label.  Here, the installer labelled it as "ROOT" and mounted it as
82
83     ROOT                      288G    12G   276G     4%    /
84
85 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. The installer labeled it as ROOT because it is mounted at `/`.
86
87 Now inside the root HAMMER file system you find the installer created 7 PFSes from the `df -h` output above, let us see how they are mounted in `/etc/fstab`:
88
89     # cat /etc/fstab
90
91     # Device                Mountpoint      FStype  Options         Dump    Pass#
92     /dev/serno/9VMBWDM1.s1a         /boot           ufs     rw      1       1
93     /dev/serno/9VMBWDM1.s1b         none            swap    sw      0       0
94     /dev/serno/9VMBWDM1.s1d         /               hammer  rw      1       1
95     /pfs/var                /var            null    rw              0       0
96     /pfs/tmp                /tmp            null    rw              0       0
97     /pfs/usr                /usr            null    rw              0       0
98     /pfs/home               /home           null    rw              0       0
99     /pfs/usr.obj    /usr/obj                null    rw              0       0
100     /pfs/var.crash  /var/crash              null    rw              0       0
101     /pfs/var.tmp    /var/tmp                null    rw              0       0
102     proc                    /proc           procfs  rw              0       0
103
104
105 The PFSes are mounted using a NULL mount because they are also HAMMER file systems. You can read more on NULL mounts at the [mount_null(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=mount_null&section=8) manpage.
106
107 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 PFSes; it can be seen in the `df -h` output above that the free space is the same for all PFSes and the root HAMMER file system.
108
109 If you look in `/var`
110
111     # cd /var/
112     # ls
113     account   backups   caps   cron    empty   log   msgs   run   spool   yp  at        
114     cache     crash     db     games   lib     mail  preserve   rwho  tmp
115
116 you will find the above directories.
117
118 If you look at the status of one of the PFSes, e.g. `/usr` you will see `/var/hammer` is the default snapshot directory.
119
120     # hammer pfs-status /usr/
121     /usr/   PFS #3 {
122         sync-beg-tid=0x0000000000000001
123         sync-end-tid=0x0000000117ac6270
124         shared-uuid=f33e318e-d2af-11df-b588-01138fad54f5
125         unique-uuid=f33e31cb-d2af-11df-b588-01138fad54f5
126         label=""
127         prune-min=00:00:00
128         operating as a MASTER
129         snapshots directory defaults to /var/hammer/<pfs>
130     }
131
132 At installation time, it will be seen that there is no `hammer` directory in `/var`. The reason for this is that no snapshots have yet been taken. You can verify this by checking the snapshots available for `/usr`
133
134     # hammer snapls /usr
135     Snapshots on /usr       PFS #3
136     Transaction ID          Timestamp               Note
137
138 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 activities, it will take a snapshot of the filesystem.
139
140     # sudo hammer cleanup
141     cleanup /                    - HAMMER UPGRADE: Creating snapshots
142             Creating snapshots in /var/hammer/root
143      handle PFS #0 using /var/hammer/root
144                snapshots - run
145                    prune - run
146                rebalance - run..
147                  reblock - run....
148                   recopy - run....
149     cleanup /var                 - HAMMER UPGRADE: Creating snapshots
150     [...]
151     cleanup /tmp                 - HAMMER UPGRADE: Creating snapshots
152     [...]
153     cleanup /usr                 - HAMMER UPGRADE: Creating snapshots
154     [...]
155     cleanup /home                - HAMMER UPGRADE: Creating snapshots
156     [...]
157     cleanup /usr/obj             - HAMMER UPGRADE: Creating snapshots
158     [...]
159     cleanup /var/crash           - HAMMER UPGRADE: Creating snapshots
160     [...]
161     cleanup /var/tmp             - HAMMER UPGRADE: Creating snapshots
162     [...]
163     cleanup /var/isos            - HAMMER UPGRADE: Creating snapshots
164     [...]
165
166 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  history is pruned, at which point the available disk space will stabilise. To prevent temporary files on the mentioned PFSes (e.g., object files, crash dumps) from consuming disk space, the PFSes are marked as `nohistory`.
167
168 After performing nightly housekeeping, a new directory called *hammer* will be found in `/var` with the following sub directories:
169
170     # cd hammer/
171     # ls -l
172     total 0
173     drwxr-xr-x  1 root  wheel  0 Oct 13 11:51 home
174     drwxr-xr-x  1 root  wheel  0 Oct 13 11:42 root
175     drwxr-xr-x  1 root  wheel  0 Oct 13 11:43 tmp
176     drwxr-xr-x  1 root  wheel  0 Oct 13 11:51 usr
177     drwxr-xr-x  1 root  wheel  0 Oct 13 11:54 var
178
179
180 Looking inside `/var/hammer/usr`, one finds:
181
182     # cd usr/
183     # ls -l
184     total 0
185     drwxr-xr-x  1 root  wheel   0 Oct 13 11:54 obj
186     lrwxr-xr-x  1 root  wheel  25 Oct 13 11:43 snap-20101013-1143 -> /usr/@@0x0000000117ac6cb0
187
188
189 We have a symlink pointing to the snapshot transaction ID shown below.
190
191     # hammer snapls /usr
192     Snapshots on /usr       PFS #3
193     Transaction ID          Timestamp               Note
194     0x0000000117ac6cb0      2010-10-13 11:43:04 IST -
195     #
196
197 You can read more about snapshots, prune, rebalance, reblock, recopy etc from [hammer(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=hammer&section=8).  Make especially sure to look under the heading "cleanup [filesystem ...]".
198
199 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/)
200
201 In order to correctly map hard disk sernos to device names you can use the 'devattr' command.
202
203     # udevd
204     # devattr -d "ad*" -p serno
205     Device ad4:
206             serno = Z2AD9WN4
207     Device ad4s1:
208     Device ad4s1d:
209
210     Device ad5:
211             serno = 9VMRFDSY
212     Device ad5s1:
213     Device ad5s1d:
214
215     Device ad3:
216             serno = Z2AD9WLW
217     Device ad3s1:
218     Device ad3s1a:
219     Device ad3s1b:
220     Device ad3s1d:
221
222 If your disks are 'da', change as appropriate.
223
224 ## Configuring and Starting the SSH Server
225
226 Described in detail [here](docs/newhandbook/Users/#index3h1)
227
228 ## Software/Programs and Configuration Files Location 
229
230 The DragonFly default installation contains the base software/programs from the DragonFly project itself and additional software from other sources. 
231
232 The base system binary software programs are located in the folders 
233
234     /bin    /sbin
235     /usr/bin   /usr/sbin
236
237 The configuration files for the base system can be found in `/etc`. Third-party programs use `/usr/local/etc`.
238
239 There are several different ways to install software and which version you use depends on which DragonFly BSD version you have.  You can compile things from source code, or you can use binary packages.