# FreeBSD 8.2 to 9.0 RELEASE + gmirror + custom kernel



## xy16644 (May 5, 2012)

Hello All

I want to upgrade my FreeBSD 8.2 RELEASE server to 9.0 RELEASE. I do run a custom kernel and I am running a mirrored disk setup with gmirror (from what I understand this can cause issues after the upgrade).

I have made a full backup of the server as follows:
[cmd=]dump -0aLf /tmp/backup.tar /dev/mirror/RootMirror4s1a[/cmd]

Do I need to do anything special before performing the upgrade due to my configuration?

I was going to run the following commands to do my upgrade:

```
freebsd-update upgrade -r 9.0-RELEASE

cd /usr/src

make KERNCONF=ALPHA kernel

freebsd-update install

shutdown -r now

freebsd-update install

shutdown -r now
```

I'm sure I' m missing something here. Do I need to do anything else to make sure my system will still boot up since I use gmirror? Or anything else in general I have missed?

Many thanks


----------



## wblock@ (May 5, 2012)

xy16644 said:
			
		

> I want to upgrade my FreeBSD 8.2 RELEASE server to 9.0 RELEASE. I do run a custom kernel and I am running a mirrored disk setup with gmirror (from what I understand this can cause issues after the upgrade).



If you followed the Handbook example to create a mirror in-place on an existing drive, expect problems.  There are workarounds.  The right way is a full backup, creating the mirror from scratch, then a restore to the mirror.  Mirrors created that way will work fine.



> I have made a full backup of the server as follows:
> 
> ```
> dump -0aLf /tmp/backup.tar /dev/mirror/RootMirror4s1a
> ```



1. Giving dump(8) files a ".tar" extension will cause regret later.
2. Probably that is not a full backup.  s1a is usually just the / filesystem.  Remember that dump(8) does not cross filesystems.  See Backup Options For FreeBSD for examples.



> Do I need to do anything special before performing the upgrade due to my configuration?



Do a full backup (or several) and restore it to another drive.  Test that drive, make sure all the files are there and correct.  Then do the upgrade.


----------



## xy16644 (May 5, 2012)

wblock@ said:
			
		

> If you followed the Handbook example to create a mirror in-place on an existing drive, expect problems.  There are workarounds.  The right way is a full backup, creating the mirror from scratch, then a restore to the mirror.  Mirrors created that way will work fine.
> 
> 
> 
> ...



Thats got me a bit scared! 

I can't remember where I read about how to create the disk mirror using gmirror but I did document the steps I did:

```
Ensure:
echo geom_mirror_load="YES" > /boot/loader.conf
Create /etc/fstab-mirror as follows:
/dev/mirror/RootMirror4s1b              none            swap    sw              0       0
/dev/mirror/RootMirror4s1a              /               ufs     rw              1       1
/dev/acd0               /cdrom          cd9660  ro,noauto       0       0

Boot into single user mode and then run the following commands:

mount -a

cp /etc/fstab /etc/fstab-nomirror

cp /etc/fstab-mirror /etc/fstab

sysctl kern.geom.debugflags=16

gmirror label -v RootMirror4 /dev/ad4

Reboot in multi user mode and run:

gmirror insert RootMirror4 /dev/ad6
```
(sorry if this comes out a bit messy)

Are you saying that the way I am using dump currently is not correct for having a full backup of the system? Currently I am using about 16GB on the server and when the dump command I posted previously is complete the tar file is about 11.5GB in size.

So I assume I need to get the dump backup command correct first to do a FULL backup of the system and then I need to restore it to a test (maybe VM) server and do a restore? Then do the upgrade?


----------



## wblock@ (May 5, 2012)

For a single filesystem layout like that, that dump is adequate (but testing is still required).  Verifying it in a VM is not a bad idea.  Better yet, a VM gives the opportunity to rehearse and document the steps so doing it for real is quicker and easier.

The steps don't say whether ad4 already had data on it.  gmirror(8) needs one block for metadata at the end of the drive or partition.  If the drive or partition is already full with a filesystem, that procedure turns off the safety with the sysctl.  Then the mirror metadata can be written to the last block, which (probably) does not contain filesystem data.

When the newer geom code sees that problem, one geom (the mirror) inside the boundaries of another (the original partition), it complains and does not boot.

So again, the right way to do this:

1.  Back up all data.  Verify it.  Back it up again to other media, and verify that, too.
2.  Create the mirror from scratch.  Do not use kern.geom.debugflags, because it will not be needed.  This will wipe out all data on the mirror drives!
`# gmirror label mymirror0 ad4 ad6`
3.  Set up MBR slices and FreeBSD partitions on the mirror.  Remember to make it bootable (Disk Setup On FreeBSD) and load the geom_mirrormodule.  (Another option is to mirror partitions.  See gmirror With Disk Partitions, but be aware of the downsides.)
4.  Restore backup to the mirror.


----------



## xy16644 (May 5, 2012)

I am busy installing VirtualBox on my laptop now to experiment with.

A bit of background (which may answer some of your questions). When I initially built the FreeBSD server it was on a single 80GB drive. It was only later on that I added a second drive and then mirrored it. So I think the answer to your question is yes in that ad4 did have data on it before mirroring.

I have never done a full system restore before using my dump backup file...is this fairly straight forward?

This is quite overwhelming. Let me just break it down into steps to make sure I fully understand it all:

1) Install FreeBSD 8.2 into VM with one disk (I assume)

2) Restore system from dump tar file

3) Setup disk mirroring (not sure which comes first...step 2 or 3)

NB: In theory, at this stage, my VM should match my live server

4) Break the mirror and recreate from scratch

5) Upgrade to FreeBSD 9

I'm not 100% sure of all the commands etc at this stage. I just want to understand the steps involved first to make sure I get the logic behind it all.


----------



## wblock@ (May 5, 2012)

1. Boot VM with mfsBSD.
2. Create mirror.  For a test system, a one-disk mirror would be adequate.  Use two disks when you do it for real.
3. fdisk/bsdlabel mirror.
4. Restore backup onto mirror.
5. Test VM.
6. Upgrade VM to FreeBSD 9.
7. Test VM.


----------



## xy16644 (May 6, 2012)

wblock@ said:
			
		

> 1. Boot VM with mfsBSD.
> 2. Create mirror.  For a test system, a one-disk mirror would be adequate.  Use two disks when you do it for real.
> 3. fdisk/bsdlabel mirror.
> 4. Restore backup onto mirror.
> ...



I didn't get very far with this last night. My VM in VirtualBox kept crashing. So it got me thinking, what are my options to get my system from 8.2 to 9.0:

1) Remove one of the disks from the gmirror (RAID1). Do the upgrade (on the remaining disk) and hope for the best. If it fails troubleshoot. If all else fails, remove the disk with the failed upgrade on it and put the second disk back in with 8.2 on it.

2) Build a new server with FreeBSD 9.0 RELEASE and do a full restore from my dump file (is this possible considering I'll be going from FreeBSD 8.2 to 9.0?) I don't have the hardware for this option unfortunately right now.

3) Clone/image the current system and the do the upgrade. If it fails revert back to a (working tested) copy

I'm not sure if my thinking is correct regarding this. 

Would my upgrade to 9.0 be easier if I didn't have the system mirrored using gmirror in RAID1? ie: would the upgrade work 100% if I was running the server on a single disk?

Thanks for all the help. This is the toughest upgrade I have done yet.


----------



## wblock@ (May 7, 2012)

The only difference in setup is the mirror, otherwise it's no harder and no less reliable.

Make certain you have the latest VirtualBox, and that it's using PIIX4 for the hard drive controller.

If you install FreeBSD 9 and then restore over it, you'll have FreeBSD 8 again.  Unless you only restore user information, not operating system and applications.


----------



## xy16644 (May 7, 2012)

Ok, so what about breaking the mirror? If the 8.2 system has no gmirror RAID 1 on it (ie: single bootable disk), would that simplify things and enable me to perform the upgrade to 9.0?


----------



## wblock@ (May 8, 2012)

Why break the existing mirror?  Set up two virtual drives in VirtualBox, or use a scratch drive if you want to do it on real hardware.

The only difference with the mirror rather than a single disk is that you have to create it first and use the mirror device names instead of raw disk names.


----------



## xy16644 (May 8, 2012)

wblock@ said:
			
		

> Why break the existing mirror?  Set up two virtual drives in VirtualBox, or use a scratch drive if you want to do it on real hardware.
> 
> The only difference with the mirror rather than a single disk is that you have to create it first and use the mirror device names instead of raw disk names.



I have managed to find a physical machine that is indentical to the one I currently have FreeBSD 8.2 installed on. It even has two hard drives of the same capacity.

So how does this sound:

Install FreeBSD 8.2 on identical machine with two hard drives
Copy dump backup file onto newly built machine
Run full restore on newly built machine (at this stage the newly built machine should have the same config as my current live server)
Update FreeBSD 8.2 to 9 on test machine - test/check that all is working


----------



## xy16644 (May 12, 2012)

I have installed FreeBSD 8.2 RELEASE on a machine that is indentical to what my production machine is. It has two drives that are the same capacity as my production server.

