# Migration from 7.0 to 8.0 screwed up my data disks



## TiN-MAN (Jan 9, 2011)

I from what I can gather. Changes have been made to the filesystem handling from FreeBSD 7.0 to 8.0. 

I am a FreeBSD newbie, so I could easily be my own fault. That being said. I believe that the data is still on the disks but the MBR/Slices/lables have been wiped or somehow damaged. Right now sysinstall -> slices and label sees the disk as empty. 

Tried testdisk, normal scan revealed nothing, running deeper scan right now.

Can anyone tell me how to add a slice covering the entire disk like I had before? Without actually doing any damage to data that might be on the disk. Enabling me to mount /dev/ad4s1d and see if the data survived.

I have been reading a ton of blogs, posts on the topic. But can't really find a straight answer when It comes to just creating the slices and not touching the raw data on the disk.

Othervise I will just have to accept the data loss and start over


----------



## Beastie (Jan 9, 2011)

TiN-MAN said:
			
		

> Can anyone tell me how to add a slice covering the entire disk like I had before. Without actually doing any damage to data that might be on the disk.


If that's what you had, then fdisk()'s *-I* option should recreate the slice.
But the problem could be with the BSD label (i.e. partitions) or anything else actually.

By the way, how did you upgrade? And have you mounted the partition(s) outside sysinstall to see if the data is still there?


----------



## TiN-MAN (Jan 9, 2011)

Beastie: Well. I actually installed FreeBSD 8 on new system and then attached the old disks to the new system. Added them to fstab exactly like the old system and rebooted.

Boot failed with file-system inconsistency. I did not run fsck on them. Removed them from fstab again with vi and rebooted. Tried to mount one of two disks manually. Resulting in a mounted empty disk (guess I should have used read only). 

Moved them back to my FreeBSD 7 system where I could read data from the disk I did not mount. And the other one appears empty. It is in my FreeBSD 7 system now. Running testdisk.


----------



## Beastie (Jan 9, 2011)

TiN-MAN said:
			
		

> Added them to fstab exactly like the old system and rebooted.


For another time, you can mount filesystems right away using *mount* followed by the mountpoint included in /etc/fstab. This saves the trouble of having an unpleasant startup if something's wrong.



			
				TiN-MAN said:
			
		

> Boot failed with file-system inconsistency.


On which one? The system disk with the new installation or the data disk? If the latter, then that may have been the problem from the start. Maybe you unmounted it uncleanly last time, or if it's USB-connected maybe there was a power loss or something.



			
				TiN-MAN said:
			
		

> Tried to mount one of two disks manually. Resulting in a mounted empty disk (guess I should have used read only).
> 
> Moved them back to my freebsd 7 system where I could read data from the disk I did not mount. And the other one appears empty. It is in my Freebsd 7 system now. Running testdisk


That's very odd. If something went wrong and any disk/filesystem metadata was corrupted, it should return errors when mounting or fail to mount at all. But it isn't, right?
Even an empty (but still mountable) disk should have a valid partition table (or similar structure), BSD label, UFS superblock, etc.

Also, even if you ran newfs on it, you should at least see the .snap directory.

How are you mounting the disk?


----------



## TiN-MAN (Jan 9, 2011)

Beastie said:
			
		

> For another time, you can mount filesystems right away using mount followed by the mountpoint included in /etc/fstab. This saves the trouble of having an unpleasant startup if something's wrong.



Thanks, nice to know.



			
				Beastie said:
			
		

> On which one? The system disk with the new installation or the data disk? If the latter, then that may have been the problem from the start. Maybe you unmounted it uncleanly last time, or if it's USB-connected maybe there was a power loss or something.



Well I better explain. I have two WD 1TB disks, both failed with file-system inconsistency. Can't find /dev/ad4 and /dev/ad6 something something. I know both worked fine seconds before in FreeBSD 7.  

I tried mounting one of the disks with [cmd=]mount /dev/ad4s1d /mnt/disk1/[/cmd] it mounted with no problem. I don't think there was an .snap dir, now that you mention it. Just noticed the empty drive and free space (932G) (Using Midnight commander). I guessed it did not work. 

Powered down and moved the drives or rather just the sata cables and power back to the original system. One disk did not mount (The one I mounted in 8.0) failing with file-system inconsistency. Sysinstall (in 7.0) now sees the disk as completely empty. 

I managed to move data from the working drive to another computer. Reconnected that disk back to the new server (8.0) and after a lot of trial and error I got the disk wiped and partitioned again. Apparently something weird was wrong with both disks file systems. Sysinstall would not run newfs on the disk and manually running newfs did not result in a mountable drive.

In the end I used gpart to "destroy" the disk and then sysinstall had no problem preparing the disk. 

Now I'm only left with one disk than will not mount in either system


----------



## TiN-MAN (Jan 9, 2011)

Now I used gpart to add ad4s1


```
gpart list
Geom name: ad4
fwheads: 16
fwsectors: 63
last: 1953525134
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: ad4s1
   Mediasize: 1000204851712 (932G)
   Sectorsize: 512
   Mode: r0w0e0
   length: 1000204851712
   offset: 17408
   type: freebsd
   index: 1
Consumers:
1. Name: ad4
   Mediasize: 1000204886016 (932G)
   Sectorsize: 512
   Mode: r0w0e0
```
Now I just need to create ad4s1d without using newfs or anything that alters the entire disk.


----------



## wblock@ (Jan 9, 2011)

Don't use sysinstall after you've installed the system.  fdisk(8), ]bsdlabel(8), and gpart(8) are the tools.  See Disk Setup On FreeBSD for more information.

Somewhere in ports is a utility that will scan a disk and try to recreate the label, but I can't recall what it's called and haven't tried it.


----------



## TiN-MAN (Jan 10, 2011)

wblock said:
			
		

> Don't use sysinstall after you've installed the system. fdisk(8), ]bsdlabel(8), and gpart(8) are the tools. See Disk Setup On FreeBSD for more information.
> 
> Somewhere in ports is a utility that will scan a disk and try to recreate the label, but I can't recall what it's called and haven't tried it.



Ok, I will keep that in mind. Just felt more comfortable with a GUI. Easier to get an overview.

But it all comes back to how I create a "d" partition on ad4s1 without newfs.

Will this do the trick?

```
bsdlabel -w /dev/ad4s1
```


----------



## Beastie (Jan 10, 2011)

TiN-MAN said:
			
		

> Will this do the trick?
> 
> ```
> bsdlabel -w /dev/ad4s1
> ```


Again, if that's _exactly_ what you had, it should recreate it as it was before. After that, edit the label with vi using `# bsdlabel -e ad4s1` and replace (r) the default "a" partition with "d" then save the label wq).
You should now see /dev/ad4s1 and /dev/ad4s1d when you run `% ls /dev/ad4*`.


----------

