fstab being overwritten on each manual mount

ronells200

Commendable
Oct 6, 2016
17
0
1,510
I've decided to go the way of the consensus and mount USB drives to a directory. So, I did some research and found someone who edited fstab to make mounting to a directory on the Desktop.

So, all I need to do is edit the /etc/fstab file.

In place of the device path I'm using the drives UUID so I don't have to worry about the devices getting shuffled during unmount, and I use the Desktop directory path as the mount point (yes, I created a fstab.bak backup file) and save it as fstab_mount for quick copy, you'll see why in just a little bit.
Lines added to fstab:

Code:
UUID=A6B01E5FB01E35F1  /home/caine/Desktop/USB1  ntfs-3g  rw,loop,noauto,noexec,nodev,noatime,umask=000,show_sys_files,streams_interface=windows,allow_other 0 0 # by rbfstab
UUID=E2FB-5843 /home/caine/Desktop/Flash vfat rw,loop,noauto,noexec,nodev,noatime,umask=000,shortname=mixed,quiet 0 0 # by rbfstab
The Type and Option are all copy and paste from the systems original fstab.

Next all I need to do is mount the mount point: USB1 and Flash. Unfortunately I have to be on the Desktop to do this, is there a script I can write that I can click on and do it without being on the desktop in the terminal?

Code:
/Desktop# mount USB1
/Desktop# mount Flash
mount: can't find Flash in /etc/fstab or /etc/mtab
/Desktop#
As you can see it fails to mount the thumb drive "Flash" because it can not be found in fstab." This is because after every mount the fstab is being overwritten with each "mount".

I edit fstab in "nano /etc/fstab", I've even used sudo nano, but it keeps getting overwritten. I have also used "mount -a" after the edit as some users have advised in other posts.

So I copy fstab_mount to /etc/fstab and mount the falsh drive:

Code:
/Desktop# mount Flash
/Desktop#
and again fstab is overwritten again.

Help is very sparse on the web, and all they talk about is being overwritten on Boot, not mount. I'm using a CAINE 7.0 Live CD, so no booting.

So I got to thinking, it could be the end of each line calling the file: "# by rbfstab".

I removed “ # by rbfstab” from end of each line entry. On mount the bootup defaults are appended to the end of fstab (see below), on the first mount ONLY, Why only the first one???

Code:
root@caine:/home/caine/Desktop# nano /etc/fstab

    GNU nano 2.2.6           File: /etc/fstab

overlayfs / overlayfs rw 0 0
tmpfs /tmp tmpfs nosuid,nodev 0 0
/dev/sr0        /media/sr0      iso9660  ro,loop,noauto,noexec,nodev,noatime 0 0
/dev/sda1       /media/sda1     ntfs-3g  ro,loop,noauto,noexec,nodev,noatime,umask=000,show_sys_files,streams_interface=windows,allow_other 0 0
/dev/sda2       /media/sda2     vfat     ro,loop,noauto,noexec,nodev,noatime,umask=000,shortname=mixed,quiet 0 0
/dev/sda3       /media/sda3     vfat     ro,loop,noauto,noexec,nodev,noatime,umask=000,shortname=mixed,quiet 0 0
/dev/sda5       /media/sda5     ntfs-3g  ro,loop,noauto,noexec,nodev,noatime,umask=000,show_sys_files,streams_interface=windows,allow_other 0 0
/dev/sda6       /media/sda6     ntfs-3g  ro,loop,noauto,noexec,nodev,noatime,umask=000,show_sys_files,streams_interface=windows,allow_other 0 0
/dev/sda7       /media/sda7     ntfs-3g  ro,loop,noauto,noexec,nodev,noatime,umask=000,show_sys_files,streams_interface=windows,allow_other 0 0
UUID=A6B01E5FB01E35F1       /home/caine/Desktop/USB1     ntfs-3g  rw,loop,noauto,noexec,nodev,noatime,umask=000,show_sys_files,streams_interface=windows,allow_other 0 0
UUID=4E26CC1026CBF74D       /home/caine/Desktop/USB2     ntfs-3g  rw,loop,noauto,noexec,nodev,noatime,umask=000,show_sys_files,streams_interface=windows,allow_other 0 0
UUID=E2FB-5843       /home/caine/Desktop/Flash     vfat  rw,loop,noauto,noexec,nodev,noatime,umask=000,shortname=mixed,quiet 0 0