What I did after installing FreeBSD 8.2 was to mount the second drive as /mnt/seconddrive. I then ran the following while in /mnt/seconddrive:
[cmd=]restore -rf /tmp/restore.tar[/cmd]

After it finished running I can see ALL my data on this second drive as it is on my live server.

I then powered down the server and removed the drive I had installed FreeBSD 8.2 on and rebooted.

I now have the following error:

```
FreeBSD/x86 boot
Default: 0:ad(0,a)/boot/kernel/kernel
```

I have read a bit about this but I still can't get the newly restored drive to boot. I have tried editing the /etc/fstab file and tried the bsdlabel command but I have not had any luck with it. I also tried making the drive bootable from sysinstall but that didn't work either. 

Any ideas please? I am well stuck! :e

Once I can get this drive to boot I can perform the upgrade to FreeBSD 9.0 RELEASE as a test.


----------



## wblock@ (May 16, 2012)

Most likely you restored the old /etc/fstab over the one that was installed.  That's a problem with brute-force restores.  It can be avoided by using labels.

Let me point out one more time that giving dump files a ".tar" extension will cause you pain, sooner or later.


----------



## xy16644 (May 19, 2012)

wblock@ said:
			
		

> Most likely you restored the old /etc/fstab over the one that was installed.  That's a problem with brute-force restores.  It can be avoided by using labels.
> 
> Let me point out one more time that giving dump files a ".tar" extension will cause you pain, sooner or later.



Hi Wblock, thanks for the reply :e

I have taken your advice and stopped using .tar extensions for my backups. I now use .dump. Thank you for pointing that out to me.

I also had a read through that link you provided that explains labels. These seem very useful. Couple of questions though:

1) How do I go about using these on a mirrored (RAID1) system using gmirror? 

Currently my /etc/fstab looks like this:

```
/dev/mirror/RootMirror4s1b              none            swap    sw              0       0
/dev/mirror/RootMirror4s1a              /               ufs     rw              1       1
```

and if I run a:
[cmd=]gmirror status[/cmd]
I get this:

```
mirror/RootMirror4  COMPLETE  ad4
                              ad6
```

2) If I go ahead and make these changes with labels, does this mean I will be able to successfully upgrade from 8.2 to 9.0 and not experience the boot problems that most people do with gmirror?

Thanks again.


----------



## wblock@ (May 19, 2012)

> 1) How do I go about using these on a mirrored (RAID1) system using gmirror?



Filesystem or glabel(8) labels show up whenever a disk is attached.  They can be used in /etc/fstab instead of absolute device names.  So the fstab shown above would be

```
/dev/label/mswap              none            swap    sw              0       0
/dev/ufs/mrootfs              /               ufs     rw              1       1
```

That's if glabel(8) was used to assign the name mswap to the swap partition, and tunefs(8) was used to assign mrootfs to the UFS filesystem.  These would work regardless of whether there were other labels or other mirrors.



> 2) If I go ahead and make these changes with labels, does this mean I will be able to successfully upgrade from 8.2 to 9.0 and not experience the boot problems that most people do with gmirror?



No, unfortunately that is a different problem, where the mirror and filesystem areas overlap.  If the mirror was created as shown in the Handbook, where a drive was added to an existing one with the kern.geom.debugflags workaround, the areas overlap and FreeBSD 9 will refuse to boot.  The right way to fix those is to back up everything, then boot with mfsBSD or the FreeBSD 9.0 install CD, go to a shell, and create the mirror from scratch.  The workaround is not necessary and the mirror will be correct.  Restore all the data to it, then use normally.


----------



## xy16644 (May 19, 2012)

wblock@ said:
			
		

> No, unfortunately that is a different problem, where the mirror and filesystem areas overlap.  If the mirror was created as shown in the Handbook, where a drive was added to an existing one with the kern.geom.debugflags workaround, the areas overlap and FreeBSD 9 will refuse to boot.  The right way to fix those is to back up everything, then boot with mfsBSD or the FreeBSD 9.0 install CD, go to a shell, and create the mirror from scratch.  The workaround is not necessary and the mirror will be correct.  Restore all the data to it, then use normally.



This is what has me nervous and unsure of how to proceed next. I created a fresh dump of my current live server and then did a restore on indentical hardware. It didn't boot after I completed the restore. Now I understand that is due to the disks having different names but I had to "hack" the /etc/fstab file to boot off ONE disk. I didn't have a mirrored pair after the restore. And to boot each time (after a reboot I had to enter:


```
0:ad(6,d)/boot/loader
ufs:ad6s1d
```

(took me ages to figure this out!)

Sorry for all the questions but if I had to break this down very simply step by step how would it look? This is the most tricky upgrade I have done and am not familiar with using mfsBSD.

1) Backup current live system with dump (using a .dump file extension!)

