# Perplexing mount_udf / mdconfig dvd iso problem



## Ogham (Aug 1, 2012)

I seem to be having no luck mounting a dvd iso image, I have verified the sha1sum.


```
# mdconfig -a -f en_windows_7_ultimate_x64_dvd_x15-65922.iso 
md0
# mount_cd9660 /dev/md0 /mnt
# ls -la /mnt
total 4
dr-xr-xr-x   1 root  wheel   112 Jul 14  2009 .
drwxr-xr-x  18 root  wheel  1024 Jul 31 22:21 ..
-r-xr-xr-x   1 root  wheel   135 Jul 14  2009 readme.txt
# cat /mnt/readme.txt 
This disc contains a "UDF" file system and requires an operating system
that supports the ISO-13346 "UDF" file system specification.
# umount /dev/md0
# mount_udf /dev/md0 /mnt
mount_udf: /dev/md0: Invalid argument
# mount_udf -v /dev/md0 /mnt
mount_udf: /dev/md0: Invalid argument
# ls /dev/md*
/dev/md0        /dev/mdctl
# file -s /dev/md0
/dev/md0: ISO 9660 CD-ROM filesystem data 'GRMCULXFRER_EN_DVD             ' (bootable)
# udfclient /dev/md0 
        bufcache thread initialising
Opening device /dev/md0
Got error executing SCSI command, assuming IDE disc
 UDF: no explicit support for disc devices yet for this operating system.
: No such file or directory
Trying readonly access...
: No such file or directory
UDF: warning... reading/writing on 'disc' device

UDF Dump of disc in device /dev/md0
UDF sessions : No 




Resulting list of alive sets :

UDF volume sets marked alive :

Directory listing of /
UDF working directory is     /
Current FS working directory /usr/local/sabnzbd/Downloads/complete/en_windows_7_ultimate_x64_dvd_x15-65922
UDF> ls
Directory listing of /
UDF> quit
Closing discs
```

It seems either I am doing something wrong, or this disc has a peculiar layout unsupported by FreeBSD. I'm starting to wonder if the UDF filesystem is supported at all?


----------



## Ogham (Aug 1, 2012)

I've found this comment on the mailing lists:

http://lists.freebsd.org/pipermail/freebsd-questions/2010-June/218040.html


> On Thursday 24 June 2010 11:06:59 M. Vale wrote:
> 
> > So my question is is possible to mount an UDF disk on FreeBSD or is me that
> > is doing something wrong ?
> ...



Which I am inclined to think is still the case. I doubt that support has simply been omitted, is it possible that proprietary code is involved - preventing inclusion in the base system?

I also burnt the iso to disk and attempted to mount_udf /dev/cd0 /mnt, I recieved exactly the same error.

I should also mention that regardless of attempting to mount the iso image via md0, or the physical disk via cd0, I see the following in dmesg:


```
FSD does not lie within the partition!
```

_Can anyone suggest an alternative way to access the disk contents on FreeBSD?_ (I was hoping to avoid using VirtualBox)

Cheers,
Ogham


----------



## SirDice (Aug 1, 2012)

I'm guessing that, even though it's named as such, it's not really an ISO file.

There are various formats used by burn programs, but not all of them are strict ISO images.


----------



## kpa (Aug 1, 2012)

A DVD disk can have multiple directory hierarchies, one conforming to just strict ISO 9660, one with UDF directory hierarchy with long filenames etc., all with the same file contents. An image of such disk is still a valid ISO file, it's just a matter of which hierarchy is examined how it looks like. That ISO file of windows 7 ultimate x64 is certainly a valid ISO file.


----------



## Ogham (Aug 1, 2012)

SirDice said:
			
		

> I'm guessing that, even though it's named as such, it's not really an ISO file.
> 
> There are various formats used by burn programs, but not all of them are strict ISO images.



I think there is definitely something different about this iso image, it seems as if it is part iso9660/CDFS, and part iso13346/UDF... I am very perplexed!

I am just hoping there is some other way (ports) I can access the content?

Here is an isoinfo dump from sysutils/cdrtools :


