Sponsored Content
Top Forums Shell Programming and Scripting Script to unmount and mount by UUID Post 302887565 by gtr33m on Saturday 8th of February 2014 10:17:26 PM
Old 02-08-2014
Script to unmount and mount by UUID

Hi,

Need a bit of help on this one as I am a scripting noob.

I have a linux based NAS that mounts USB hard drives in an inconsistent location and to make matters worse, seems to lose the mount for an unknown reason and doesn't remount automatically unless the drive is removed and re-inserted.

I'd like to make a script with that checks for a mounted drive by UUID, then checks it's mounted location and if not mounted in the location I want, unmounts then remounts in the correct location

What I have been able to figure out so far is that I can use

Code:
usbuuid=917086e7-9115-44fe-b176-b1a79f04e739
blkid|grep $usbuuid

to find it's /dev/xxx location, but I still need to parse the results to get rid of the extra info, and I'd like to then put the parsed info into a variable say usbdev.

I want to then used that variable with

Code:
mount|grep $usbdev

Again I need to parse the result to find the mount location, if any

If mounted, but not mounted in my desired location, I want to unmount it and remount it in the correct location. If not mounted, mount. If mounted correctly, do nothing. Then keep checking routinely in case the mount is lost.

I should point out that I can't change fstab. It's protected and even if I change it reverts on reboot.

I can schedule a cron job, or a startup script.

The other would be to dynamically create or change a dynamic link to which ever location the system mounts the USB, but I would still need a script to check if it's mounted and re-mount if necessary, and I have a problem that samble does not follow symbolic links and this setting can't be changed.

Any help would be appreciated.

Mark
 

9 More Discussions You Might Find Interesting

1. HP-UX

Cannot unmount mount points??

When taking a snap, I have a script that stops any active snap. When running the script, I'm getting a message that u02 and u04 are already mounted. How can I find out what process(es) is/are latching on the these mount points? Thank you for your time. (1 Reply)
Discussion started by: genzbeat
1 Replies

2. Gentoo

automating chroot and mount/unmount

Hello, I am trying to automate a task that I believe is easy. It is documented for manual system administrative purposes here: Gentoo Linux -- Installing the Gentoo Base System - chapter 6 I am attempting to do the following in a script: # cd $TOP_OF_ROOT_FS # mount -t proc none... (3 Replies)
Discussion started by: duderonomy
3 Replies

3. HP-UX

/usr out of disk space need to unmount/ expand volume /mount

Greetings, I am running HP-UX 10.2 and /usr is out of disk space already. I installed IE 5.0 for UNIX on my machine under /usr and browsed the Internet for a while and presto no more disk space. I have plenty of hard disk space on my computer so would like to expand the size of the volume. The... (5 Replies)
Discussion started by: Dirk_
5 Replies

4. OS X (Apple)

Can't Mount Disk / Image after bad unmount

I have had a little issue with one of my disks, the usb cacble was pulled out and one of the external drives on it would no longer mount. I used First Aid and it verified and repaired both OK / nothing to do). After lots of messing around and not being able to mount I used Drive Genius 2 and that... (1 Reply)
Discussion started by: Cranie
1 Replies

5. Shell Programming and Scripting

if (disk is mounted) unmount if (disk is unmounted) mount

Hey there, sorry if this is a bit too much of a noob question, trying to get to grips with a simple bash script - but i have done ZERO bash scripting. basically having worked out how to mount and unmount disks using: disktool -m *device* & disktool -e *device* - and looking at the result of... (2 Replies)
Discussion started by: hollister
2 Replies

6. Shell Programming and Scripting

Cygwin bash script to unmount and mount an XP partition

As stated, I am looking into keeping my backup drive unmounted in normal windows use. Partly this is to address threats like cryptolocker. Since one of my backup drives is an internal drive, it will not likely afford any protection from such a threat. I am thinking of adding code to my rsync script... (5 Replies)
Discussion started by: LMHmedchem
5 Replies

7. Shell Programming and Scripting

Script to mount nas-share using generated credentials (mount EC 13,32)

Heyas At home i have 1 nas with 3 shares, of which i used to mount 2 of them using a script with hardcoded password and username in it. EDIT: Turns out, its not the script, but 'how i access' the nas share.. (-o user=XY,password=... VS. -o credentials=...). Figured about credential files,... (0 Replies)
Discussion started by: sea
0 Replies

8. Shell Programming and Scripting

Unmount files via script

Hi all, I have a requirement to do an upgrade. As part of that upgrade I have to unmounts files in the fstab (there could be 100's), is there a way I can do this via script? The problem is, is that the mount points on every server will be different.... For example: /u001/oradata/T865 ... (4 Replies)
Discussion started by: gartie
4 Replies

9. UNIX for Beginners Questions & Answers

AIX - SAN Mount and Unmount on LPAR

We have 2 LPAR. LPAR #1 have a Application, Database Server process (ctree Server) and SAN+Physical Table. LPAR#2 has only Application. Both Application process are connected to Database via C-tree Server Process (Running on LPAR #1.. We want to keep one Active C-tree Server and one Backup... (1 Reply)
Discussion started by: gabhanes
1 Replies
GVFS-MOUNT(1)							   User Commands						     GVFS-MOUNT(1)

NAME
gvfs-mount - Mounts the locations SYNOPSIS
gvfs-mount [OPTION...] [LOCATION...] gvfs-mount --unmount-scheme=SCHEME gvfs-mount --list [OPTION...] gvfs-mount --monitor [OPTION...] DESCRIPTION
gvfs-mount provides commandline access to various aspects of GIOs mounting functionality. Mounting refers to the traditional concept of arranging multiple file systems and devices in a single tree, rooted at /. Classical mounting happens in the kernel and is controlled by the mount utility. GIO expands this concept by introducing mount daemons that can make file systems available to GIO applications without kernel involvement. OPTIONS
The following options are understood: -h, --help Prints a short help text and exits. -m, --mountable Mount as a mountable. -d, --device=DEVICE Mount the volume with the given device file. -u, --unmount Unmount the locations. -e, --eject Eject the locations. -s, --unmount-scheme=SCHEME Unmount all mounts with the given scheme. -l, --list List all known mounts. -o, --monitor Monitor mount and unmount events. -i, --detail Show extra information for --list and --monitor. EXIT STATUS
On success 0 is returned, a non-zero failure code otherwise. SEE ALSO
ls(1), gvfs-info(1) gvfs GVFS-MOUNT(1)
All times are GMT -4. The time now is 05:19 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy