How to mount UFS1 partition style disk (created by DragonFlyBSD) within FreeBSD. reddit / freebsd ---------------------------------------------------------------------- loziomario · 2021-12-26 21:27 Hello. On FreeBSD I've created several raw / img files of various OS that I've virtualized with bhyve and I've stored them on a UFS2 disk. Now,what I want to do is to virtualize those images with qemu and nvmm under the DragonFlyBSD. The problem is that DragonFlyBSD does not support UFS2. So,I've reinstalled the DragonFlyBSD on the disk that I will use to store the raw-img files of the virtual machines,but during the installation I've used the UFS fs instead of the HAMMER2 fs,because I thought that doing in this way I could have copied the vms from Freebsd to DFLY and viceversa. Unfortunately it seems that I can't mount that disk from FreeBSD. Someone knows why ? Maybe there is a specific switch to specify ufs1 ? I didn't find it. ​ The disk where I have installed the DFLY and that I want to use to store and share the files from FreeBSD to DFLY and viceversa is da1 : Geom name: da1 Providers: 1. Name: da1 Mediasize: 1000204886016 (932G) Sectorsize: 512 Mode: r0w0e0 descr: TOSHIBA External USB 3.0 lunid: 41736d6564696120 ident: 20130506005976F rotationrate: unknown fwsectors: 63 fwheads: 255 root@marietto:/home/marietto # ls /dev/da1* /dev/da1 /dev/da1p1 /dev/da1p2 => 63 1953259457 da1p2 MBR (931G) 63 1953259457 - free - (931G) => 34 1953525101 diskid/DISK-20130506005976F GPT (932G) 34 2014 - free - (1.0M) 2048 262144 1 efi (128M) 264192 1953259520 2 dragonfly-label64 (931G) 1953523712 1423 - free - (712K) => 63 1953259457 gptid/5da2a10d-668a-11ec-9f5e-e1d55ee21f22 MBR (931G) 63 1953259457 - free - (931G) => 63 1953259457 diskid/DISK-20130506005976Fp2 MBR (931G) 63 1953259457 - free - (931G) Below u can see that I tried to mount the UFS partition while running FreeBSD,but it is not accepted : root@marietto:/home/marietto # mount -t auto /dev/da1p2 /mnt/da1p2 mount: /dev/da1p2: Operation not supported by device root@marietto:/home/marietto # mount -t ufs /dev/da1p2 /mnt/da1p2 mount: /dev/da1p2: No such file or directory ---------------------------------------------------------------------- meatmechdriver · 2021-12-26 21:51 I think this may be due to the by-diskid label consuming the part GEOM. Have you tried mounting /dev/diskid/DISK-20130506995976Fp2? ---------------------------------------------------------------------- loziomario · 2021-12-26 21:55 root@marietto:/usr/home/marietto # mount -t ufs /dev/diskid/DISK-20130506995976Fp2 /mnt/da1p2 mount: /dev/diskid/DISK-20130506995976Fp2: No such file or directory ---------------------------------------------------------------------- meatmechdriver · 2021-12-26 22:56 sorry, that might be /dev/label/diskid. i am not at a system with glabels right now so i don’t remember ---------------------------------------------------------------------- loziomario · 2021-12-26 23:04 nope. it's /dev/diskid,but it does not work. root@marietto:/usr/home/marietto # ls /dev/label ls: /dev/label: No such file or directory root@marietto:/usr/home/marietto # ls /dev/diskid/DISK-2013\* /dev/diskid/DISK-20130506005976F        /dev/diskid/DISK-20130506005976Fp2 /dev/diskid/DISK-20130506005976Fp1 ---------------------------------------------------------------------- loziomario · 2021-12-27 14:11 When I have installed the DFLY I've chosen UFS and not HAMMER because I wanted to mount the UFS partition while on FreeBSD. So it should be UFS. root@marietto:/dev # file /dev/da1p2 /dev/da1p2: character special (1/92) root@marietto:/dev # ls -l /dev/da1p2 crw-r----- 1 root operator 0x15c 26 dic 21:43 /dev/da1p2 root@marietto:/dev # touch /mnt/da1p2/foo root@marietto:/dev # rm /mnt/da1p2/foo root@marietto:/dev # fstyp /dev/da1p2 fstyp: /dev/da1p2: filesystem not recognized so,it's going to be interesting. DragonFlyBSD during the installation offers to use UFS but it does not seem to be UFS. ---------------------------------------------------------------------- jrtc27 · 2022-01-01 15:00 What UFS partition? As far as I can see your da1p2 is just an empty MBR, which is rather odd. Unless you’re talking about the dragonfly- label64 partition, which is a disk label and so you’ll need a geom provider that understands that in order to find the slices inside it. Why is dragonfly using disk labels this decade rather than just more GPT partitions... it’s not 1990. ---------------------------------------------------------------------- loziomario · 2022-01-01 15:12 for the same reason all the DFLY devs are on a irc channel but today no one stay there ? Today all the devs are in the MLs,or Reddit or on the various Forums,but they prefer to live in the past. ---------------------------------------------------------------------- loziomario · 2022-01-01 15:24 \---> you’ll need a geom provider that understands that in order to find the slices inside it. I have no idea about what do you mean with this statement. ---------------------------------------------------------------------- jrtc27 · 2022-01-01 16:17 GEOM is the storage framework in FreeBSD, where everything is represented as a provider and/or consumer, with consumers stacked on top of providers in a pluggable manner. So your disk is a single provider for the whole disk's area, a partition table is a consumer and a set of providers, mirroring is a set of consumers and a single provider, etc. Slices are just what partitions are called in the disklabel world (and, unlike partitions, can overlap; e.g. the "c" slice is the whole disklabel). I originally assumed that, although we had a BSD64 disklabel provider, it would not be the same as DragonFly's, since they have their own partition code, but in fact it's the same. It looks like there's a bug in FreeBSD's implementation though for 512 sector size disks (happens to work for 1k and up). Can you try the following kernel patch? ``` 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); } ``` Edit: hmm, it looks the existing code, whilst a bit dodgy/unclear, should in fact work... ---------------------------------------------------------------------- loziomario · 2022-01-01 16:41 thanks for the patch,but this goes beyond my knowledge and Its not safe for me to play with my informations in this unsafety manner. Maybe you can propose that patch to the developers ? ---------------------------------------------------------------------- jrtc27 · 2022-01-01 16:47 Oh, I see, geom\_part\_bsd64 just isn't compiled into the kernel by default. You can either `kldload geom_part_bsd64` or build a custom kernel with `options GEOM_PART_BSD64`. ---------------------------------------------------------------------- jrtc27 · 2022-01-01 16:53 I am one of the developers... But as my edit says, I since realised that, whilst that patch does make the code a lot more obvious, the existing code should "work". See my other reply for the actual problem. ---------------------------------------------------------------------- loziomario · 2022-01-01 17:38 ok. this is what I tried : root@marietto:/home/marietto # geom disk list Geom name: da2 Providers: 1. Name: da2 Mediasize: 1000204886016 (932G) Sectorsize: 512 Mode: r0w0e0 descr: TOSHIBA External USB 3.0 lunid: 41736d6564696120 ident: 20130506005976F rotationrate: unknown fwsectors: 63 fwheads: 255 root@marietto:/home/marietto # gpart show => 34 1953525101 diskid/DISK- 20130506005976F GPT (932G) 34 2014 - free - (1.0M) 2048 262144 1 efi (128M) 264192 1953259520 2 dragonfly-label64 (931G) 1953523712 1423 - free - (712K) the partition that I want to mount is /dev/da2p2 So,I did : kldload geom_part_bsd64 OK and then : mount -t ufs /dev/da2p2 /mnt/da2p2 mount: /dev/da2p2: No such file or directory ---------------------------------------------------------------------- loziomario · 2022-01-01 17:43 do u want to write here all the commands that I should issue to apply this patch ? thanks. ---------------------------------------------------------------------- grahamperrin · 2022-01-01 20:39 Thanks, and a side note: triple backtick MarkDown doesn't work entirely as expected here. FYI https://old.reddit.com/wiki/markdown ---------------------------------------------------------------------- jrtc27 · 2022-01-01 20:56 1. Run gpart show \*after\* the kldload. 2. It won't be /dev/da2p2. da2p2 is a disklabel, i.e. a nesting of partitions. It'll be da2p2x for some letter x, depending on what slice was used by DragonFly. Mounting da2p2 is like trying to mount da2 itself. ---------------------------------------------------------------------- jrtc27 · 2022-01-01 20:57 As I said in my edit *and* my reply to you: it's not needed, I was wrong ---------------------------------------------------------------------- jrtc27 · 2022-01-01 20:58 Right... too used to a client that supports it ---------------------------------------------------------------------- loziomario · 2022-01-01 22:26 ok : 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. very thanks. ---------------------------------------------------------------------- grahamperrin · 2022-01-02 04:41 :-) Same here. I have a browser extension configured to redirect *nearly* all `www.reddit.com` pages to `old.reddit.com` alternatives because the old (and supported) view allows me to see more with fewer clicks. Fewer distractions and compressions than the new. ---- Reddit aside, the requirement for BBCode at FreeBSD Forums feels *soooo* last century …