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.
  • 90,397
Suche_G
  • 127

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
  • 83,767
  • Hi @Jacob Vliijm Earlier even the hard disks would reappear. I want them to come back. Is there any way out? Oh by the way, I had made the partitions in gparted, if that helps anyway.. – Suche_G Dec 27 '14 at 08:47
  • @Suche_G And what is now (without changing anything) the output of: gsettings get org.gnome.desktop.media-handling automount? – Jacob Vlijm Dec 27 '14 at 08:55
  • it is coming true – Suche_G Dec 27 '14 at 08:57
  • @Suche_G and of gsettings get com.canonical.Unity.Devices blacklist? – Jacob Vlijm Dec 27 '14 at 08:59
  • ['b1ab5a7d-10fe-4bbb-a22d-9a10b8b8f3d2-4TB_6', '816be5c6-08c3-40f6-939d-bfb1e216144c-4TB_5', '1cf37836-b8d2-4698-b475-93f6e3a7d9b6-4TB_4', 'b4f071fa-e47d-4f6e-ae92-fa3b02c9b34e-4TB_3', '91ea4c5a-5b28-48a3-962d-240071b2b669-4TB_2', '57da03a3-8037-4407-9a9a-da3fc97127e3-4TB_1', '82DC9120DC911011-SUCHETANA_9551571789'] Seems my pendrive also got added to the blacklist :( – Suche_G Dec 27 '14 at 09:00
  • So isn't there any option? – Suche_G Dec 27 '14 at 09:12
  • Okay. Do you have such a script? – Suche_G Dec 27 '14 at 09:20
  • Sure I will. Please let me know the detailed procedure (I am very very poor in Linux) And thanks a lot for your time and help! – Suche_G Dec 27 '14 at 09:22
  • Hi I did everything as you said, the pendrive is returning, but the mounted partitions are not :( – Suche_G Dec 28 '14 at 04:00
  • Output for the 1st one is: ['b1ab5a7d-10fe-4bbb-a22d-9a10b8b8f3d2-4TB_6', '816be5c6-08c3-40f6-939d-bfb1e216144c-4TB_5', '1cf37836-b8d2-4698-b475-93f6e3a7d9b6-4TB_4', 'b4f071fa-e47d-4f6e-ae92-fa3b02c9b34e-4TB_3', '91ea4c5a-5b28-48a3-962d-240071b2b669-4TB_2', '57da03a3-8037-4407-9a9a-da3fc97127e3-4TB_1']
  • – Suche_G Dec 28 '14 at 07:15
  • second one is: NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 3.7T 0 disk ├─sda1 8:1 0 4.7G 0 part [SWAP] ├─sda2 8:2 0 18.6G 0 part / ├─sda3 8:3 0 465.7G 0 part /media/suchetana/4TB_1 ├─sda4 8:4 0 465.7G 0 part ├─sda5 8:5 0 465.7G 0 part ├─sda6 8:6 0 465.7G 0 part /media/suchetana/4TB_4 ├─sda7 8:7 0 931.3G 0 part /media/suchetana/4TB_5 ├─sda8 8:8 0 880.8G 0 part /media/suchetana/4TB_6 ├─sda9 8:9 0 38M 0 part /boot/efi └─sda10 8:10 0 27.9G 0 part /home sr0 11:0 1 1024M 0 rom – Suche_G Dec 28 '14 at 07:16
  • @Suche_G It should really work now, could you try again, same procedure? Tried adding all your devices to my blacklist, tried with my drives, all was immediately removed from blacklist when using script (else not). – Jacob Vlijm Dec 28 '14 at 09:44
  • Hi Jacob I retried but the same thing persists. May be some bug on my system :( – Suche_G Dec 28 '14 at 10:49
  • @Suche_G OK, i'll remove my answer :( – Jacob Vlijm Dec 28 '14 at 10:49
  • No but may be someone else could find it useful. Don't know why it didn't work for me. Heard HP machines have some intrinsic bugs – Suche_G Dec 28 '14 at 10:52
  • Now all the partitions load on the launcher on starting my system. I have dared not unlock them from launcher! – Suche_G Dec 30 '14 at 03:19
  • @Suche_G your computer has a mind of its own :) – Jacob Vlijm Dec 30 '14 at 07:15
  • haha! may be!! :) – Suche_G Dec 30 '14 at 13:20