LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   How to auto-mount a NTFS RAID partition? (https://www.linuxquestions.org/questions/linux-hardware-18/how-to-auto-mount-a-ntfs-raid-partition-769520/)

giyad 11-16-2009 04:35 PM

How to auto-mount a NTFS RAID partition?
 
Ok, I have a maybe unique problem as it took me a really long time to find a solution for mounting my RAID (kudos to mostlyharmless for helping figure this one out)

Now, it seems that every time I restart my computer, the partitions created by kpartx are no longer there. I have to run every time I boot up:

Code:

sudo kpartx -a /dev/mapper/nvidia_facfcied
So, this means also that I am not able to auto-mount the partition.

Here are my questions:

1. How can I have it so that the partitions are either permanent, or create a script that runs every time I login that will run that code (without requesting my password)?

2. How do I auto-mount the drive once I've solved the first question?

3. The thing is I want to use this NTFS RAID as a media share. If I have to create the partition mappings each time I boot up, and then mount, share settings probably won't stick. Will I be able to save my share settings?

Robhogg 11-16-2009 05:23 PM

I've no real experience of NTFS raid, so there may be a more "proper" way of doing this, but the simplest would be to use the normal startup scripts system.

Many Linux distros will have a script called something like boot.local or rc.local in /etc or /etc/init.d, that is executed at the end of the boot process. By default, these scripts usually do nothing, and are just there for users to add anything else that they need to run during boot. Just add the commands needed to initialise and mount the devices, to these scripts.

If there is no such script on your system, you could create one, make it runnable, and then create a start link to it from the directory for your default runlevel. For example:

Code:

sudo bash # get a root shell
cat <<-END > /etc/init.d/ntfs_init.sh # create the script
#!/bin/bash
kpartx -a /dev/mapper/nvidia_facfcied
# add any other commands that are needed here

exit 0
END
chmod 700 /etc/init.d/ntfs_init.sh # make it runnable by root
runlevel # get the current runlevel (the second number)
# the command below will add a startup link for runlevel 2 (Debian default)
# change as appropriate
ln -s /etc/init.d/ntfs_init.sh /etc/rc2.d/S99ntfs_init
# S means start, 99 is the priority (1 is the highest, but this command
# probably wants to come quite late)


mostlyharmless 11-16-2009 05:41 PM

Quote:

#!/bin/bash
kpartx -a /dev/mapper/nvidia_facfcied
then put right after that
mount -t ntfs-3g /dev/mapper/nvidia_facfcied2 /media/Z

giyad 11-16-2009 06:10 PM

Thanks so much guys! GOT IT WORKING :-)

Code:

sudo gedit /etc/rc.local
This is what was in the rc.local file:
Quote:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

exit 0
This is what I modified it to:

Quote:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
kpartx -a /dev/mapper/nvidia_facfcied
mount -t ntfs-3g /dev/mapper/nvidia_facfcied2 /media/Z

exit 0
Works like a charm!

giyad 11-17-2009 12:38 AM

I do have a question for you guys. I was planning on running my current Windows installation virtually in Ubuntu. But, now that I've got the RAID mounted in Ubuntu, would running that drive cause problems? I know that I'm not supposed to mount any drives simultaneously in the VM and the host OS.

mostlyharmless 11-18-2009 09:19 AM

Correct, you shouldn't mount the drive under Ubuntu and have the Windows installation see the drive at all. You can run your Windows partition and then mount the Ubuntu served RAID partition as a network drive though, or as a "shared drive". Be careful that when you run Windows that the RAID is not touched at all by Windows; not mounted, not recognized, period.

While you can run your physical Windows partition directly under a VM, and go back to dual booting if you need to (for games, eg.), you might have some Windows activation problems (though not insurmountable) and you increase the chances of something bad happening to the Windows installation. You're probably better off running an entirely separate VM with a new virtual drive for Windows if you can avoid dual booting. It's just my opinion, having done it both ways.

giyad 11-19-2009 01:31 AM

Quote:

Originally Posted by mostlyharmless (Post 3761361)
Be careful that when you run Windows that the RAID is not touched at all by Windows; not mounted, not recognized, period.

Ummm... how do you go about doing that? I mean won't the RAID automatically mount in Windows, and definitely be recognized (Or does the VM work differently)?

So it sounds like my only option would be to unmount the RAID in Ubuntu whenever I want to run the virtual machine.

Honestly, I think I'm going to end up not using that partition to boot up in the VM, but I want to try it out haha. I'm going to be installing Windows 7 soon anyway, so I don't really care if something happens to my Windows partition (everythings backed up on the RAID, and the RAIDs backed up to an external).

mostlyharmless 11-19-2009 09:59 AM

Quote:

I mean won't the RAID automatically mount in Windows, and definitely be recognized (Or does the VM work differently)?
When you set up the VM, you'll specify the harddisk to use. You should only specify the installation disk, not the RAID array. Before you do that, you'd have to boot into Windows the regular way and remove that RAID array and driver from your Windows install so that it is seen as a foreigh partition, just like your Linux ones.

Quote:

