# Migrating to second hard drive



## daruffneck2 (Apr 10, 2016)

I need a hint how to mount a second hard drive into a newly installed BSD Desktop System. This second drive has been mounted under Debian wheezy but after changing to jessie I am facing the music. It is not a raid, justs a simple second hdd.
Since I installed the new system and no further applications I can see the disk, gsmartcontrol is telling me that it is safe and sound. The totally used disk space is about 469 GB on that disk I need to acces. I know that once a disk has been used in another system there are different rights and it is seen as another device, another user and another root. So normally I would change the fstab. So I did, but this resulted in nothing but a unbootable system. Note: even as root, the changes were not accepted, rights were set to 775.
The line I added to the /etc/fstab was


```
/dev/ada1s1  /newdisk  ufs  rw 2  2
```

So I reinstalled the whole system. Looking for the following files.  /boot  looking at

```
loader.conf
loader.conf.pcbsd
loader.rc
```
 By the way, I set in the first two under

```
# Load File-System Support
ext2fs_load="YES"
ext4fs_load="YES"
```

May I should apply as well to

```
# Load Linux compat
linux_lvm="YES"
```
  I really don't know.

So I searched on, reading about to add a slice to the 2nd disk, beside the mbr. Under linux it has been a linux_lvm and under `gpart list` is said

```
Mode : r0w0e0  ... type : linux_lvm
```

`gpart list` tells me the disk is safe and sound. And a MTBF for some 4200 hours. I am using this disk for less than a year as a mass storage. If it helps I put here the output of `gpart list`.
To cut a long story short, is it a good idea to add a slice to the second hdd, beside the mbr that is already there, just to gain access to it? Or how to copy the content and after that format it? And how to gain access to it? That is the crucial point.
So if anyone has a clue that helps to access the disk I gladfully appreciate it. Thanks in advance.


----------



## SirDice (Apr 11, 2016)

There is no support for LVM on FreeBSD. If you want to use it for FreeBSD you'll need to remove the existing partitions and create new ones, preferably FreeBSD ones. 

Handbook: 17.2. Adding Disks


----------



## daruffneck2 (Apr 21, 2016)

I just have been, not for the first time reading this very site, even the man-page for gpart, but what happens, when I follow those instructions as this very site tells me to do is :

```
# gpart create -s GPT ada1
gpart: geom 'ada1': File exists
```
 and this

```
# gpart add -t freebsd-ufs -a 1M ada1
gpart: size '0': Invalid argument
```
.
Any time I tried for training to delete a slice on a pluggable usb-key and afterwards to destroy it, I could not succeed with none of them. Nor destruct it, neither destroy it, not even the -f Option worked. So how to delete the slice on the 2nd disk, in this case called 
ada1. I tried 

```
newfs -U /dev/ada1p1
newfs: /dev/ada1p1: could not find special device
```
and 

```
/var/run/dmesg.boot
diskinfo -ctv ada1
gpart set -a active /dev/ada1
   operation not supported by device
gpart set -a bootme -i 1 /dev/ada1
   invalid argument
```
In almost complete dispair I tried the following one

```
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada1
bootcode written to ada1
```


----------



## daruffneck2 (Apr 21, 2016)

I just have been, not for the first time reading this very site, even the man-page for gpart, but what happens, when I follow those instructions as this very site tells me to do is :

```
# gpart create -s GPT ada1
gpart: geom 'ada1': File exists
```
 and this

```
# gpart add -t freebsd-ufs -a 1M ada1
gpart: size '0': Invalid argument
```
.
Any time I tried for training to delete a slice on a pluggable usb-key and afterwards to destroy it, I could not succeed with none of them. Nor destruct it, neither destroy it, not even the -f Option worked. So how to delete the slice on the 2nd disk, in this case called
ada1. I tried

```
newfs -U /dev/ada1p1
newfs: /dev/ada1p1: could not find special device
```
and

```
/var/run/dmesg.boot
diskinfo -ctv ada1
gpart set -a active /dev/ada1
   operation not supported by device
gpart set -a bootme -i 1 /dev/ada1
   invalid argument
```
In almost complete dispair I tried the following one

```
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada1
bootcode written to ada1
```
And as soon as I add a line to 

```
/etc/fstab
```
taking the risk to reboot, it stops and freezes, just after adding the device and mount point rw options etc.


----------



## Juha Nurmela (Apr 21, 2016)

`gpart destroy -F ada1` does not work ? Maybe `dd < /dev/zero > /dev/ada1` will ? Let it whirr for a second and ^C. Then start again with `gpart create ...`

remember to breathe 
Juha

You might benefit later, if you create a small ada1p1 for /boot and then a large ada1p2. The first page in EXAMPLES of gpart(8)


----------



## daruffneck2 (Apr 22, 2016)

I may take a deep breath, because I typed the following, and just now running GSmartControl the long run.....ten minutes left....but I guess it's about data recovery now. So I did this:
The last try was about deleting the index on the 2nd hdd typing the command

```
gpart delete -i 1 ada1
```
then

```
gpart add -t freebsd-zfs -a 1M ada1
```
then the decisive error, I guess

```
gpart add -t freebsd-boot -b40 -s512k ada1
```
and running GSmart Control the long test.
I can mount the disk and see a snapshot. But as it appears, it is empty.
Throughout the time testing this I saw at least three slices, or partitions, which are said to contain a hidden backup.
So now typing

```
gpart recover ada1s1
gpart: arg0 'ada1s1': Invalid argument
```
Or should I type ada1p1 instead?

```
gpart recover ada1
ada1 recovering is not needed
```
Well, can anyone help me out of this trap? Thanks in advance.


----------



## wblock@ (Apr 22, 2016)

I don't know what "GSmartControl" is, or why you are running it.  Or why data recovery is mentioned.  Repartitioning a disk deletes the old partitions and data.  Make a backup before starting.

The command that will help is just `gpart show ada1`.  The errors about not being able to create a new GEOM are because the drive is already partitioned.
To repartition it, the old partitioning must be destroyed.  gpart(8) refuses to destroy partitioning unless all the partitions are removed first.  Or that can be overridden with -F (note: capital F, and this will erase the partitioning on ada1 making any old data extremely difficult to recover):
`gpart destroy -F ada1`

Then you can create a GPT partitioning scheme and add partitions.  This does not create any data, just leaves the disk with empty filesystems where data can be copied.


----------