```
# isoinfo -d -i en_windows_7_ultimate_x64_dvd_x15-65922.iso
CD-ROM is in ISO 9660 format
System id: 
Volume id: GRMCULXFRER_EN_DVD
Volume set id: GRMCULXFRER_EN_DVD
Publisher id: MICROSOFT CORPORATION
Data preparer id: MICROSOFT CORPORATION, ONE MICROSOFT WAY, REDMOND WA 98052, (425) 882-8080
Application id: CDIMAGE 2.54 (01/01/2005 TM)
Copyright File id: 
Abstract File id: 
Bibliographic File id: 
Volume set size is: 1
Volume set sequence number is: 1
Logical block size is: 2048
Volume size is: 1574554
El Torito VD version 1 found, boot catalog is in sector 22
NO Joliet present

No SUSP/Rock Ridge present
Eltorito validation header:
    Hid 1
    Arch 0 (x86)
    ID 'Microsoft Corporation'
    Cksum 4C 49 OK
    Key 55 AA
    Eltorito defaultboot header:
        Bootid 88 (bootable)
        Boot media 0 (No Emulation Boot)
        Load segment 0
        Sys type 0
        Nsect 8
        Bootoff 2DE 734
```


----------



## Ogham (Aug 1, 2012)

kpa said:
			
		

> A DVD disk can have multiple directory hierarchies, one conforming to just strict ISO 9660, one with UDF directory hierarchy with long filenames etc., all with the same file contents. An image of such disk is still a valid ISO file, it's just a matter of which hierarchy is examined how it looks like. That ISO file of windows 7 ultimate x64 is certainly a valid ISO file.



I thought that might be the case. Do you know if there is a way I can define which hierarchy is examined, or if there are any tools I can use to extract the UDF component?

Right now, it looks like I will have to build emulators/virtualbox-ose in the near future!


----------



## Ogham (Aug 1, 2012)

I have finally found a solution, and I am sure many of you will find it useful in the future! :e

It does not appear that the base system supports the majority of UDF versions, but the archivers/p7zip port does!

Using only:

```
7z e en_windows_7_ultimate_x64_dvd_x15-65922.iso
```
I was able to extract the files from the UDF filesystem.


----------



## Ogham (Aug 6, 2012)

*Successful creation of Win 7 USB installer from with FreeBSD*

Success at last! I finally managed to make a bootable Windows 7 USB installer from within FreeBSD using nothing but the .iso image.

My aim was to create a NTFS filesystem on a USB stick, extract the contents of the installation .iso, and dd a Windows 7 MBR onto the stick.

It turned out that this was not as simple as it sounded!

I encountered the following problems during this process:


mount_ufs is not capable of mounting all UDF versions/configurations
sysutils/udfclient suffers from the same problem
sysutils/ntfsprogs is required in addition to sysutils/fusefs-ntfs if you want to make NTFS filesystems
sysutils/fusefs-ntfs does not seem to be capable of copying large files, and is unpredictable
sysutils/fusefs-ntfs has some configuration knobs, but they either failed to help or resulted in an _unacceptable_ transfer speed
emulators/virtualbox-ose USB (1.0) support is minimal, it appears there is no support whatsoever for mass storage devices

I hoped to avoid installing VirtualBox for this task, but it turned out that the only solution was to use VirtualBox's rawdisk feature (createrawvmdk):


```
VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk -rawdisk /dev/da0
```

Many thanks to _nox_ on the #FreeBSD freenode IRC channel for the idea 

I should also note, that I created the rawdisk as root, and ran VirtualBox as root to get around some device permission issues I encountered (I was at the end of my tether at this point, I am sure these issues could have been rectified with the correct device permissions).

This allowed me to expose my USB stick to the Windows guest instance as an IDE/SATA disk drive, and I was able to use the relevant Windows commands to create the bootable USB stick.

The USB stick was created as expected, and has functioned perfectly.