2) Boot with FreeBSD 9 DVD on live system into the shell

3) This is where I get lost. Must I format the drives and then recreate the mirror from scratch here? And also use labels to make things easier in the future?


----------



## wblock@ (May 19, 2012)

xy16644 said:
			
		

> This is what has me nervous and unsure of how to proceed next. I created a fresh dump of my current live server and then did a restore on indentical hardware. It didn't boot after I completed the restore. Now I understand that is due to the disks having different names but I had to "hack" the /etc/fstab file to boot off ONE disk. I didn't have a mirrored pair after the restore.



Right.  The system sees a mirror as a single drive.  Unless you create a mirror and restore onto it, you'll be back to one drive.



> And to boot each time (after a reboot I had to enter:
> 
> 
> ```
> ...



Labels will help with that.



> Sorry for all the questions but if I had to break this down very simply step by step how would it look? This is the most tricky upgrade I have done and am not familiar with using mfsBSD.



mfsBSD is just a convenient FreeBSD system that runs from memory.  It has all the standard FreeBSD commands.



> 1) Backup current live system with dump (using a .dump file extension!)



Yes.  Use *dump -C16 -b64 -0uanL*, and make sure you back up each filesystem.  There might be only one, or there might be /, /var, /tmp, and /usr.  Maybe others, like a separate /home.  Each has to be dumped separately, dump(8) does not cross filesystems.

Boot the system with mfsBSD or the FreeBSD 9 CD and create the mirror.  Then create the filesystems on it, and restore to those filesystems.  It's a lot safer to use new disks, because then the old disk can be disconnected and that data on it isn't endangered.


----------



## xy16644 (May 20, 2012)

wblock@ said:
			
		

> Yes.  Use *dump -C16 -b64 -0uanL*, and make sure you back up each filesystem.  There might be only one, or there might be /, /var, /tmp, and /usr.  Maybe others, like a separate /home.  Each has to be dumped separately, dump(8) does not cross filesystems.



I have created a new dump of the system using:
[CMD=""]dump -C16 -b64 -0uanLf /tmp/TestRestore.dump /dev/mirror/RootMIrror4s1a[/CMD]

At this time, there is only one filesystem and that is for root (/).



			
				wblock@ said:
			
		

> Boot the system with mfsBSD or the FreeBSD 9 CD and create the mirror.  Then create the filesystems on it, and restore to those filesystems.  It's a lot safer to use new disks, because then the old disk can be disconnected and that data on it isn't endangered.



This is the bit I need some help on. Let*'*s assume I do this on my test machine that has identical hardware. Let*'*s also assume that both disks in the test machine are empty/formatted.

Once I have booted off the FreeBSD 9 DVD, do I do an install? Do I do an *fdisk*? Do I go into the shell and create the mirror? Surely if I do a full restore of my system once the mirror is created it'll roll back to 8.2? Shouldn't I boot off the 8.2 DVD rather? Am I doing a basic install of 8.2, mirroring it and then restoring over it?

I understand that I need to create a new mirror and then do a restore using my dump file but I am battling to grasp the exact steps needed to achieve this. I am happy to try anything on the test machine :e


----------



## wblock@ (May 20, 2012)

As the Perl people would say, TMTOWTDI.

I'd get the 8.2 system onto a properly-created mirror and then use a source upgrade to get to 9-stable.  The 9.0 install CD would be used just to provide live CD to create the mirror and restore to it.

Boot with the 9.0 install CD.
Select Shell.
Use glabel(8) to label the two disks.  (Same as filesystem labels, these provide a static label that always refers to a single disk.)
Create the mirror with the two disks, using the labels instead of device names:
`# gmirror label -v mymirror0 /dev/label/mirrordisk0 /dev/label/mirrordisk1`
Use gpart(8) to create an MBR, make it bootable, then create bsdlabel "partitions" on the mirror, just one in this case.  (Note: gpart(8) does everything fdisk(8) and bsdlabel(8) did, plus a lot more.)
glabel(8) the swap area to give it a name.
newfs(8) the filesystem, giving it a filesystem label at the same time.
mount(8) the empty filesystem on /mnt.
cd to /mnt and restore(8) the backup.
While it's still mounted, edit /mnt/etc/fstab to use the filesystem and swap label.
Reboot and check that it comes up.  Then verify all the data is there.

After that, update source to FreeBSD 9.0-RELEASE or 9.0-STABLE, buildworld, kernel, installworld, mergemaster -Ui, reboot.  Because the mirror was created right, FreeBSD 9 won't have a problem with it.


----------



## xy16644 (May 20, 2012)

Many thanks for this! I shall be giving this a try and reporting back as to how it goes. I will list the commands in the order I try them. This may be useful for other forum members.


----------



## xy16644 (May 23, 2012)

When I have restored my system, can I use the FreeBSD 9 DVD to perform the upgrade instead of using the following method:
[CMD=]freebsd-update upgrade -r 9.0-RELEASE[/cmd]

Also, you mentioned upgrading to FreeBSD 9 STABLE. I am running 8.2 RELEASE with a custom kernel. Will this cause any issues?


----------



## wblock@ (May 23, 2012)

xy16644 said:
			
		

> When I have restored my system, can I use the FreeBSD 9 DVD to perform the upgrade instead of using the following method:
> [CMD="freebsd-update upgrade -r 9.0-RELEASE"]#[/CMD]



I have never tried it, but have no reason to think it wouldn't work.



> Also, you mentioned upgrading to FreeBSD 9 STABLE. I am running 8.2 RELEASE with a custom kernel. Will this cause any issues?



Not really, although I think it means that freebsd-update(8) can't be used.  And it may be necessary to adjust the kernel config file for differences in FreeBSD 9.
Simplifying FreeBSD Kernel Config Files
Upgrading FreeBSD To -STABLE


----------



## xy16644 (May 23, 2012)

The only reason I want to use the DVD to perform the upgrade is because once I restore the system, it'll have the same IP as my live server. I don't want to change the IP on the freshly restored server so as to keep things "like for like" which means it can't be connected to my network.

Do I just mount the DVD and run *sysinstall* to perform the upgrade?

I think I am going to stick with the FreeBSD 9.0 RELEASE version for now.


----------



## wblock@ (May 23, 2012)

IP address will be an issue regardless of whether it's 8.2, 9.0-RELEASE, or 9-STABLE.  Unless you mean that the machine would not need to be connected to the net at all if you upgrade from the DVD.  Save that until after the mirror conversion is complete.

Then comment the ifconfig line in /etc/rc.conf, add another to temporarily use DHCP, and do the 8.x to 9.x upgrade.  That is probably desirable to be able to test network services on the updated machine anyway.


----------



## xy16644 (May 23, 2012)

I realise that the version I upgrade to has nothing to do with the IP address issue. What I meant to say was, I need to keep the restored machine disconnected from the LAN which means that I won't have any internet access. I thought the workaround could be to just use the DVD to perform the upgrade. I don't mind changing the IP address AFTER the upgrade to 9.0.

So the steps (I think) will be (while the NIC is not connected to the netowork):

Rebuild mirror
Restore system from dump file
Boot off DVD (?) and select upgrade option to upgrade to 9.0
After upgrade, login and change IP in rc.conf
Connect to LAN
Test network services, ports, etc


----------



## xy16644 (May 24, 2012)

I am busy working through your (helpful!) post and would appreciate some feedback or comments on the list of commands I will be running to test the upgrade of my system. I'll admit, I wasn't sure of a couple and have mentioned that below. 

Heres what I have so far:

```
1) Boot with the 9.0 install CD.

2) Select Shell.

3 )Use glabel to label the two disks:

3a) glabel label MirrorDisk0 /dev/ad4

3b) glabel label MirrorDisk1 /dev/ad6

4) gmirror label -v RootMirror0 /dev/label/MirrorDisk0 /dev/label/MirrorDisk1

5)  gpart create -s mbr RootMirror0  (Create MBR)
    gpart set -a active -i 1 RootMirror0 (Make bootable/active)
    bsdlabel -e RootMirror0 (Create bsdlabel partition)

6) glabel label AlphaSwap /dev/ad4s1b

7) newfs /dev/mirror/RootMirror0

8) mount /dev/mirror/RootMirror0 /mnt/mirror

9) cd /mnt/mirror

10) restore -rf /mnt/usb/restore.dump

11) Add to /etc/fstab file: 

/dev/mirror/AlphaSwap               none            swap    sw              0       0
/dev/mirror/RootMirror0              /               ufs     rw              1       1
```

Am I even close?


----------



## wblock@ (May 24, 2012)

5.  Do not use bsdlabel(8).  gpart(8) is a replacement for it.

6.  Use the mirror device for swap, not one individual disk.

7.  Use soft updates and filesystem labels on the filesystem.

11.  Labels do not show up in /dev/mirror.


----------



## xy16644 (May 25, 2012)

wblock@ said:
			
		

> 5.  Do not use bsdlabel(8).  gpart(8) is a replacement for it.
> 
> 6.  Use the mirror device for swap, not one individual disk.
> 
> ...



Many thanks for the input. I have changed the above mentioned points as follows:


```
5)  gpart create -s mbr RootMirror0  (Create MBR)
    gpart set -a active -i 1 RootMirror0 (Make bootable/active)
    gpart create -s gpt RootMirror0 (Create partition on new mirror)

6) glabel label AlphaSwap /dev/label/RootMirror0

7) newfs -U /dev/label/RootMirror0

11) Add to /etc/fstab file: 


/dev/label/AlphaSwap               none            swap    sw              0       0
/dev/label/RootMirror0              /               ufs     rw              1       1
```

The one thing I have been wondering about is, where do I set the size of the swap and root mirror partition?


----------



## wblock@ (May 25, 2012)

xy16644 said:
			
		

> Many thanks for the input. I have changed the above mentioned points as follows:
> 
> 
> ```
> ...



No, the bsdlabel scheme is called BSD.  And it should be created on a slice.  So

```
gpart create -s BSD mirror/RootMirror0s1
```
Then the filesystems and swap partition must be created on that s1 slice.



> ```
> 6) glabel label AlphaSwap /dev/label/RootMirror0
> ```




```
glabel label romiswap /dev/mirror/RootMirror0s1b
```



> ```
> 7) newfs -U /dev/label/RootMirror0
> ```



Yes, but add a filesystem label:

```
newfs -U -L romirootfs /dev/mirror/RootMirror0
```
Note that RootMirror0 is the device name you gave to the mirror, it's not a label.  Labels show up in various parts of /dev when a disk is attached.  /dev/ufs/ for UFS filesystem labels, /dev/label/ for generic labels, and so on.  See glabel(8).



> ```
> 11) Add to /etc/fstab file:
> 
> /dev/label/AlphaSwap               none            swap    sw              0       0
> ...




```
/dev/label/romiswap               none            swap    sw              0       0
/dev/ufs/romirootfs               /               ufs     rw              1       1
```



> The one thing I have been wondering about is, where do I set the size of the swap and root mirror partition?



That is done when you create those partitions, which is not shown above.  This would be one gpart add to RootMirror0s1 for each partition.


----------



## xy16644 (May 25, 2012)

Thanks for the reply wblock@! Let me just make sure I understand this 100%:

Step 5:

```
gpart create -s BSD mirror/RootMirror0s1  (Create slice)
gpart add -i 1 -s 70G -t mirror/RootMirror0s1a (Create / partition of 70GB)
gpart add -i 2 -s 3G -t mirror/RootMirror0s1b (Create swap partition of 3GB)
```

Step 6:

```
glabel label romiswap /dev/mirror/RootMirror0s1b (label swap...does this have to say romiswap?)
```

Step 7:

```
newfs -U -L romirootfs /dev/mirror/RootMirror0 
(Create file system, enable Soft Updates on mirror partition and label it...
does this label have to be romirootfs or can I change this to something else?)
```

Step 11:
/etc/fstab:

```
/dev/label/romiswap               none            swap    sw              0       0
/dev/ufs/romirootfs               /               ufs     rw              1       1
```

I must be getting close now :e


