Solved How can FreeBSD read and write on the UFS1 file system created by DragonFlyBSD

Code:
root@marietto:/usr/home/marietto # sh

root@marietto:/usr/home/marietto # for i in $(jot 256);do echo -n $i;dd if=/dev/da2p2 iseek=$i count=30 2>/dev/null|file -;done|grep -v ": data" 

9/dev/stdin: DOS executable (COM)
11/dev/stdin: COM executable for DOS
 
from dragonfly try disklabel64 /dev/daXs2

Code:
root@marietto:/home/marietto # gpt show /dev/da10

       start        size  index  contents
           0           1      -  PMBR
           1           1      -  Pri GPT header
           2          32      -  Pri GPT table
          34        2014      -  Unused
        2048      262144      0  GPT part - EFI System
      264192  1953259520      1  GPT part - DragonFly Label64
  1953523712        1423      -  Unused
  1953525135          32      -  Sec GPT table
  1953525167           1      -  Sec GPT header


root@marietto:/home/marietto # disklabel64 /dev/da10s1


# /dev/da10s1:

#

# Calculated informational fields for the slice:

#

# boot space:    1044480 bytes

# data space:  976627712 blocks    # 953738.00 MB (1000066777088 bytes)

#

# NOTE: The partition data base and stop are physically

#       aligned instead of slice-relative aligned.

#

# All byte equivalent offsets must be aligned.

#


diskid: 607a4197-668a-11ec-9f5e-e1d55ee21f22

label:

boot2 data base:      0x000000001000

partitions data base: 0x000000100000

partitions data stop: 0x00e8d8b00000

backup label:         0x00e8d8bff000

total size:           0x00e8d8c00000    # 953740.00 MB

alignment: 4096

display block size: 1024    # for partition display and edit only


16 partitions:

#          size     offset    fstype   fsuuid

  a:    1048576          0    4.2BSD    #    1024.000MB

  d:  975579136    1048576    4.2BSD    #  952714.000MB

  a-stor_uuid: b952ae35-668a-11ec-9f5e-e1d55ee21f22

  d-stor_uuid: b952ae3a-668a-11ec-9f5e-e1d55ee21f22
 
dd if=/dev/da10s1a bs=1024 count=10 >/tmp/file1.bin
dd if=/dev/da10s1 iseek=1024 bs=1024 count=10 >/tmp/file2.bin
compare the files with cmp and if they dont differ try
dd if=/dev/da10s1 bs=1024 iseek=1049600 count=20|file -
should say ufs something
if the offset to the d partition is correct then you can use gnop in freebsd to create a block device at that offset and try to mount it
 
i want to verify that da10s1a is 1mb after da10s1
then i can figure the offset of da10s1d relative to da10s1
da10s1 si the same with da2p2 in freebsd
s1a and s1d are unknown in freebsd, we have to figure them out
we need an offset to a known point (da2p2)
 
According with a developer,I should patch the file "/usr/src/sys/geom/part/g_part_bsd64.c" with this code :

Code:
diff --git a/sys/geom/part/g_part_bsd64.c b/sys/geom/part/g_part_bsd64.c
index bc0112fbb7ed..52971b3913cf 100644
--- a/sys/geom/part/g_part_bsd64.c
+++ b/sys/geom/part/g_part_bsd64.c
@@ -473,18 +473,22 @@ g_part_bsd64_probe(struct g_part_table *table, struct g_consumer *cp)
 {
     struct g_provider *pp;
     uint32_t v;
+    off_t secstart, secend;
     int error;
     u_char *buf;
 
     pp = cp->provider;
     if (pp->mediasize < 2 * PALIGN_SIZE)
         return (ENOSPC);
-    v = rounddown2(pp->sectorsize + offsetof(struct disklabel64, d_magic),
-               pp->sectorsize);
-    buf = g_read_data(cp, 0, v, &error);
+    secstart = rounddown2(offsetof(struct disklabel64, d_magic),
+        pp->sectorsize);
+    secend = roundup2(offsetof(struct disklabel64, d_magic) +
+        sizeof(((struct disklabel64 *)0)->d_magic),
+        pp->sectorsize);
+    buf = g_read_data(cp, secstart, secend - secstart, &error);
     if (buf == NULL)
         return (error);
-    v = le32dec(buf + offsetof(struct disklabel64, d_magic));
+    v = le32dec(buf + (offsetof(struct disklabel64, d_magic) - secstart));
     g_free(buf);
     return (v == DISKMAGIC64 ? G_PART_PROBE_PRI_HIGH: ENXIO);
 }

ok,I've modified that file. but now,what should I do ? how can I compile it ? it's a simple "make" enough ? let me know,I want to check if the patch works.
 
Last edited:
build the module or the kernel

cd /sys/modules/geom/geom_part/geom_part_bsd64
make
make install
kldload geom_part_bsd64
 
Solution :

Code:
kldload geom_part_bsd64
gpart show :


2048 1953255425 da2p2 BSD64 (931G)
2048 2097152 1 dragonfly-ufs (1.0G)
2099200 1951158272 4 dragonfly-ufs (930G)
1953257472 1 - free - (512B)

root@marietto:/home/marietto # ls /dev/da2p2*

/dev/da2p2 /dev/da2p2a /dev/da2p2d


root@marietto:/home/marietto # mount -t ufs /dev/da2p2d /mnt/dragonfly

and it's done. The two BSDs are now in communication. That's not bad.
 
if you want to use the whole disk as ufs you do not add partitions after
just newfs -O 1 /dev/da2
file -s /dev/da2

I tried to "format" the disk da8 :


Code:
=>        34  1953525101  da8  GPT  (932G)
          34        2014       - free -  (1.0M)
          2048  1953521664    1  ms-basic-data  (932G)
          1953523712        1423       - free -  (712K)

with the UFS1 fs using these commands :

Code:
# newfs -O 1 /dev/da8
# gpart create -s GPT /dev/da8
# gpart add -t freebsd-ufs /dev/da8

and then I jumped on the DragonBSD,which understands only the UFS vers. 1 file system and I tried to mount the new partition created :

Code:
# ls /dev/da16s0*
/dev/da16s0

# gpt -v show /dev/da16

gpt show: /dev/da16: mediasize=1000204886016; sectorsize=512; blocks=1953525168
       start        size  index  contents
           0           1      -  PMBR
           1           1      -  Pri GPT header
           2          32      -  Pri GPT table
          34           6      -  Unused
          40  1953525088      0  GPT part - FreeBSD UFS/UFS2
  1953525128           7      -  Unused
  1953525135          32      -  Sec GPT table
  1953525167           1      -  Sec GPT header

# mount -t ufs /dev/da16s0 /mnt/da16s0

but it didn't work :

mount_ufs: /dev/da16s0 on /mnt/da16s0: incorrect super block


what's the problem here ?
 
Who says that UFS filesystem in dragonflybsd or for instance openbsd is the same as UFS for freebsd.
Meaning UFS might have multiple different implementations & there doesn't exist a "standard" UFS.
 
Back
Top