########## Below are the lines added after a mount is issued ##############

/dev/sr0        /media/sr0      iso9660  ro,loop,noauto,noexec,nodev,noatime 0 0 # by rbfstab
/dev/sda1       /media/sda1     ntfs-3g  ro,loop,noauto,noexec,nodev,noatime,umask=000,show_sys_files,streams_interface=windows,allow_other 0 0 # by rbfstab
/dev/sda2       /media/sda2     vfat     ro,loop,noauto,noexec,nodev,noatime,umask=000,shortname=mixed,quiet 0 0 # by rbfstab
/dev/sda3       /media/sda3     vfat     ro,loop,noauto,noexec,nodev,noatime,umask=000,shortname=mixed,quiet 0 0 # by rbfstab
/dev/sda5       /media/sda5     ntfs-3g  ro,loop,noauto,noexec,nodev,noatime,umask=000,show_sys_files,streams_interface=windows,allow_other 0 0 # by rbfstab
/dev/sda6       /media/sda6     ntfs-3g  ro,loop,noauto,noexec,nodev,noatime,umask=000,show_sys_files,streams_interface=windows,allow_other 0 0 # by rbfstab
/dev/sda7       /media/sda7     ntfs-3g  ro,loop,noauto,noexec,nodev,noatime,umask=000,show_sys_files,streams_interface=windows,allow_other 0 0 # by rbfstab

root@caine:/home/caine/Desktop#
So, why is /etc/fstab being automatically overwritten on a mount, even with rbfstab disabled?
Why is fstab being appended to with the "bootup" settings on the first mount only?

What is the mount process calling?

The OS runs in the background checking for new devices plugged in, is this what is happening? But why would it append to fstab if the devices match what's already there (except the removal of # by rbfstab)?
 
I figured it out. I went over rbfstab again and tried the -r option. It removed reference to all devices in fstab. Not what I was expecting, but I went ahead and copied my saved version of fstab_nordfstab (with out the reference to rbfstab) to fstab and mounted USB1. fstab was not overwritten or appended to. So I mounted Flash, same results. I unmounted Flash then remounted Flash, still not overwritten or appended to.

So from here forward I will run:
Code:
rbfstab -r
after each boot and copy my version of fstab.


 
Now I'm trying to create a Launcher on the desktop to mount USB1.

Below is what I have so far:
Code:
#To install desktop file:
#xdg-desktop-menu install --novendor --mode system /home/caine/Desktop/Flash/mount_USB1.desktop
[Desktop Entry]
Name=mount_USB1.desktop
Comment=mount Drive USB1
Exec=sudo /home/caine/Desktop/mount USB1
TryExec=sudo /home/caine/Desktop/mount USB1
StartupNotify=false
Icon=/home/caine/Desktop/USB1
Terminal=true
Type=Application
Categories=System;Filesystem;
Next I run
Code:
xdg-desktop-menu install --novendor --mode system /home/caine/Desktop/Flash/mount_USB1.desktop
then I validate the .desktop file
Code:
#desktop-file-validate /user/local/share/applications/mount_USB1.desktop
the file passes validate

So I open the file (inside the /applications folder)
even with issuing --mode system I have to run the launcher as Administrator.
The wheel spins and stops, and still does not mount the USB drive.

According to the man page and what I've read online, you can run terminal commands from a Launcher.
What am I doing wrong?
 
Why bother making a launcher for a livecd??? It will just get erased on reboot!

In addition it is not clear what command you are actually running. 'mount' for example does not reside on your desktop. Also you should use gksu instead of calling sudo since you want to call it from desktop and not terminal.

Also also why not just make an alias, or short shell command.

Alsoalsoalso why not just let udisks or similar service handle the mounting of removable devices??? You make this too complicated.

Another thought maybe use kali instead of caine. Kali has more up to date forensic tools.
 
I want a launcher because I don't plan on shutting my system down all the time, so I want to be able to unmount and mount without the hassle of typing in the Desktop path all the time. I created an alias but it does not mount the drive, unless you have a solution, I'm open to it. All I have to do is backup the files I created on my USB drive and when I do reboot, just copy them back, not difficult.

