# Problem adding drives (with data) to an existing system



## pta99 (Apr 7, 2014)

I added two hard drives (that contain data) to a FreeBSD 10 installation.  The drives show up in dmesg.boot.  I added the following lines in fstab:


```
/dev/da1p1     /home2           ufs     rw      2       2
/dev/da2p1     /home3           ufs     rw      2       2
```

I'm 99% certain that the drives are UFS.  (It is possible however that it could be another file system) - how do I find out what it might be?

Then I try to mount with the following command:

`mount /home2`

and I get this error:


```
mount: /home2: No such file or directory
```

Rebooting the machine causes it to fail boot up because of the added drives - can't remember what error it gave.  Only way to get back in is to manually comment out the two lines in fstab.  Could there be something else or do I have the wrong file system specified?  If the latter, is it safe and can I just proceed with trial and error?  Or is there another way?


----------



## wblock@ (Apr 7, 2014)

Do the /home2 and /home3 mountpoint directories exist?  The p1 and p2 notation says those external drives use GPT formatting.  Is that correct?

Filesystems can usually be identified with file(1): `# file -s /dev/da2p1`


----------



## pta99 (Apr 7, 2014)

Yes the /home2 and /home3 directories exist.  Although there is a caveat.  Those were the directories that existed but when I ran

`# file -s /dev/da1p1`

The machine returned the following:


```
/dev/da1p1: Unix Fast File system [v2] (little-endian) last mounted on /home, last written at Sun Feb  9 20:13:53 2014, clean flag 1, readonly flag 0, number of blocks 488374272, number of data blocks 473036700, number of cylinder groups 3048, block size 32768, fragment size 4096, average file size 16384, average number of files in dir 64, pending blocks to free 0, pending inodes to free 0, system-wide uuid 0, minimum percentage of free blocks 8, TIME optimization
```

This conflicts with /dev/da0p6 which is associated with /home - I don't understand why this is so as I had this drive set up as /home3

For your curiosity the output of `# file -s /dev/da2p1` yields: 


```
/dev/da2p1: Unix Fast File system [v2] (little-endian) last mounted on /home2, last written at Sun Feb  9 20:13:53 2014, clean flag 1, readonly flag 0, number of blocks 488374272, number of data blocks 473036700, number of cylinder groups 3048, block size 32768, fragment size 4096, average file size 16384, average number of files in dir 64, pending blocks to free 0, pending inodes to free 0, system-wide uuid 0, minimum percentage of free blocks 8, TIME optimization
```

