Score:1

Grsync fills up o/s partition if destination is unmounted

us flag

If the designated destination drive is unmounted, Grsync fills up the o/s partition instead of just mounting it, or aborting. How do I prevent that?

I usually remember to check to see that it's mounted, but sometimes I forget, with very bad results.

Thanks for any help.

ra@ra-main:~$ cat /etc/fstab

/etc/fstab: static file system information.

Use 'blkid' to print the universally unique identifier for a

device; this may be used with UUID= as a more robust way to name devices

that works even if disks are added and removed. See fstab(5).

/ was on /dev/sdc3 during installation

UUID=557ba3eb-2dcc-4b03-964b-f12f509c4faa / ext4 errors=remount-ro 0 1

/boot/efi was on /dev/sda3 during installation

#UUID=D305-EBF0 /boot/efi vfat umask=0077 0 1 /swapfile none swap sw 0 0 UUID=0399-667C /boot/efi vfat defaults 0 1 LABEL=Grsync /mnt/Grsync auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-name=Grsync 0 0 ra@ra-main:~$ ^C

ar flag
Welcome to Ask Ubuntu. Please edit your question and add the following information. Which distro and version of Linux are you using? What is the mount point of the "destination drive"? Is it an internal or external drive? Is it set to auto-mount?
RichC avatar
us flag
The dest. drive is an internal, and it is set to auto mount on boot up in Disks, but sometimes the setting gets reset, or somehow it goes unmounted.
ar flag
Please [edit your question with the new information](https://askubuntu.com/posts/1371344/edit) and see [this post](https://stackoverflow.com/questions/27359/rsync-only-if-filesystem-is-mounted).
ar flag
Use the command `cat /etc/fstab` to show the contents of the file `/etc/fstab`. Then copy and paste that output in your question. Finally format the pasted output as `code` using the {_} icon above the edit question window. This may explain why your internal drive gets unmounted.
Score:0
th flag

Yes, that's the intended behavior of grsync, rsync, etc., and many other backup tools and it is the user's responsibility to check that the volume is mounted prior to executing these tools (as you allude to). You can create a script that runs the grsync command instead of running it directly, and then put some commands that check to see if the volume is mounted before running the grsync command (or just run the mount check commands manually, that works too). Something like this might work:

cd /home/username/
mkdir scripts
cd scripts
nano grsyn.sh
sudo chmod 750 grsync.sh nano grsync.sh

Then, in the file that opens in the nano text editor, copy and paste and adjust this script to your needs:

if grep -qs '/mnt/backup ' /proc/mounts; then
    echo "I will proceed with grsync because the volume is ready."

grsync [enter your commands/flags here]

else

    echo "The volume is not ready, so I am not running grsync."

fi

You can run the script manually by navigating to your scripts' directory and typing ./grsync.sh. The q flag is optional and can be removed depending on user preference. You can optionally create a cron job to run this script as follows:

sudo crontab -e

Below the last entry, copy/paste and adjust the following to your needs:

0 8 * * * /bin/bash /home/username/scripts/ >> /home/username/grsync.log

This script will run your desired grsync command every day at 8am.


New users and/or less complex workflows might only require a simple check, and in that case it is easiest to enter a single command at the console. To do that, use the grep syntax above, but just make sure to omit the q flag so the result prints to standard output:

grep -s '/mnt/backup ' /proc/mounts

This will then print a result similar to this if the Volume is mounted:

/dev/sdb /mnt/backup ext4 rw,nosuid,nodev,noatime,attr2,inode64,logbufs=8,logbsize=32k,noquota 0 0

If you receive no output, and as long as your grep string is accurate, then this would indicate the volume is likely not mounted. Lastly, if you want this integrated within the graphical front end of grsync instead of handling at the command line, then simply enter the manual command into the Extra Options / Execute this command before rsync / Halt on failure.

oemb1905 avatar
th flag
@RichC Is this what you were looking for? lmk ...
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.