2

I am using Ubuntu 14.04 on my HP Pavillion Desktop.

Till a few minutes back, the devices, pendrives, external hard disks would show up on mounting them and plugging them in respectively.

Suddenly, I find that mounted devices are no longer showing up on the launcher. If I drag them from and lock to launcher, the moment I unlock them, they disappear and are not coming back even on mounting.

Any idea on how to bring back the appearance on launcher on mounting feature?

Edit: On running fdisk -l I get the following:

WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted


Disk /dev/sda: 4000.8 GB, 4000785948160 bytes
255 heads, 63 sectors/track, 486401 cylinders, total 7814035055 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1  4294967295  2147483647+  ee  GPT
Partition 1 does not start on physical sector boundary.

Edit: When I try to connect my Android phone via datacable, mostly it doesn't mount it. The cable is absolutely fine, I have used it in other systems.

A.B.
  • 92,125
Suche_G
  • 127
  • 2
  • 9

1 Answers1

3

Whether mounted (usb) drives are showing up in the Unity launcher or not, has nothing to do with fstab.

Run the following command to reset the blacklist and show all mounted devices again in the launcher:

gsettings set com.canonical.Unity.Devices blacklist "[]"

Explanation

When you unlock mounted volumes from the launcher, you actually add them to a blacklist (com.canonical.Unity.Devices), that prevents them from showing up in the launcher. They will be mounted nevertheless.

You can see which devices are currently in the blacklist by running the command:

gsettings get com.canonical.Unity.Devices blacklist

Force temporarily blacklisting

To automatically remove blacklisted devices from the blacklist, once they are unmounted, you can run a small script in the background. It watches changes in the list of mounted volumes. If a device gets disconnected, the script removes its (possible) mention in the blacklist.
The device will then appear again in the launcher on the next time it is connected.

How to use

  • Copy the script below into an empty file (use e.g. gedit).
  • Save the file somewhere as rm_blacklist.py.
  • For a clean start, reset the blacklist with the command:

    gsettings set com.canonical.Unity.Devices blacklist "[]"
    
  • Test- drive the script by opening a terminal window and run the command:

    python3 /path/to/rm_blacklist.py
    

    While keeping the terminal window open (running the script):

    • Insert a pen drive. Wait a few seconds until it is mounted, then unlock it from the launcher
    • Disconnect the pen drive.
    • Insert it again after a few seconds; it should now re-appear in the launcher.

If all works as you want, add it to your Startup Applications:
Dash > "Startup Applications" > Add. Add the command:

python3 /path/to/rm_blacklist.py

The script

#!/usr/bin/env python3
import subprocess
import time

def get_info(cmd):
    return subprocess.check_output(["/bin/bash", "-c", cmd]).decode("utf-8")

def get_mountedlist():
    devices = get_info("lsblk").splitlines()
    return [l.split("/")[-1].strip() for l in devices if "/" in l and not l.endswith("/")]

def get_blacklist():
    try:
        return eval(get_info("gsettings get com.canonical.Unity.Devices blacklist"))
    except SyntaxError:
        return []

while True:
    curr_blacklist = get_blacklist()
    mounted_blacklisted = sum([[it for it in curr_blacklist if m in it] for m in get_mountedlist() ], [])
    if '-' in curr_blacklist:
        mounted_blacklisted = mounted_blacklisted+['-']
    if not curr_blacklist == mounted_blacklisted:
        cmd = "gsettings set com.canonical.Unity.Devices blacklist "+'"'+str(mounted_blacklisted)+'"'
        subprocess.Popen(["/bin/bash", "-c", cmd])
    time.sleep(3)
Jacob Vlijm
  • 85,475