(no commit message)
[ikiwiki.git] / docs / howtos / howto_reinstall_hammer / index.mdwn
1 *** THIS GUIDE IS INCOMPLETE ***
2
3 [[!toc]]
4 # Scenario
5 I have got a 250GB SATA harddisk with DragonFlyBSD 2.3.2 32-bit installed on it. 
6
7 Actually I want to repartition my harddisk in order to install other OSes besides DragonFly, so for that I need to shrink the current installation size. Above all, I would like my system just like it is now.
8
9 Although several methods could be used, as this is a HAMMER installation, I'm going to use HAMMERS's mirror-{read,write} capabilities.
10 This assumes you cannot store the PFSs in another HAMMER disk so that you have to store physical data compressed in files that can be put in any share you have.  
11 Here I will be using a NFS share.
12
13 # Pre-steps
14 ## HAMMER version
15 You should check that your HAMMER version is at least 2 (NORM    2.3 - New directory entry layout).
16
17     smash64# hammer version /
18     min=1 wip=3 max=2 current=2 description="2.3 - New directory entry layout"
19     available versions:
20         1   NORM    2.0 - First HAMMER release
21         2   NORM    2.3 - New directory entry layout
22
23 If not, you would have to use hammer version-upgrade. See [hammer(8)](http://leaf.dragonflybsd.org/cgi/web-man?command=hammer&section=8) for details.
24
25 ## LiveCD
26 You will need a DragonFlyBSD LiveCD in order to perform steps for the new installation. Release 2.4.0 or later is recommended.
27 Download the ISOs from [here](http://www.dragonflybsd.org/mirrors/).
28
29 ## /boot partition
30
31 Note that if your /boot is out of the ROOT HAMMER filesystem, you should copy the data also, so you can restore your current kernel in the new installation. Having kernel and world out of sync can be a problem sometimes. You have been warned.
32
33 # Data backup
34 At this point you should have a place ready to store all the compressed files you are going to generate.
35 In our case:
36
37     smash64# df -h /mnt/pfs
38     Filesystem                 Size   Used  Avail Capacity  Mounted on
39     dualsmash:/home/data/pfs   364G   235G   111G    68%    /mnt/pfs
40     smash64#
41
42 So we can start saving all our data:
43     
44     smash64# cd /mnt/pfs
45
46     smash64# hammer mirror-read / | gzip -3 -c > root.gz
47     histogram range 0000000000000000 - 000000129a02c4b0
48     Mirror-read: Mirror from 0000000000000000 to 000000129a02c4b0
49     smash64#
50
51     smash64# hammer mirror-read /var | gzip -3 -c > var.gz
52     histogram range 0000000000000001 - 000000129a02c4f0
53     Mirror-read: Mirror from 0000000000000001 to 000000129a02c4f0
54     Mirror-read /var succeeded
55     smash64#
56
57     smash64# hammer mirror-read /tmp | gzip -3 -c > tmp.gz
58     histogram range 0000000000000001 - 000000129a02c790
59     Mirror-read: Mirror from 0000000000000001 to 000000129a02c790
60     Mirror-read /tmp succeeded
61     smash64#
62     
63     [....]
64
65 Make sure the shared storage you have used is available for the LiveCD.
66
67 # New installation process
68
69 ## Booting LiveCD
70
71 Boot the LiveCD in the machine you want to install. 
72 You can run installer in order to do some basic configurations for the LiveCD environment, under option "LiveCD utilities", and then exit again to the shell.
73
74 ## Backup data accesibility
75
76 Prepare the share where you have the backup data:
77     # mkdir /root/pfs
78     # mount 192.168.3.1:/home/data/pfs /root/pfs
79     # df -h /root/pfs
80     Filesystem                   Size   Used  Avail Capacity  Mounted on
81     192.168.3.1:/home/data/pfs   364G   247G    98G    72%    /root/pfs
82
83 ## Creating disk layout
84 This part is critical. With this you will lose all the data on the disk you have chosen.
85
86 **Warning: You are discouraged to use fdisk. Use another partition utility while you can **
87
88 Initalize the disk and partition it. After that, you will have to manually partition your disk, and with fdisk can be no fun.
89
90     # fdisk -BI ad4
91     # fdisk -i
92
93     ( this is only an extract )
94
95     [....]
96
97     Do you want to change our idea of what BIOS thinks ? [n] 
98     Media sector size is 512
99     Warning: BIOS sector numbering starts with sector 1
100     Information from DOS bootblock is:
101     The data for partition 1 is:
102     sysid 165,(DragonFly/FreeBSD/NetBSD/386BSD)
103         start 63, size 148990401 (72749 Meg), flag 0
104             beg: cyl 0/ head 1/ sector 1;
105             end: cyl 1023/ head 255/ sector 63
106     Do you want to change it? [n] y
107     Supply a decimal value for "sysid (165=DragonFly)" [0] 165
108     Supply a decimal value for "start" [0] 63
109     Supply a decimal value for "size" [0] 148990401
110     Explicitly specify beg/end address ? [n] 
111     Warning: ending cylinder wraps, using all 1's
112     sysid 165,(DragonFly/FreeBSD/NetBSD/386BSD)
113         start 63, size 148990401 (72749 Meg), flag 0
114             beg: cyl 0/ head 1/ sector 1;
115             end: cyl 1023/ head 255/ sector 63
116     Are we happy with this entry? [n] y
117     Do you want to change the active partition? [n] y
118     Supply a decimal value for "active partition" [1] 1
119     Are you happy with this choice [n] y
120
121     [....]
122
123     Information from DOS bootblock is:
124     1: sysid 165,(DragonFly/FreeBSD/NetBSD/386BSD)
125         start 63, size 148990401 (72749 Meg), flag 80 (active)
126             beg: cyl 0/ head 1/ sector 1;
127             end: cyl 1023/ head 255/ sector 63
128     2: <UNUSED>
129     3: <UNUSED>
130     4: <UNUSED>
131     Should we write new partition table? [n] y
132
133 Now that we have the partition, we can create the slices for our new installation.
134
135 As of now, the recommended configuration is ***/boot*** on UFS and ***/*** can be HAMMER.
136
137 So you do:
138     # disklabel64 -r -w ad4s1 auto
139     # disklabel64 -e ad4s1
140
141     (do the layout you want)
142     
143     # disklabel64 ad4s1
144     #          size     offset    fstype   fsuuid
145       a:     262144          0    4.2BSD    #     256.000MB
146       b:    1048576     262144      swap    #    1024.000MB
147       d:   73184440    1310720    HAMMER    #   71469.180MB
148
149 Finally, we create the filesystems:
150     
151     # newfs /dev/ad4s1a
152     /dev/ad4s1a: media size 256.00MB
153     Warning: Block size restricts cylinders per group to 94.
154     /dev/ad4s1a:    524288 sectors in 128 cylinders of 1 tracks, 4096 sectors
155             256.0MB in 2 cyl groups (94 c/g, 188.00MB/g, 16256 i/g)
156     super-block backups (for fsck -b #) at:
157      32, 385056
158     
159     # newfs_hammer -L ROOT /dev/ad4s1d
160     Volume 0 DEVICE /dev/ad4s1d     size  69.79GB
161     initialize freemap volume 0
162     ---------------------------------------------
163     1 volume total size  69.79GB version 2
164     boot-area-size:       64.00MB
165     memory-log-size:     256.00MB
166     undo-buffer-size:    104.00MB
167     total-pre-allocated: 120.00MB
168     fsid:                738615f8-a702-11de-8ec9-011617eff231
169
170     [....]
171
172 ## Prepare mount points
173
174 Now we setup the mount points where the data will actually be restored.
175
176 You will need 
177
178     # mkdir /root/target
179     # mount_hammer /dev/ad4s1d /root/target
180     # mkdir /root/target/boot
181     # mkdir /root/target/pfs
182     # mount /dev/ad4s1a /root/target/boot
183
184 You must create an intermediate slave PFS in order to restore / mount. PFS#0 cannot be downgraded to slave, so you have no choice here.
185 We create all the PFSs as slaves, and mount_null them.
186
187     # hammer pfs-slave /root/target/var
188     [....]
189     # hammer pfs-slave /root/target/usr
190     [....]
191     # hammer pfs-slave /root/target/tmp
192     [....]
193     # hammer pfs-slave /root/target/home
194     [....]
195     # cd /root/target && mv var usr tmp home pfs
196     # mkdir var usr tmp home
197
198     # hammer pfs-slave /root/target/var/tmp
199     [....]
200     # hammer pfs-slave /root/target/var/crash
201     [....]
202     # hammer pfs-slave /root/target/usr/obj
203     [....]
204     # hammer pfs-slave /root/target/rootcopy
205     Creating PFS #1 succeeded!
206     /root/target/rootcopy
207     [....]
208
209
210
211
212
213 # Restoring the data
214 # Fixing the configuration
215 # Booting
216
217
218