English 中文(简体)
虚拟箱子站胜出
原标题:Virtualbox boot mount won t unmount

I have what I think is a very useful script here if you use NetBeans on VirtualBox guest. There seems to be one problem:

如果你看看这封信件,就会把网上贝曼项目从东道国系统排到客座。 罚款。 然而,另外还制作了一个文字,并将其转移到当地用户的双版上。 事实上,有两种文字: (1) 允许用户站立起来,2) 放弃安装的夹,以允许灵活性。

我测试了我的乌班特客的文字和一切作品,但网本是一纸。

它将不 un在boot子上安装的轨迹,而我已尝试让文字材料扎根。

Any clues as to if this will work and how? :

#!/bin/bash
#Author: Yucca Nel http://thejarbar.org
#Will restart system
PATH="/sbin:/usr/sbin:/bin:/usr/bin"
export PATH

#Modify these variables as needed...
tempWork=/tmp/work
startupScript=/etc/init.d/rc.local
defaultNetBeansVersion=7.0.1

echo "Provide NetBeans version (7.0.1 is default) then hit [Enter] :"
  read NetBeansVersion

  if [ -z "$NetBeansVersion" ]
    then
    $NetBeansVersion=$defaultNetBeansVersion
  fi

mkdir -p /$tempWork;
cd /$tempWork;

wget http://dlc.sun.com.edgesuite.net/netbeans/7.0.1/final/bundles/netbeans-$NetBeansVersion-ml-javase-linux.sh;
sh $tempWork/*sh;


#Add Netbeans launcher to your PATH. Doing so allows you to run  netbeans  command from the terminal
#This line will need to be changed if you changed the default install location (IOW Netbeans is not in ~/)
sudo ln -f -s ~/netbeans-$NetBeansVersion/bin/netbeans /usr/bin/;

#If you use VirtualBox , you can share your projects between Host and guest. Name of shared
#folder must match  NetBeansProjects 
mkdir -p $HOME/NetBeansProjects

if [ -f /sbin/mount.vboxsf ]
then
    sudo /sbin/umount /home/$HOME/NetBeansProjects
    sudo /sbin/mount.vboxsf NetBeansProjects $HOME/NetBeansProjects
fi

if mountpoint -q ~/NetBeansProjects
then
#Add it to the universal start script to automate process...
    sudo sed -ie  $d  $startupScript
    echo "sudo /sbin/mount.vboxsf NetBeansProjects $HOME/NetBeansProjects"| sudo tee -a $startupScript
    echo "exit 0"| sudo tee -a $startupScript
    sudo chmod +x $startupScript

#Create a mount and unmount script file and add it to users local bin
    rm -rf $tempWork/*
    echo  #!/bin/bash  > $tempWork/netbeans-mount.sh
    echo  #!/bin/bash  > $tempWork/netbeans-umount.sh
    echo  #!/bin/bash  > $tempWork/mount-from-host.sh
    echo  #!/bin/bash  > $tempWork/unmount-from-host.sh
    echo "sudo /sbin/mount.vboxsf NetBeansProjects $HOME/NetBeansProjects" >> $tempWork/netbeans-mount.sh
    echo "sudo /sbin/mount.vboxsf NetBeansProjects $HOME/NetBeansProjects" >> $tempWork/mount-from-host.sh
    echo "sudo umount $HOME/NetBeansProjects" >> $tempWork/netbeans-umount.sh
    echo "sudo umount $HOME/NetBeansProjects" >> $tempWork/unmount-from-host.sh
    echo "exit 0" >> $tempWork/unmount-from-host.sh
    echo "exit 0" >> $tempWork/mount-from-host.sh
    echo "exit 0" >> $tempWork/netbeans-mount.sh
    echo "exit 0" >> $tempWork/netbeans-umount.sh

    sudo chmod +x $tempWork/*
    sudo mv -f $tempWork/*.sh /usr/local/bin
    rm -rf $tempWork
fi

#This function is used to cleanly exit with an error code.
function error_exit {
    sleep 7
    exit 1
}
#restart
sudo reboot
exit 0

Update: Hand coded unmounting in terminal also fails to unmount the NetBeans Projects folder. So I guess I need to ask if it s even possible to unmount this folder if the system initialization mounted the folder?

Update2:Still Stuck, but I have some new info after looking in etc/mtab. Here is what I see:

...
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
NetBeansProjects /home/yucca/NetBeansProjects vboxsf rw 0 0
...

很显然,我不得不多次起诉“~”项目!

Additional mount options like f-l-a-t won t work either as it unmounts everything and I only want my targeted directory unmounted.

最佳回答

I rechecked all my init files and found there were some additional mounts added to /etc/init.d/rc.local I now test for existing string before writing like this (as an example):

if ! grep "JAVA_HOME=${javaUsrLib}/jdk1.7.0_01" /etc/environment

then echo "JAVA_HOME=${javaUsrLib}/jdk1.7.0_01" | sudo tee -a /etc/environment fi

问题回答

您可以不与以下各方分享:

sudo umount -a -t vboxsf 

或使用用户

sudo fusermount -u /mnt




相关问题
Signed executables under Linux

For security reasons, it is desirable to check the integrity of code before execution, avoiding tampered software by an attacker. So, my question is How to sign executable code and run only trusted ...

encoding of file shell script

How can I check the file encoding in a shell script? I need to know if a file is encoded in utf-8 or iso-8859-1. Thanks

How to write a Remote DataModule to run on a linux server?

i would like to know if there are any solution to do this. Does anyone? The big picture: I want to access data over the web, using my delphi thin clients. But i´would like to keep my server/service ...

How can I use exit codes to run shell scripts sequentially?

Since cruise control is full of bugs that have wasted my entire week, I have decided the existing shell scripts I have are simpler and thus better. Here is what I have so far svn update /var/www/...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

热门标签