----------



## wblock@ (May 25, 2012)

xy16644 said:
			
		

> Step 6:
> 
> ```
> glabel label romiswap /dev/mirror/RootMirror0s1b (label swap...does this have to say romiswap?)
> ```



No, it's just the label; seriously, see glabel(8).  It's lowercase because I only use lowercase in labels.  "romi" is from your RootMirror, which is misleading because it doesn't have anything to do with a root filesystem or user.



> Step 7:
> 
> ```
> newfs -U -L romirootfs /dev/mirror/RootMirror0
> ...



You can change it.


----------



## xy16644 (May 25, 2012)

I have made it to step 5:

[CMD=""]gpart create -s BSD mirror/RootMirror0s1[/CMD]

but I am getting the following:


```
gpart: arg0 'mirror/RootMirror0s1': Invalid argument
```

I have tried reading the man file and this is what it says:

[CMD=""]gpart create -s scheme [-n entries] [-f flags] provider[/CMD]

I'm not sure why my provider is incorrect?


----------



## wblock@ (May 25, 2012)

Does /dev/mirror/RootMirror0 (sigh) exist?

Did you load the kernel module for gmirror(8)?


----------



## xy16644 (May 26, 2012)

This seemed to have done the trick:

```
gpart add -i 1 -s 74G -t freebsd mirror/RootMirror0
gpart add -i 1 -s 70G -t freebsd-ufs mirror/RootMirror0s1
gpart add -i 2 -s 3G -t freebsd-swap mirror/RootMirror0s1
```


----------



## wblock@ (May 26, 2012)

It's not necessary to use the -i option when adding partitions.  If you leave out the size, it will use the rest of the available space.


----------



## xy16644 (May 26, 2012)

wblock@ said:
			
		

> It's not necessary to use the -i option when adding partitions.  If you leave out the size, it will use the rest of the available space.



Thanks for that. I will try it shortly as I have started over again. Am battling with making the new mirror bootable!


----------



## xy16644 (May 27, 2012)

I have finished upgrading my test machine to FreeBSD 9 RELEASE and from what I can tell so far there are 3 problems that I have encountered so far:

1) I can't get the SSH service to start and get the following error:

```
/etc/rc: WARNING: /usr/bin/ssh-keygen does not exist
/etc/rc: WARNING: failed precmd routine for sshd
```

2) Postfix can't deliver email anymore. When I send an email I get the following in the NDR error:

```
local configuration error. Command output: mailwrapper:  parse error in /etc/mail/mailer.conf
Action: failed
Status: 5.3.5
Diagnostic-Code: x-unix; mailwrapper: parse error in /etc/mail/mailer.conf
```

3) This is more a curiousity and for my own understanding but before the upgrade I was running my own customised kernel called ALPHA. Post upgrade I am now running the GENERIC kernel. I did recompile my kernel during the upgrade but this doesn't seemed to have worked. I don't need the customised kernel anymore, I just want to understand where I went wrong and why it started using the GENERIC one again.

Many thanks!


----------



## wblock@ (May 27, 2012)

One of the steps after upgrading by source is to update /etc.  Usually that is done with mergemaster(8).  See http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/makeworld.html#CANONICAL-BUILD.

After updating major revisions, FreeBSD 8 to 9, for example, all ports have to be rebuilt.  There's a procedure at the end of the portmaster(8) man page for that.

I would guess the Postfix problem will be fixed by the reinstall of mail/postfix, which (I think) has an option or instructions to update /etc/mail/mailer.conf.

The kernel depends on how you upgraded.  Binary, I think GENERIC is the only choice.  For source, if you don't include KERNCONF=MYKERNELCONFIG on the command line when building the kernel, you'll get GENERIC instead.


----------



## xy16644 (May 27, 2012)

Maybe I should take a step back. In the past when I upgraded from 7.2 to 8.0 and then to 8.2 I ran the following commands in this order:

[CMD="*"]freebsd-update upgrade -r 8.2-RELEASE[/CMD]
[CMD="*"]cd /usr/src[/CMD]
[CMD="*"]make KERNCONF=ALPHA kernel[/CMD]
[CMD="*"]freebsd-update install[/CMD]
[CMD="*"]shutdown -r now[/CMD]
[CMD="*"]freebsd-update install[/CMD]
[CMD="*"]shutdown -r now[/CMD]

This would *normally* upgrade the machine to the new version of FreeBSD and if I ran a [CMD=""]uname -a[/CMD] it would show that the customised kernel was in use.

Having had a look through the link you included in your last post, the steps are quite different:

[CMD="*"]cd /usr/src[/CMD]
[CMD="*"]make buildworld[/CMD]
[CMD="*"]make buildkernel[/CMD]
[CMD="*"]make installkernel[/CMD]
[CMD="*"]shutdown -r now[/CMD]
Boot into single user mode:
[CMD="*"]mount -u /[/CMD]
[CMD="*"]mount -a -t ufs[/CMD]
[CMD="*"]adjkerntz -i[/CMD]
[CMD="*"]mergemaster -p[/CMD]
[CMD="*"]cd /usr/src[/CMD]
[CMD="*"]make installworld[/CMD]
[CMD="*"]mergemaster[/CMD]
[CMD="*"]reboot[/CMD]

I should mention that I don't mind going back to the GENERIC kernel (the changes I made in my customised kernel were never used in the end).

I did end up rebuilding ALL my ports as follows:
[CMD="*"]portmaster -a -f -D -R[/CMD]

This seemed to fix my Postfix problem (I can send email again) but I have since discovered that I can't connect via Thunderbird to the test server for email. I noticed that saslauthd service was no longer installed! I tried to reinstall the port but it kept ending with a fatal error during the make install. I ended up having to install the package but I still can't connect with Thunderbird. 

/var/log/auth.log says:

```
sasldblistusers2: unable to dlopen /usr/local/lib/sasl2/libgs2.so.2: Undefined symbol "GSS_C_MA_ITOK_FRAMED"
saslpasswd2: unable to dlopen /usr/local/lib/sasl2/libgs2.so.2: Undefined symbol "GSS_C_MA_ITOK_FRAMED"
```

After rebuilding all the ports I still can't get the SSH service to start and still get:

```
/etc/rc: WARNING: /usr/bin/ssh-keygen does not exist
/etc/rc: WARNING: failed precmd routine for sshd
```

If I had to start with a fresh restore, would it be better to follow your steps to upgrade from 8.2 to 9.0 (with a generic kernel)? Then rebuild all the ports again? I feel like somethings gone wrong with all these errors I am getting?

BTW, the new mirrors working great! Labels are a nice feature, thanks for introducing me to them!


----------



## wblock@ (May 27, 2012)

The two methods you show are binary (freebsd-update(8)) and source.  I've never used the binary method, but it is covered in both the Handbook and the man page.  Read those, seriously.  They are links, klicken Sie auf den Link.

The upgrade procedure in portmaster(8) helps to avoid problems.  If you do rebuild all your ports, do it that way.

The saslauthd problem is because the package is looking for an older library.  Rebuild it from the port; if there are build problems, something else may be broken.

The ssh-keygen problem, no idea, I've never seen that before.  I would just rebuild from source, rather than restoring again.  And I would do that before attempting to install or rebuild any ports.


----------



## xy16644 (May 28, 2012)

I'm not understanding something when I am in single user mode. From what I have read, when you are using single user mode, the root file system is in read only mode. How does one put it into write mode?

I have tried:

[CMD=""]fsck -p[/CMD]

But I get:

```
/dev/ufs/MirrorRootFS: NO WRITE ACCESS
/dev/ufs/MirrorRootFS: UNEXPECTED INCONSISTENCY; RUN fsck MANUALLY.
```

Running:
[CMD=""]mount -a[/CMD]

doesn't help either.

I also tried:
[CMD=""]fsck -f[/CMD]

The results from running
[CMD=""]mount[/CMD]
are:

```
/dev/ufs/MirrorRootFS on / (ufs, local, soft-updates)
```

What*'*s the correct way to make root writable? (keeping in mind I have a mirror with gmirror).

Thank you.


----------



## wblock@ (May 28, 2012)

That it's a mirror makes no difference, that happens on a level below the filesystem.  As far as the filesystem is concerned, it's just a disk.

To remount the root filesystem in rw mode,
`# mount -u /`


