Disk partitioning & mounting

FreeBSD 9.x
I have two questions:
If I am using a single disk as a storage disk do I need to set up partitions on it?

[ii] I have a disk that I cannot mount - [NOT a system drive]
# gpart show /dev/ada4
Code:
=>       63  156355521  ada4  MBR  (74G)
         63  156344517     1  freebsd  [active]  (74G)
  156344580      11004        - free -  (5.4M)

:# file -s /dev/ada4
Code:
/dev/ada4: x86 boot sector; partition 1: ID=0xa5, active, starthead 1, startsector 63, 156344517 sectors, code offset 0x31
Seems as if the whole disk sector 63-156344517 is seen as a boot sector, strange! as this contained data before. How can I recover this, should I just do a dd() and lay down a newfs()?

Now
# ls /dev/ada4*
Code:
/dev/ada4      /dev/ada4s1

# file -s /dev/ada4s1
Code:
/dev/ada4s1: data

Of course
# mount -v /dev/ada4 /disktmp
Code:
mount: /dev/ada4 : Invalid argument

and
# mount -v /dev/ada4s1 /disktmp
Code:
mount: /dev/ada4s1 : Invalid argument
fails too as expected.

Any Suggestions?
 
jaymax said:
FreeBSD 9.x
I have two questions:
If I am using a single disk as a storage disk do I need to set up partitions on it?


It is not required. The device name given to mount() would just be the drive name. Normally, partitions are expected.

[ii] I have a disk that I cannot mount - [NOT a system drive]
# gpart show /dev/ada4
Code:
=>       63  156355521  ada4  MBR  (74G)
         63  156344517     1  freebsd  [active]  (74G)
  156344580      11004        - free -  (5.4M)

:# file -s /dev/ada4
Code:
/dev/ada4: x86 boot sector; partition 1: ID=0xa5, active, starthead 1, startsector 63, 156344517 sectors, code offset 0x31
Seems as if the whole disk sector 63-156344517 is seen as a boot sector, strange! as this contained data before. How can I recover this, should I just do a dd() and lay down a newfs()?

Don't use dd(). It is not needed. Use gpart(8): gpart show ada4s1. Or easier, just gpart show and it will show all the GEOM devices.
 
Sorry, thought I had included that earlier, anyway here it is?

# gpart show ada4s1
Code:
gpart: No such geom: ada4s1.

and

# gpart show ada4
Code:
=>       63  156355521  ada4  MBR  (74G)
         63  156344517     1  freebsd  [active]  (74G)
  156344580      11004        - free -  (5.4M)

Thanks
 
On an MBR, there would normally be a FreeBSD bsdlabel(8) inside that slice to create the individual FreeBSD partitions.

But both the file(1) and gpart(8) output show there is nothing recognizable there. file(1) in particular should recognize filesystems of all types. Maybe it is a geli(8)-encrypted filesystem.

If there is nothing to recover from that disk, and you want to use the whole thing for a single storage filesystem, I'd suggest using gpart(8) to set that up. GPT partitions are much easier to create:

Code:
# gpart destroy -F ada4                     # destroy the partitioning
# gpart create -s gpt ada4                  # create GPT partitioning
# gpart add -t freebsd-ufs -a4k -b1m ada4   # add a UFS partition aligned to 4K, starting at 1M
# newfs -U /dev/ada4p1                      # format the filesystem with soft updates
# mount /dev/ada4p1 /mnt                    # ready for use
 
Good, wonderful!

Now if there is data that I want to recover, and I do -
I previously did a dd of the disk and of the partition - stored on another disk, can I after the reformatting simply do a dd if=/diskX/devada4 of=/dev/ada4 or dd if=/diskX/devada4s1 of=/dev/ada4p1 (/diskX/devada4 and /diskX/devada4s1 being path to the stored disk and partition) and recover it all?

That would be the complete solution to the immediate problem,

Thanks!
 
The first command will entirely overwrite the disk, including the partitioning. The second will leave you in the same situation as now. Both will run very slowly due to copying only one block at a time.

Don't repartition or reformat until you know what that data is and have it accessible somewhere else. Finding out what it is could be challenging.
 
Back
Top