I thought it was clear what command I am running: "mount USB1". USB1 is called out from fstab. "mount" is executable from the Desktop, but as noted in my previous post I have to be in Desktop in the terminal "/home/caine/Desktop/mount USB1".

This whole process started because every time I would unmount a drive I would lose all data that was created in that session. I am working on creating an image of a partition on a failed drive. This became very frustrating when ddrescue took 6hrs each time on a 1tb drive. Even when I made a copy of the image to another USB drive, takes hours also, it was all being deleted on unmount. I got no solutions from anywhere. And I use ddrescue because the GUI programs would still crap out with the first I/O error.

I experimented with examples on the web and found a solution, editing the fstab and using the system default values. It worked, and that is where I found the option to run mount from the Desktop by calling it from fstab. USB1 is the moint point.

I am a newbie and have been muddling through this on my own. Everywhere I read said to use sudo to execute as root permission. I found no reference to gksu. I am not aware of udisks. I did not think I was making this difficult. It seems straight forward, create a launcher, edit the command lines and walla - double click solution. No terminal.

Why did I use caine, because there are quite a few livecd's out there and everyone claims to be the best. When I tried caine it was pretty straight forth and had plenty of options. So I quit creating a bootable thumb drive with each livecd I found. And to free up a USB port I created a bootable CD.

I felt a bit attacked at first, but you do bring up good questions and points. I hope I was able to answer them.
 
as noted in my previous post I have to be in Desktop in the terminal "/home/caine/Desktop/mount USB1".

that cannot be accurate. Caine is built off ubuntu 14.04 so likewise in ubuntu the 'mount' binary path is:
'/bin/mount'
not
'/home/caine/Desktop/mount'

http://packages.ubuntu.com/trusty/i386/mount/filelist

Really just try in the terminal: '/home/caine/Desktop/mount' and you will probably get 'no such file or directory'. then try again with '/bin/mount'

gksu is needed because executing 'sudo' requires you to input your password, which requires a terminal, which will not magically launch on its own. gksu is like the gui equivalent of sudo.

No attacking. I think you are just making this much harder on your self, after all people have been mounting removable drives for decades... It is a solved problem!

For example udisks handles the automatic mounting/unmounting of removable drives on most modern systems these days. All modern desktops (gnome, kde, xfce, lxde...etc) also include nice single click mounting/unmounting tool in the system tray and in most file managers.
 


Sorry I've been on other things.
Skittle, your right I am making it harder on myself. But, it's been a learning experience and I've gotten really side tracked now. Now I'm practicing on scripts, aliases and .desktop files. Way side tracked.
OK, I was wrong when I said I tried an alias and it didn't work, actually what I made was a link. I did find out how to make aliases though.

From the terminal I'm able to execute mount from the Desktop directory, but because of how it is configured in fstab it HAS TO BE from Desktop and there has to be a folder USB1 on the desktop.
Code:
/home/caine/Desktop/mount USB1
/Desktop is the path Identified in fstab for USB1:
Code:
UUID=A6B01E5FB01E35F1       /home/caine/Desktop/USB1     ntfs-3g  rw,loop,noauto,noexec,nodev,noatime,umask=000,show_sys_files,streams_interface=windows,allow_other 0 0
I did this thinking I could make it an alias and just double click it. I made fstab rw so I didn't have to mess with changing permissions.

I was able to get the launcher fixed with your suggestion:
Code:
gksu /bin/mount /home/caine/Desktop/USB1
I did find "Mounter" in the task bar, very small icon, but it will mount read only and when you unmount the drive it has to be unplugged and plugged back in to be recognized. When I try to mount writable it gives me errors.

I am playing with kali, I did create an image of my bad hard drive with. I don't know how it turned out yet though. The problem with kali is there is a lot of activity on the main HD of my system when it boots. Kali auto mounts, which I don't want. Is there a way to disable auto-mount I want a live CD (or in this case Live DVD) and mount when I want. I don't want it trying to mount the main HD and make it any worse.

Actually you can boot into Forensic mode and auto mount is disabled
 
I have been working in Kali on the image with foremost, scalpel and photorec, all are recovering too many useless files. Labeled with the extensions I'm looking for, but will not open. Using hexdump to find the header and footers has been a real learning experience, but very frustrating.

Installing my new HDD and memory upgrade, so will be busy installing everything for a bit. I will readdress the data recovery after my PC is up and running.