----------



## xy16644 (May 28, 2012)

Is there a command you can run to check what file systems are in read or write mode?

I have run:
[CMD=""]mount -u /[/CMD]

but how can I see what*'*s in read mode? And write mode?

If I run [CMD=""]fsck -p[/CMD] again it still says NO WRITE ACCESS.


----------



## wblock@ (May 28, 2012)

mount(8) does, I think.

fsck(8) only works on unmounted or readonly filesystems.  Why are you trying to run it?


----------



## xy16644 (May 28, 2012)

wblock@ said:
			
		

> mount(8) does, I think.
> 
> fsck(8) only works on unmounted or readonly filesystems.  Why are you trying to run it?



Yes, you're right, mount does do it. If I reboot straight into single user mode and do:
[CMD=""]mount[/CMD]

it returns:


```
/dev/ufs/MirrorRootFS on / (ufs, local, [B]read-only[/B])
```

I then do a:
[CMD=""]mount -u /[/CMD]

and get:


```
/dev/ufs/MirrorRootFS on / (ufs, local, [B]soft-updates[/B])
```

I'll tell you where the question comes from. When I was trying to do my dump restore onto the new mirror from a USB drive (while booted off the FreeBSD 9 DVD into the shell), it kept complaining that there wasn't any writable space in /tmp and the restore failed/stopped. As a workaround I unmounted /tmp and remounted it onto a spare USB drive I had lying around and that got things going. It made me think, did I go about this correctly? Just curious, that*'*s all!


----------



## wblock@ (May 28, 2012)

Use mfsBSD instead of the install CD shell.  It has many things done more usefully.  Just today, I encountered that problem with the install CD shell.  It mounts /tmp on a very small md(4) device.  On the other hand, there's no easily downloadable USB image of mfsBSD, just ISOs for CDs.

Update: looking again, there are now mfsBSD USB images for download!


----------



## xy16644 (May 29, 2012)

Thanks for confirming that, that*'*s the exact same thing I experienced when doing my restore! 

I shall have a look at mfsBSD then. Thanks!


----------



## DutchDaemon (May 30, 2012)

(separate Cyrus SASL question moved to Ports & Packages forum @ http://forums.freebsd.org/showthread.php?t=32393)


----------

