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

Hello.

I would like to reformat one of my USB disks using the UFS1 file system. So,I tried to do that with this command :

Code:
root@marietto:/usr/home/marietto # newfs -O 1 /dev/da2

but it says :

newfs: /dev/da2: failed to open disk for writing

also :

Code:
root@marietto:/usr/home/marietto # fdisk -I /dev/da2

******* Working on device /dev/da2 *******
fdisk: Failed to write MBR. Try to use gpart(8).

and :

Code:
root@marietto:/usr/home/marietto # ls /dev/da2
/dev/da2

root@marietto:/usr/home/marietto # gpart destroy -F da2
gpart: Device busy

root@marietto:/usr/home/marietto # umount /mnt/da2p1
umount: unmount of /mnt/da2p1 failed: Device busy

root@marietto:/usr/home/marietto # ls /mnt/da2p1

=>        34  1953525101  da2  GPT  (932G)
          34        2014       - free -  (1.0M)
2048  1953523087    1  freebsd-ufs  (932G)

it is very intertwined. I dislike very much all this unnecessary complexity. And do not try to claim that it is not true. It may not be true for you, because you are experienced, but for a newbie,to understand the underlying logic, in cases like these, it is not easy.
 
the right command is :

Code:
newfs -O 1 /dev/da2

BUT before that it worked,I had to reboot the machine. it was wrapped.
 
Anyway,it's not the only command that it needs. The next command seems to be :

Code:
gpart add -t freebsd-ufs da2

and it creates something like this :

Code:
=>        40  1953525088  da2  GPT  (932G)
          40  1953525088    1  freebsd-ufs  (932G)

=>        40  1953525088  diskid/DISK-20130506005976F  GPT  (932G)
40  1953525088                            1  freebsd-ufs  (932G)

it seems that it works,but I'm not sure that it is formatted with the UFS1 file system. How can I be sure ?
 
I'm not able to understand if it is ufs1 or 2 :

Code:
gpart show :

=>        40  1953525088  da2  GPT  (932G)
          40  1953525088    1  freebsd-ufs  (932G)

=>        40  1953525088  diskid/DISK-20130506005976F  GPT  (932G)
40  1953525088                            1  freebsd-ufs  (932G)

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:/usr/home/marietto # file -s /dev/diskid/DISK-20130506005976F

/dev/diskid/DISK-20130506005976F: DOS/MBR boot sector; partition 1 : ID=0xee, start-CHS (0x0,0,2), end-CHS (0x3ff
,255,63), startsector 1, 1953525167 sectors, extended partition table (last)

root@marietto:/usr/home/marietto # file -s /dev/diskid/DISK-20130506005976Fp1
/dev/diskid/DISK-20130506005976Fp1: data
 
Or if you want to add partitions use a different order of commands:
Code:
gpart delete -i 1 /dev/da2
gpart destroy /dev/da2
gpart create -s GPT /dev/da2
gpart add -t freebsd-ufs /dev/da2
newfs -O 1 /dev/da2s1
file -s /dev/da2s1
 
Code:
newfs -O 1 /dev/da2
file -s /dev/da2

/dev/da2: DOS/MBR boot sector; partition 1 : ID=0xee, start-CHS (0x0,0,2), end-CHS (0x3ff,255,63), startsector 1,
1953525167 sectors, extended partition table (last)
 
Code:
root@marietto:/usr/home/marietto # gpart delete -i 1 /dev/da2
gpart: arg0 'da2': Invalid argument
 
Code:
root@marietto:/usr/home/marietto # gpart destroy /dev/da2
gpart: arg0 'da2': Invalid argument

root@marietto:/usr/home/marietto # gpart destroy da2
gpart: arg0 'da2': Invalid argument

root@marietto:/usr/home/marietto # gpart destroy -F da2
gpart: arg0 'da2': Invalid argument

root@marietto:/usr/home/marietto # gpart destroy -F /dev/da2
gpart: arg0 'da2': Invalid argument
 
There is no partition table. so try:
Code:
gpart create -s GPT /dev/da2
gpart add -t freebsd-ufs /dev/da2
newfs -O 1 /dev/da2s1
file -s /dev/da2s1
 
if you want to use the whole disk as ufs you do not add partitions after
This.

You need to understand the difference between disks and partitions: da2 is a disk. It is very unusual (and bad practice) to create a file system on a disk. In contrast, da2p1 is a partition on disk da2. It is common to create file systems on partitions. The tool to create/destroy partitions is gpart. If you use gpart on a disk *after* creating the file system, you will likely damage the file system, or perhaps the system won't let you.

I suggest that you read the handbook chapter about storage.

And, I have another question: Why do you want to create a UFS1 disk? That file system format seems to be pretty obsolete. Is there a reason for using it?
 
Yes. I've prepared 10 virtual machines on FreeBSD that I have stored on a UFS2 disk. I would like to boot these VMs on the DragonFlyBSD with qemu + nvmm,but it does not support the UFS2 type fs disks,but I read that it supports the UFS1 type.
 
for sure there are. but at the moment I didn't find them. yes,my vms are in raw format. they are img files,since bhyve does not support qcow2. But I can convert a raw format in a qcow2 format because qemu likes it. But at the moment the problem is into which kind of format should I reformat a disk that FreeBSD and DFLY can read and write because I need to transfer there the vms. I suspect that DFLY can't mount ext4 or ntfs disks. Or if it can,it is not a good idea. maybe I can format the disk where I will store the img files in another format that at the moment I'm not figuring out what it could be.
 
this is how DFLY "reads" the disk that I have prepared before :

root@marietto:/home/marietto # gpt -v show /dev/da12

gpt show: /dev/da12: mediasize=1000204886016; sectorsize=512; blocks=1953525168
gpt show: /dev/da12: Bad CRC in GPT table at sector 2
start size index contents
0 1 - PMBR
1 1953525167 - Unused

it seems that it is not well prepared by FreeBSD or what ? DFLY says "bad CRC"...
 
You only need hammer as filesystem to store the raw images.
The filesystem on the raw images themselves can then be anything including linux-ext4,freebsd-zfs, as long as it's contents is understood by the qemu-virtualiser, including the boot procedure.
Code:
qemu-system-x86_64 -drive if=virtio,file=MYFREEBSDDISK.img,format=raw
You might need to tweak the "vfs.root.mountfrom in /boot/loader.conf" and "/etc/fstab" on the images. Because device names running under qemu "can sometimes" be different.
 
I can reformat a disk using the hammer2 fs (the fs that Im using on DFLY) if FreeBSD can read and write on this kind of fs,because actually my img files are stored in a UFS2 fs disk,so I should copy these files from that UFS2 disk to the hammer2 fs disk. I'm not sure that I can format the disk using linux-ext4. If FreeBSD at the moment does not have a stable ext4 fs driver,how can you think that DFLY has it ?
 
Do it Chad style — write raw images directly to partitions (might require specifically formatted raw images, not sure about details).
 
Personally i like VM's on flatfiles because they have the advantage of very easy backup. You can use memory disks. And the device names can more easily be guessed.
 
Back
Top