LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Enterprise (https://www.linuxquestions.org/questions/linux-enterprise-47/)
-   -   How can I easily mount ntfsclone images using a GUI? (https://www.linuxquestions.org/questions/linux-enterprise-47/how-can-i-easily-mount-ntfsclone-images-using-a-gui-661484/)

DaneM 08-08-2008 04:00 PM

How can I easily mount ntfsclone images using a GUI?
 
Hello.

I'm running Ubuntu 8.04.1 Desktop AMD64.

I'm spearheading a project at the computer shop that I work at that requires me/the other technicians to be able to clone an NTFS partition into an image file (NOT using the -s option), and mount it using a point-and-click interface. The problem is that I haven't been able to figure out how to do this, either with or without some serious config file hacking.

Here's how I want the hard drive mounted (WITHOUT editing /etc/fstab):

Code:

mount -t ntfs-3g /path/to/whatever.img /media/mountpoint -o users,exec,uid=$UID,gid=$GID,allow_others,umask=002
This works in the console, if I substitute $SUDO_UID and $SUDO_GID for $UID and $GID respectively, but for some reason, it ignores the users,umask,uid=,gid= options. (When I look in /etc/mtab or type "mount", it doesn't show them.) Accordingly, the user that I want to be able to umount the file via point-and-click is unable to do so.

So far, I've been using a script I made (with the above mount command in it) to mount the image via point-and-click. This required me to add the following line into /etc/mime.types:

Code:

application/x-ntfs-image    .img
...and add the following into mount-ntfs-img.desktop (put into /usr/share/applications):

Code:

[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=mount-ntfs-img.desktop
Comment=A BASH script to mount .img ntfs clone files via fuse-mount.
Exec=gksudo /usr/local/sbin/mountfile.sh %f
Icon=gnome-terminal
Terminal=true
StartupNotify=false
MimeType=application/x-ntfs-image;
Type=Application
Categories=GNOME;Core;
OnlyShowIn=GNOME;
Name[en_US]=mount-ntfs-img.desktop

I put my script, mountfile.sh into /usr/local/sbin:

Code:

#!/bin/bash

partpath=$1
part=`echo $partpath | sed -e 's/^.*\///' -`
mountpoint=$part
counter=""

mountit()
{
mount "$partpath" "/media/$mountpoint" -o exec,umask=002,uid=$SUDO_USER,gid=fuse
}

ifvalid()
{
if [ ! -d "/media/$mountpoint" ]
        then mkdir /media/$mountpoint >/dev/null 2>&1
fi

if [ -f /media/$mountpoint/* ]
        then
        let counter+=1
        mountpoint=`echo $mountpoint | sed -e 's/-[0-9]*//g' -`-$counter
        ifvalid
        else
        mountit
fi
}

ifvalid

if mount | grep "$partpath on /media/$mountpoint" >/dev/null 2>&1
        then
        echo "Your image file ($partpath) is now mounted on /media/$mountpoint."
        read -n 1 -p "Press any key to finish."
fi

(Legal stuff: Script is my work, as an employee at PCI Computer Services, and cannot be used for commercial purposes without written permission. End of legal stuff.)


I then right-clicked on the .img file I wanted to mount and told it to open with mount-ntfs-img. This mounted it nicely. Unfortunately, when I go to unmount it by right-clicking on the "partition's" image on the Desktop, it tells me that it's not in /etc/fstab, and that I'm not root, and therefore can't umount it.

I tried going into System -> Authorizations (in GNOME) and giving my user explicit permission to unmount all volumes mounted by other users, but to no avail.

I think I'm going about this the wrong way. It seems that the Authorizations I gave my user only apply to stuff mounted by HAL or some such, and I don't know how to make that work for me. Furthermore, I don't know why it's ignoring my various mount options. So, my question (in a nutshell) is this:

How can I mount an ntfsclone image (NOT using the -s option) via right-clicking on the .img file in GNOME, and unmount it the same way, as any user? Even if only the user mounting it can unmount it, that would be fine, so long as I can do so using a point-and-click method.

PLEASE help me out here! :-) I'm really stumped, and my boss is going to start wondering what's taking so long (and I think it would be really cool to know how to do this for my own purposes).

Thanks in advance for any help you are able to render.

--Dane

grepmasterd 08-08-2008 05:51 PM

hmm, why don't you want to update /etc/fstab?

and have you tried the 'loop' option (mount -o loop)

DaneM 08-08-2008 07:24 PM

Thanks for the reply!

We (at the computer shop) intend to do this with lots of different drives/images. We don't want to end up with a cluttered /etc/fstab, or have to do anything from the command prompt. (While I'm reasonably Linux savvy, the other techs at the shop are used to Windows and Mac.)

I suppose it would be possible to include some fstab editing in my script, assuming it wouldn't ignore my mount options as mentioned above. Still, though, I'm hoping to do it in a cleaner way (such as using gnome-mount, hal, or some such), and not have to do any more scripting than absolutely necessary. Also, I suspect that it's possible to do without any command-line intervention, because Ubuntu/Gnome/Linux allows one to mount other ntfs partitions without having to edit the fstab or mess with the command line; I just don't know how it does it.

For some reason, the -o loop option isn't working (even though the ntfsclone man page specifies its use). The .img files I've made DO mount just fine using the commands I posted, but just not from a GUI without me having to hack together a script and a .desktop file. Really, I'd like to do it as close to the "GNOME way" as possible.

Thanks again for your reply; this is really a stumper for me. Please don't take my preconceived notions as a dismissal of your suggestions. :-)

--Dane


All times are GMT -5. The time now is 07:51 PM.