Installing Windows 7 on my laptops second SSD, where the first SSD already contains a FreeBSD install was a different story! - It involved a screwdriver! Aaarrgh! x(


----------



## vslash (Nov 18, 2014)

In order to complete this HowTo, it could be nice to shed a light on the quote above:
_"I was able to use the relevant Windows commands to create the bootable USB"_​
Then, here's the complete HowTo:
*Successful creation of Windows 7 USB installer from an ISO image under FreeBSD*

plug your USB drive or key (unmount it from your system if you are using an automounter or something like)
use the wonderful tip from Ogham/IRC: `$ VBoxManage internalcommands createrawvmdk -filename /path/to/file.vmdk -rawdisk /dev/da0`
Attach your /path/to/file.vmdk to your VM appliance (settings > storage > following your configuration, primary slave could be right choice)
Start your VM (e.g. Windows XP)
mount your ISO (e.g. Windows 7) through VirtualBox>Devices>CD/DVD Devices ...
Format your USB key: there are two ways in order to format your new disk, through Admin Tools+ComputerManagement+StorageManagement OR using cmd.exe: so, launch cmd.exe as admin 
	
	



```
diskpart
list disk
select disk n (where n is the number of your USB drive)
clean
create partition primary
active
format fs=fat32 quick
assign
exit
```

make your new USB partition bootable e.g.:
- your DVD is mounted as d:
- your new FAT32 partition is mounted as e:

```
d:
cd boot
bootsect.exe /nt60 e:
```
Then copy your DVD to your USB/FAT32 partition: `xcopy d:\*.* e: /e /f /h`
That's all folks! Thanks to Ogham for the tips, I encountered the same troubles.


----------



## eriknstr (May 4, 2017)

vslash, I followed your steps for the most parts, but I modified it a bit to save a little time since presumably writing the ISO to the USB memory stick through VirtualBox will give USB 1.0 speeds or slower.

*Create bootable USB stick from Windows 7 install ISO under FreeBSD*

You'll need VirtualBox and a Windows 7 VM for the first set of steps. https://www.freebsd.org/doc/handbook/virtualization-host-virtualbox.html

For the last set of steps you will need the `7z` command from p7zip. (`pkg install p7zip` as root if you don't have it.)

1. Plug USB drive or key into computer and ensure it's not mounted, unmount if it is.
2. `doas chmod 666 /dev/da0`
3. `doas VBoxManage internalcommands createrawvmdk -filename win7usb.vmdk -rawdisk /dev/da0`
4. `doas chown erikn:erikn win7usb.vmdk`
5. `chmod 660 win7usb.vmdk`
6. `dd if=/dev/zero of=/dev/da0 bs=16m count=1`
7. Attach `win7usb.vmdk` to a Windows 7 VM.
8. Boot VM.
9. In VM using `cmd.exe` as you said, 
	
	



```
diskpart
list disk
select disk n (where n is the number of your USB drive)
clean
create partition primary
active
format fs=fat32 quick
assign
exit
```
10. The USB disk is E:
11. Mounted ISO on VM. The ISO appears as D:
12. Using PowerShell as Administrator, 
	
	



```
cd d:\boot\
.\bootsect.exe /nt60 e:
```
So up until this point I did pretty much exactly the same thing that you did but now I do something different.

13. Shut down the VM and detach win7usb.vmdk from VM.
14. `rm win7usb.vmdk`
15. `sync`
16. Unplug the disk and plug it back in.
17. Mount it unless you have an automounter that has already done so for you. 
	
	



```
doas chmod 666 /dev/da0s1
mkdir -p ~/tmp/win7usb/
mount_msdosfs /dev/da0s1 ~/tmp/win7usb/
```
18. `cd ~/tmp/win7usb/`
19. `7z x /var/tmp/en_windows_7_professional_with_sp1_x64_dvd_u_676939.iso` as suggested by Ogham mentioned above that 7-zip is able to extract UDF but it's important to use "x" extraction which will preserve full paths, not "e" extraction as Ogham wrote, as "e" flattens the structure and puts all files directly in the target directory.
20. `sync`
21. `umount ~/tmp/win7usb/`
22. `rmdir ~/tmp/win7usb`

Enjoy bootable USB stick.


----------



## free-and-bsd (May 6, 2017)

My goodness... you guys rox. Got to be introduced into the FreeBSD (forums) hall of fame  When I needed the same thing (urgently, I confess) I just shamefully compromised by using a windows machine with all its (doubtful in other cases but obvious in this one) advantages.


----------