So it sounds like my only option would be to unmount the RAID in Ubuntu whenever I want to run the virtual machine.
But this would be safer of course.

giyad 11-19-2009 10:12 AM

Quote:

Originally Posted by mostlyharmless (Post 3762794)
When you set up the VM, you'll specify the harddisk to use. You should only specify the installation disk, not the RAID array. Before you do that, you'd have to boot into Windows the regular way and remove that RAID array and driver from your Windows install so that it is seen as a foreigh partition, just like your Linux ones.


But this would be safer of course.

Yeah, I definitely want teh RAID to still be accessible from Windows when i choose to boot up from Windows normally, so I'd probably have to unmount whenever I run the VM. You're right this doesn't sound like a safe solution, maybe I will just run a separate installation.

Thanks mostlyharmless you've been great at getting me settled with Linux :-)

Actually, to think of it, I've been loving scripts, maybe there would be a way to have Ubuntu automatically unmount the RAID whenever I boot up the VM... that way I wouldn't have to worry about forgetting!

kad_mann 12-17-2009 04:18 AM

Quote:

Originally Posted by mostlyharmless (Post 3761361)
Correct, you shouldn't mount the drive under Ubuntu and have the Windows installation see the drive at all. You can run your Windows partition and then mount the Ubuntu served RAID partition as a network drive though, or as a "shared drive". Be careful that when you run Windows that the RAID is not touched at all by Windows; not mounted, not recognized, period.

Rubbish.

giyad 12-17-2009 12:03 PM

Quote:

Originally Posted by kad_mann (Post 3795083)
Rubbish.

care to elaborate?

kad_mann 12-18-2009 07:29 PM

Quote:

Originally Posted by giyad (Post 3795664)
care to elaborate?

If the suggestion you were given has the even the remotest amount of validity to it then there is absolutely no point whatsoever to having NTFS support in Linux, let alone NTFS read/write support. I share a four disk, NTFS-formatted 3TB SATA RAID5 array, and an NTFS-formatted four disk 1.5TB RAID10 PATA array between my Linux host and Windows and up to two different distros of Linux running simultaneously in VMs.

As for the idea of serving RAID as a network drive, well... *CHOKE* *GAG* COUGH*

All that need be done is mount the drive then share it between the running VM's. The VM, under the hood, in the background, unseen to unknowing eyes, shares the drive as a network drive anyway. The only operating system that ever needs to know what the physical format of the drive actually is is the host itself.

You will note that the person who made the suggestion to you did not query my assertion that you were being told complete and utter rubbish.

Season's greetings and good will.

mostlyharmless 12-21-2009 09:44 AM

I don't normally feed trolls. Of note, your elaboration shows that you didn't understand the situation. It isn't a matter of mounting the array under the host and making it available. That, indeed, would be safe and reasonable.

Furthermore, your message is rude for a first post.

kad_mann 12-22-2009 12:57 AM

2 Attachment(s)
Quote:

Originally Posted by mostlyharmless (Post 3799980)
I don't normally feed trolls.

Perhaps you do, perhaps you don't. I tend not to judge.

Quote:

Of note, your elaboration shows that you didn't understand the situation.
Claim fails. Complete lack of argument and hence, a complete lack of proof.

Quote:

Furthermore, your message is rude for a first post.
So, either I am a successful troll who got you to respond, or I am right.

There are two shovels over there -->

Take your pick.

"you shouldn't mount the drive under Ubuntu and have the Windows installation see the drive at all. You can run your Windows partition and then mount the Ubuntu served RAID partition as a network drive though, or as a "shared drive". Be careful that when you run Windows that the RAID is not touched at all by Windows; not mounted, not recognized, period."

What you told the user is complete and utter rubbish. What is worse, those unfortunate people using Google will find your response and probably believe it.

The one and only issue of "mount[ing] the drive under Ubuntu and hav[ing] the Windows installation see the drive at all" is that Windows does not know how to handle Linux symbolic links properly, and is likely to complain during a copy operation. Ceteris paribus, neither Windows nor Linux cares what OS sees the drive.

Now, you have verifiable data about my assertion that you are wrong. Your proof against the argument is...?

Of course, in your counter-argument, please do not forget I also asserted that the VM mounts the drive as a network resource anyway, despite your silly claim that the OP might mount the drive as a network drive; even if it was said only to cover up your in-exhaustive lack of knowledge about what you were talking about.

Attached are two images clearly showing that "you [CAN] mount the drive under Ubuntu and have the Windows installation see the drive at [THE SAME TIME]. You can run your Windows partition and then mount the Ubuntu served RAID partition [WITHOUT RESORTING TO MOUNTING IT] as a network drive though, or as a "shared drive"

Furthermore, the images clearly show that one does not need to "Be careful that when you run Windows that the RAID is not touched at all by Windows; not mounted, not recognized, period."

Now, you were saying?

mostlyharmless 12-22-2009 05:33 PM

giyad: my advice was based on http://www.vmware.com/support/refere...ion_linux.html and personal experience with not following my own present advice in the past. Hope that clears things up, in case you were still wondering.


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