# Boot problem after adding old hard disk to the system



## atomant (May 20, 2012)

I have made a fresh install of FreeBSD 9. Everythig worked fine. Then I decided to add an old drive on which I have some data and this caused the system to ask me for mountroot>.

In my /etc/fstab is following:

```
/dev/ada0p2	/		ufs	rw	1	1
/dev/ada0p3	none		swap	sw	0	0
```

If I unplug the extra hard disk the system boot*s* normal*l*y.

I have seen during boot process that the added drive becomes ada0 and the boot one ada1. Why is this happening? On my previous setup with FreeBSD 8 I had no such issue while adding an additional drive to the system.


----------



## kpa (May 20, 2012)

Here:

http://www.wonkity.com/~wblock/docs/html/labels.html


----------



## atomant (May 20, 2012)

Tried it but it doesn't work. I have followed the tutorial but after the first reboot the labels are gone.

What am I missing here?


----------



## wblock@ (May 20, 2012)

If you add the labels and let it mount the filesystems, it will wipe out the labels.  So boot single-user, set the labels with tunefs(8), then reboot (not ctrl-d or exit).  Actually, it might work to force a retaste, but I haven't tested that.


----------



## atomant (May 20, 2012)

I did it exactly as the tutorial says:

boot in single-mode
set the labels
didn't mount volumes
reboot (*shutdown -r now*)
check for labels - no labels found


----------



## wblock@ (May 20, 2012)

Are you using a custom kernel or other customizations?


----------



## atomant (May 20, 2012)

No, it is a generic kernel.


----------



## wblock@ (May 21, 2012)

The only thing that occurs to me is possibly duplicate labels on the two disks.  What type of labels did you use, and where did you look for them?


----------



## Terry_Kennedy (May 21, 2012)

atomant said:
			
		

> I have seen during boot process that the added drive becomes ada0 and the boot one ada1. Why is this happening? On my previous setup with FreeBSD 8 I had no such issue while adding an additional drive to the system.


As others have mentioned, labels are the best way to deal with this.

However, you might be able to work around it in hardware. If both drives are the same type and speed (for example, 3GB/sec SATA) you could try swapping the cables on your motherboard / controller ports.

FreeBSD probes for drives in a predicable order and will generally number them starting at 0. If you add a drive on a port that is probed before your existing ada0, the new drive will become ada0 and your existing drive will move to ada1. Some motherboards don't clearly label the ports or do strange things with them - for example, I have a system where the port order is different in AHCI mode vs. legacy mode.

Of course, swapping the cables is only useful if both ports offer the same functionality. You might have a good reason for connecting them as you did - for example, if you connected your system disk to an add-in controller with enhanced functionality.

Was your previous FreeBSD 8 install on the same system? I'm not sure why the order would change on a newer version.


----------



## atomant (May 21, 2012)

wblock@ said:
			
		

> The only thing that occurs to me is possibly duplicate labels on the two disks.  What type of labels did you use, and where did you look for them?



I had only one disk plug*g*ed in and running just to avoid what you have said.


----------



## wblock@ (May 21, 2012)

Could you show the output of file(1) and tunefs(8) on those filesystems?
`# file -s /dev/ada0p2`
`# tunefs -p /dev/ada0p2`


----------



## atomant (May 21, 2012)

Just another thing. Can I use tunefs even if my disk is GPT or should I use gpart?

At the beginning of the install process I have configured partitions and also wrote labels for them but it looks like the setup didn't take care of this option.


----------



## atomant (May 21, 2012)

wblock@ said:
			
		

> Could you show the output of file(1) and tunefs(8) on those filesystems?
> `# file -s /dev/ada0p2`
> `# tunefs -p /dev/ada0p2`




```
server# file -s /dev/ada0p2
/dev/ada0p2: Unix Fast File system [v2] (little-endian) last mounted on /, last written at Mon May 21 20:35:43 2012, clean flag 0, readonly flag 1, number of blocks 13107200, number of data blocks 12898855, number of cylinder groups 70, block size 32768, fragment size 4096, average file size 16384, average number of files in dir 64, pending blocks to free 80, pending inodes to free 1, system-wide uuid 0, minimum percentage of free blocks 8, TIME optimization

server# tunefs -p /dev/ada0p2
tunefs: POSIX.1e ACLs: (-a)                                disabled
tunefs: NFSv4 ACLs: (-N)                                   disabled
tunefs: MAC multilabel: (-l)                               disabled
tunefs: soft updates: (-n)                                 enabled
tunefs: soft update journaling: (-j)                       enabled
tunefs: gjournal: (-J)                                     disabled
tunefs: trim: (-t)                                         disabled
tunefs: maximum blocks per file in a cylinder group: (-e)  4096
tunefs: average file size: (-f)                            16384
tunefs: average number of files in a directory: (-s)       64
tunefs: minimum percentage of free space: (-m)             8%
tunefs: optimization preference: (-o)                      time
tunefs: volume label: (-L)
```


----------



## wblock@ (May 21, 2012)

In single-user mode, without remounting so / is still readonly, do
`# fsck -y /dev/ada0p2`
`# tunefs -L zootfs /dev/ada0p2`
`# reboot`

After it reboots, that label should be in /dev/ufs/.  There are two differences there.  The output from file(1) made me think fsck(8) needed to be run ("pending" numbers), and tunefs(8) shows SUJ, which I'm not using but should not matter for labels.


----------



## atomant (May 22, 2012)

I have done like you said but after reboot:


```
server# ls /dev/ufs
ls: /dev/ufs: No such file or directory
```


----------



## atomant (May 22, 2012)

Looks like the label is there:


```
server# tunefs -p /dev/ada0p2
tunefs: POSIX.1e ACLs: (-a)                                disabled
tunefs: NFSv4 ACLs: (-N)                                   disabled
tunefs: MAC multilabel: (-l)                               disabled
tunefs: soft updates: (-n)                                 enabled
tunefs: soft update journaling: (-j)                       enabled
tunefs: gjournal: (-J)                                     disabled
tunefs: trim: (-t)                                         disabled
tunefs: maximum blocks per file in a cylinder group: (-e)  4096
tunefs: average file size: (-f)                            16384
tunefs: average number of files in a directory: (-s)       64
tunefs: minimum percentage of free space: (-m)             8%
tunefs: optimization preference: (-o)                      time
tunefs: volume label: (-L)                                 rootfs
```

But where it is hiding?


----------



## wblock@ (May 22, 2012)

When a device is mounted, some or all of the device names and labels pointing to it are hidden.  When all the labels in /dev/ufs are hidden, that directory goes away.  Change /etc/fstab to use the label now, and it will work.

Note: "zootfs" was not a typo.  Give each filesystem a unique name to avoid collisions when two filesystems have the same name.  "bobrootfs", "xrootfs", and so on.


----------



## atomant (May 22, 2012)

It works!

Now let's go to make RAID1.


----------

