Mounting a DOS disc image in Linux/Ubuntu

discuss PC<>Acorn file transfer issues & the use of FDC, XFER, Omniflop/disk etc.
User avatar
BeebMaster
Posts: 2473
Joined: Sun Aug 02, 2009 4:59 pm
Location: Lost in the BeebVault!
Contact:

Mounting a DOS disc image in Linux/Ubuntu

Postby BeebMaster » Mon Oct 20, 2014 11:56 am

Following on from my contribution to this thread, where I speculated that an easyish way to fill up your Master 512 DOS Plus partition on a flash type drive would be to extract the DRIVE_C file from an image copy of the flash card containing DOS Plus and then mount this as a drive and copy files into it and then write it back to the card...

...is it actually possible? I reported problems trying to write to a mounted image file when using Ubuntu/Linux. I had no trouble actually mounting the DRIVE_C file and reading its contents, but any attempt to write gave me errors.

Preferably a drag-and-drop GUI type method, but I would consider copying the files using the command line, but I don't know the syntax in Linux for moving files around using command lines.

I've tried a few different image files, my own DRIVE_C file, one from an image file supplied with ADFS Explorer, and various 720K DOS floppy images, some downloaded and some I'd made myself. They all mount but none of them are writeable.
Image

Gimilzor
Posts: 32
Joined: Mon Oct 06, 2014 6:48 pm

Re: Mounting a DOS disc image in Linux/Ubuntu

Postby Gimilzor » Mon Oct 20, 2014 9:56 pm

I certainly don't see any reason why it shouldn't be possible.

I've definitely mounted dos floppy images in linux (suse in my case but that shouldn't make any difference) using the loop interface and written to them without issues.

My first thought looking at the commands in the last post of the thread you've linked to is are you sure the directory /mnt/dosdisk is writeable by the user you're logged in as?

Wouldn't hurt to issue a

Code: Select all

sudo chmod 777 /mnt/dosdisk


and then try the mount and see if that makes any difference.

I've never used a master 512 so don't know if the partition is in any way different to what a normal drive partition would look like - is there any way you could get an image file to me? Would be more than happy to have a play around and see what I can work out.

Oh, and by the way - linux commands for copying/moving files are cp and mv respectively.

Basically :

Code: Select all

cp (-R) (source) (destination)
where -R indicates recursive - mv if you're moving a directory is inherently recursive. There are a couple of other options that are sometimes useful :

Code: Select all

 -p - preserve permissions
-v - verbose mode

User avatar
roland
Posts: 2808
Joined: Thu Aug 29, 2013 8:29 pm
Location: Born (NL)
Contact:

Re: Mounting a DOS disc image in Linux/Ubuntu

Postby roland » Tue Oct 21, 2014 9:47 am

It is also possible that the DOS image is mounted read-only. You can check this after the image is mounted with the mount command, e.g.:

Code: Select all

[rls@linux01 rls]$ mount
/dev/xvda1 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/xvdb1 on /srv type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)


If so, mount the image with the option -w or -o rw which will mount it read/write.
256K + 6502 Inside
MAN WOMAN :shock:

Prime
Posts: 2345
Joined: Sun May 31, 2009 11:52 pm

Re: Mounting a DOS disc image in Linux/Ubuntu

Postby Prime » Tue Oct 21, 2014 11:06 am

Assuming :

Your user is beebmaster and has a uid of 1000, and gid of 2000, you can find these out by looking at the password file, or typing the id command at a shell prompt.

What you probably need to do is :

sudo mount /path_to_image /mountpoint -o loop, uid=1000,gid=2000

This will set the owner of the mounted files to be the same as the user you are logged in as.

Sample session showing this :

Code: Select all


phill@c64:~/disks> sudo mount pcdos5.dsk /mnt -o loop
phill@c64:~/disks> ls -lad /mnt
drwxr-xr-x 2 root root 3584 Jan  1  1970 /mnt
phill@c64:~/disks> touch /mnt/X
touch: cannot touch ‘/mnt/X’: Permission denied
phill@c64:~/disks> sudo umount /mnt

phill@c64:~/disks> id
uid=1000(phill) gid=100(users) groups=100(users)
phill@c64:~/disks> sudo mount pcdos5.dsk /mnt -o loop,uid=1000,gid=1000
phill@c64:~/disks> ls -lad /mnt
drwxr-xr-x 2 phill 1000 3584 Jan  1  1970 /mnt
phill@c64:~/disks> touch /mnt/X
phill@c64:~/disks> ls -la /mnt/X
-rwxr-xr-x 1 phill 1000 0 Oct 21 12:17 /mnt/X
phill@c64:~/disks> sudo umount /mnt
phill@c64:~/disks>




Note that Gimilzor's sugestion of using chmod on the mount point before mounting won't work as the permissions will get replaced by those from the filesystem being mounted (or the defaults in this case).

Also be aware that you **MUST** unmount the image once you have written files to it before trying to write it back to the CF card, Linux / Unix cache writes, un-mounting the filesystem forces them to be written.

Cheers.

Phill.

paulb
Posts: 784
Joined: Mon Jan 20, 2014 9:02 pm

Re: Mounting a DOS disc image in Linux/Ubuntu

Postby paulb » Tue Oct 21, 2014 2:18 pm

Prime wrote:Assuming :

Your user is beebmaster and has a uid of 1000, and gid of 2000, you can find these out by looking at the password file, or typing the id command at a shell prompt.

What you probably need to do is :

sudo mount /path_to_image /mountpoint -o loop, uid=1000,gid=2000

This will set the owner of the mounted files to be the same as the user you are logged in as.


Yes, I think it's just a straight permissions issue. Indeed, you can probably make things even easier by creating the mountpoint (the directory where the image appears when mounted) in some directory you already have write access to (unlike /mnt), but that's mostly just an issue of tidiness and being able to leave random clutter in places of no importance.

Unfortunately, you will still need to use the uid option to take ownership of the mounted image because mount will change the ownership of the mountpoint while the image is mounted and won't let you change it using the normal commands.

And as Phill says, using umount is essential once you're done to make sure that everything gets copied into the image.

User avatar
BeebMaster
Posts: 2473
Joined: Sun Aug 02, 2009 4:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Mounting a DOS disc image in Linux/Ubuntu

Postby BeebMaster » Tue Oct 21, 2014 5:19 pm

Right, I'll have a go at that when I'm back home tomorrow. I've been a bit busy with this sort of thing today:
HMQEIIOctober2014-3.jpg
Image

User avatar
BeebMaster
Posts: 2473
Joined: Sun Aug 02, 2009 4:59 pm
Location: Lost in the BeebVault!
Contact:

Re: Mounting a DOS disc image in Linux/Ubuntu

Postby BeebMaster » Wed Oct 22, 2014 1:30 pm

Right, that seems to have done the trick. The chmod didn't work on its own, but the mount with extra options did.

I used all the right options, but not necessarily in the right order:

Code: Select all

sudo mount -o loop,uid=1000,gid=2000 DRIVE_C /media/dosdisc


And I can then write things to the image, and unmounting it and mounting it again proves it has been saved.

Next to put the modified image back in the CF drive and see what DOS Plus makes of it...
Image


Return to “software & utilities for the pc, mac or unix”

Who is online

Users browsing this forum: No registered users and 1 guest