mounting other shares from debi

Discussion in 'Server Operation' started by Toucan, Mar 21, 2010.

  1. Toucan

    Toucan New Member

    I'm running debian lenny and also have on the same lan a Western Digital MyWorldBook with network file shares.

    I can mount them from windows and ubuntu gui no problem. I'd like potentially to mount them from my deb lenny server using a shell to use as a backup destination one day. How do I mount them?
     
  2. falko

    falko Super Moderator ISPConfig Developer

    Can you post the output of
    Code:
    mount
    from your Ubuntu desktop when the network share is mounted?
     
  3. sjau

    sjau Local Meanie Moderator

    I use something like this to mount my external WD usb drives (and uncrypt them):

    Code:
    #!/bin/bash
    
    # USER VARIABLES
    TB15="/media/tb15"		# Folder where the 1.5 TB drive shall be mounted to
    TB20="/media/tb20"		# Folder where the 2.0 TB drive shall be mounted to			
    KEY="/root/root.key"	# Keyfile for unlocking the luks / dm-crypt devices
    
    DEVICE15="/dev/disk/by-id/usb-WD_My_Book_1110_574D41565531313433393930-0:0-part1"	# The path and ID of the 1.5 TB drive
    DEVICE20="/dev/disk/by-id/usb-WD_My_Book_1112_574341565932313039353935-0:0-part1"	# The path and ID of the 2.0 TB drive
    
    MAPPER15="tb15"			# Name of the 1.5 TB device mapper
    MAPPER20="tb20"			# Name of the 2.0 TB device mapper
    
    ##                                                      ##
    ##      --       DO NOT EDIT BELOW THIS HERE     --     ##
    ##                                                      ##
    
    # Check if the 1.5 TB drive is attached, if so mount it
    if [ -h "$DEVICE15" ] ;
    then
    	# Check if the mount folder exists, otherwise create it
    	if [ ! -d "$TB15" ]; then
    		mkdir $p "$TB15"
    	fi
    	# Unlock the encrypted drive
    	cryptsetup luksOpen --key-file="$KEY" "$DEVICE15" "$MAPPER15"
    	# Mount it
    	mount "/dev/mapper/$MAPPER15" "$TB15"
    fi
    
    # Check if the 2.0 TB drive is attached, if so mount it
    if [ -h "$DEVICE20" ] ;
    then
    	# Check if the mount folder exists, otherwise create it
    	if [ ! -d "$TB20" ]; then
    		mkdir $p "$TB20"
    	fi
    	# Unlock the encrypted drive
    	cryptsetup luksOpen --key-file="$KEY" "$DEVICE20" "$MAPPER20"
    	# Mount it
    	mount "/dev/mapper/$MAPPER20" "$TB20"
    fi
    
    
    exit 0
    
     
  4. Toucan

    Toucan New Member

    Thanks sjau, the drive is actually a network share not a usb drive. I think I get where falko is heading, work out how it is mounted in ubuntu and then use the same info in debian.

    Falko, I'm away from that desktop for a few days.. i'll post when i'm back there.
     
  5. sjau

    sjau Local Meanie Moderator

    Well,

    I have those entries in my fstab for network shares:

    Code:
    # SSHFS
    [email protected]:/media/Audio     /media/Audio    fuse    user    0       0
    [email protected]:/media/Video     /media/Video    fuse    user    0       0
    
    # NFS
    SERVERIP:/media/Audio  /media/Audio    nfs     noauto,user,defaults    0       0
    SERVERIP:/media/Video  /media/Video    nfs     noauto,user,defaults    0       0
    
    # CIFS
    //SERVERIP/Shows       /media/Shows    cifs    noauto,users,noatime,username=USER,password=PASSWORD,iocharset=utf8,workgroup=WORKGROUP   0       0
    
    And to mount them as user, when I want them, I use:

    Code:
    #!/bin/bash
    
    TARGET=SERVERIP
    if ping -c 1 -w 5 $TARGET &>/dev/null ;
    then
      mount /media/Audio
      mount /media/Video
      mount /media/Shows
    fi
    
    I used to use SSHFS for the mount but now I'm using NSF for two mounts and samba/cifs for the third one.
     
  6. Toucan

    Toucan New Member

    Ok, in ubuntu desktop, i used the connect to server menu and connected to the wd network drive called oldoak.

    I can see and access the files and share from ubuntu desktop.

    When I went to cli I typed mount and this is what returned:
    Code:
    [email protected]:~$ mount
    /dev/sda1 on / type ext4 (rw,errors=remount-ro)
    proc on /proc type proc (rw)
    none on /sys type sysfs (rw,noexec,nosuid,nodev)
    none on /sys/fs/fuse/connections type fusectl (rw)
    none on /sys/kernel/debug type debugfs (rw)
    none on /sys/kernel/security type securityfs (rw)
    udev on /dev type tmpfs (rw,mode=0755)
    none on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
    none on /dev/shm type tmpfs (rw,nosuid,nodev)
    none on /var/run type tmpfs (rw,nosuid,mode=0755)
    none on /var/lock type tmpfs (rw,noexec,nosuid,nodev)
    none on /lib/init/rw type tmpfs (rw,nosuid,mode=0755)
    binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
    gvfs-fuse-daemon on /home/david/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=david)
    [email protected]:~$ ^C
    
    is that what you required falko?
     
  7. falko

    falko Super Moderator ISPConfig Developer

    Is that the network drive?
    Code:
    gvfs-fuse-daemon on /home/david/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=david)
    What's the output of
    Code:
    fdisk -l
    when the network drive is mounted?
     
  8. Toucan

    Toucan New Member

    Sorry for the delay and thanks for the help guys, but my ubuntu machine has now stopped working so I can't use it for the tests to assist mounting it from debi.

    Looking from a windoze7 machine I have the share known as Public like this in the windows tree:
    Public (//192.168.0.54)

    This has no user name or password assigned to it.
     
  9. Toucan

    Toucan New Member

    Sjay,

    I see what you're doing I think. Where you have written server ip, do I put in the the ip of my network drive?

    Where you have written !bash/bin do I literally write that all at command line or make some sort of script to run it?

    Thanks


     
  10. sjau

    sjau Local Meanie Moderator

    you know what fstab is or how to assign variables in bash?
     
  11. Toucan

    Toucan New Member

    I would use vi to edit the vstabs file yes?

    I don't know don't know anything about bash though. Could you help?
     
  12. sjau

    sjau Local Meanie Moderator

    yes

    Have a search for "shebang line". And for the script itself, it has to be made executable and then just called like ./start.sh
     
  13. Toucan

    Toucan New Member

    Got it, partway at least...

    I've edit the fstab to look like this:
    Code:
    # /etc/fstab: static file system information.
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    proc            /proc           proc    defaults        0       0
    /dev/sda1       /               ext3    errors=remount-ro,usrquota,grpquota 0       1
    /dev/sda5       none            swap    sw              0       0
    /dev/scd1       /media/cdrom0   udf,iso9660 user,noauto     0       0
    /dev/scd0       /media/cdrom1   udf,iso9660 user,noauto     0       0
    /dev/fd0        /media/floppy0  auto    rw,user,noauto  0       0
    
    192.168.0.103:/nfs/badback      /mnt/badback    nfs     auto,user,defaults    0       0
    192.168.0.103:/nfs/Public       /mnt/public     nfs     auto,user,defaults    0       0
    
    They seem to mount up fine on system start up. So I'm not quite sure, what is the other shebang line script you mentioned for?
     

Share This Page