My conclusion is that I had /home2 and /home3 reversed in fstab.  However, even after fixing this issue and noting that both drives are formatted with UFS (and I'm confirming that those drives use GPT formatting) - I still get the same output when I attempt to mount either drive:


```
mount: /home2: No such file or directory
```


```
mount: /home3: No such file or directory
```

and mounting /dev/da1p1 or /dev/da2p1 yields the same errors:

`# mount /dev/da1p1`

```
mount: /home3: No such file or directory
```

`# mount /dev/da2p1`

```
mount: /home2: No such file or directory
```

Seems to me that thanks to the `file -s /dev/da2p1` command and logic, at least the /home3 or /dev/da1p1 should be mounting.  Is there another requirement that I'm missing?  I'm not sure how to read the output from the `file -s /dev/da2p1` command so I'm not sure if any of it points to a problem with the data on the drive, however comparing that output to the output of other partitions on /da0 leads me to believe that these partitions and the data are fine.


----------



## wblock@ (Apr 7, 2014)

pta99 said:
			
		

> ```
> /dev/da1p1: Unix Fast File system [v2] (little-endian) last mounted on /home, last written at Sun Feb  9 20:13:53 2014, clean flag 1, readonly flag 0, number of blocks 488374272, number of data blocks 473036700, number of cylinder groups 3048, block size 32768, fragment size 4096, average file size 16384, average number of files in dir 64, pending blocks to free 0, pending inodes to free 0, system-wide uuid 0, minimum percentage of free blocks 8, TIME optimization
> ```
> 
> This conflicts with /dev/da0p6 which is associated with /home - I don't understand why this is so as I had this drive set up as /home3



It's not a conflict, just a report of the last place it was mounted.

If these drives are connected by USB, realize that they might swap drive numbers if you connect or power on one before the other.

Are you certain that home2 is present in /, and not /usr?  What happens if you try this: `mount /dev/da1p1 /mnt`?


----------



## pta99 (Apr 7, 2014)

I should have corrected this assumption: these are internal drives.  I did a fresh install of FreeBSD on /dev/da0 but didn't want to touch these two drives during the installation because I didn't want them to be wiped and was unsure of the procedure to keep them untouched.  

These two internal drives had been assigned /home2 and /home3 prior to reinstallation of FreeBSD.  Thus my confusion in seeing that it was mounted as /home.  From your response, I assume that this is of no incidence now and I can simply reassign that drive to /home3.

I see no evidence of /home2 or /home3 in /usr.

I ran `# mount /dev/da1p1 /mnt`

The first time I ran it, it returned nothing.  

I then did: 


```
# cd /dev/da1p1
/dev/da1p1: Not a directory.
```

I ran the same command again:


```
# mount /dev/da1p1 /mnt
mount: /dev/da1p1: Device busy
```

So no assumptions are made - here are the relevant lines from fstab


```
/dev/da1p1     /home3           ufs     rw      2       2
/dev/da2p1     /home2           ufs     rw      2       2
```

Thank you!


----------



## wblock@ (Apr 7, 2014)

pta99 said:
			
		

> I ran `# mount /dev/da1p1 /mnt`
> 
> The first time I ran it, it returned nothing.



That means it worked.  The contents of that filesystem will be visible in /mnt.

Please show the output of `ls -lhd /home2 /home3`.


----------



## pta99 (Apr 7, 2014)

Here's what I got:


```
# ls -lhd /home2 /home3
ls: /home2: No such file or directory
ls: /home3: No such file or directory
```

and: 


```
# cd /mnt
root@rd1:/mnt # ls
.snap		myfiles
```

(I deleted most of the files in the directory for the purpose of the output above, just left a couple to show that it shows the content).

In other words, it is showing the content of /mnt is the content of what was formerly /home2.


----------



## wblock@ (Apr 7, 2014)

What this shows is that the error message was correct.  The mountpoint directories do not exist.  They are not automatically created, but must be present for mount(8) to use as mountpoints when mounting a new filesystem.


----------



## pta99 (Apr 8, 2014)

First, thank you for all your help!

However, being a newbie to FreeBSD, I'm confused by your last post.  I understood that using `mount` along with the having the correct definitions in the fstab I should be able to mount a drive.  As it stands now, rebooting the machine will yield the same error I had originally encountered - inability to boot as /home2 and /home3 or /dev/da1p1 and /dev/da2p1 cause an error.  

Would you be able to point me the right direction for further research on how to proceed from this point?  It seems that there's an intermediate step that I'm missing and the reading I've done in the FreeBSD manual and google hasn't yielded a satisfactory answer.  

Thank you.


----------



## wblock@ (Apr 8, 2014)

pta99 said:
			
		

> I understood that using `mount` along with the having the correct definitions in the fstab I should be able to mount a drive.



mount(8) requires that a directory exists where the filesystem will be mounted.  This is called a _mountpoint_.  Defining devices and mountpoints in /etc/fstab does not create those mountpoints, that's manual.

So create those empty directories for mountpoints first:
`mkdir /home2 /home3`

After that, the drives can be mounted manually with `mount /dev/da1p1 /home2`.  The entries in /etc/fstab are not required, but if they are there, can be used to mount those drives automatically on startup.  Or add the noauto option, and mount them manually.  In that case, just specify the mountpoint, and mount(8) will look up the entry: `mount /home2`.


----------



## pta99 (Apr 8, 2014)

I had considered this - after reading the manual but I had been under the impression that `mkdir` would be destructive to the data on the drive because I confused `mkdir /home2` with the /home2 partition label on the drive.  With your explanation, it became clear that it isn't the case.  Everything works.  Thank you so very much for your help!


----------

