On Linux systems like Ubuntu or Kubuntu all partitions other than the root partitions are usually not mounted at startup.
Clicking on the partition inside a file manager mounts them and open the content for viewing.
However sometimes it is desirable that the partition mounts automatically at startup, so that some application can access it right away.
In this article, we show you how to mount partitions automatically at startup on a Kubuntu, without using the fstab command.
1. Get the device path and UUID
The first step is to find out the device path and the uuid that you wish to mount. Use the lsblk command to check the details as shown below.
$ lsblk -o PATH,SIZE,RO,TYPE,MOUNTPOINT,UUID,MODEL PATH SIZE RO TYPE MOUNTPOINT UUID MODEL /dev/loop0 96.5M 1 loop /snap/core/9436 /dev/loop1 229.6M 1 loop /snap/atom/257 /dev/loop2 55M 1 loop /snap/core18/1880 /dev/loop3 54.8M 1 loop /snap/gtk-common-themes/1502 /dev/loop4 156.2M 1 loop /snap/chromium/1213 /dev/loop5 55M 1 loop /snap/core18/1754 /dev/loop6 62.1M 1 loop /snap/gtk-common-themes/1506 /dev/loop7 230.6M 1 loop /snap/atom/258 /dev/loop8 158.4M 1 loop /snap/chromium/1229 /dev/loop9 97M 1 loop /snap/core/9665 /dev/sda 465.8G 0 disk Samsung_Portable_SSD_T5 /dev/sda1 420G 0 part 757dcceb-3e17-4ca8-9ba1-b0cf68fb0134 /dev/sdb 111.8G 0 disk Samsung_SSD_840_EVO_120GB /dev/sdb1 95.4G 0 part / 19d84ceb-8046-4f8d-a85a-cda49515d92c /dev/sdc 111.8G 0 disk Samsung_SSD_850_EVO_120GB /dev/sdc1 95.8G 0 part f41b21a7-e8be-48ac-b10d-cad641bf709b e[email protected]:~$
2. Mount it with udisksctl
Note down the device path from the output shown by lsblk command.
For example /dev/sdc1. Now run the udisksctl command to mount it.
$ udisksctl mount -b /dev/sdc1 Mounted /dev/sdc1 at /media/enlightened/f41b21a7-e8be-48ac-b10d-cad641bf709b.
The above command will mount the device at the path which contains both username and uuid:
The path is automatically decided by the command udisksctl so that we don't have to specify it. This is the same location where the device is mounted when clicked inside file manager Dolphin. So mounting it with this command will also show it mounted inside Dolphin the same way.
Mount with UUID
If you have multiple storage devices connected to your system then the device paths like /dev/sdb1 might change for each storage device every time.
Hence its a better idea to use UUID to mount devices as they do not change. Udisksctl command does not have an option to mount drive by uuid, but there is a work around. Use the command as follows:
$ udisksctl mount -b /dev/disk/by-uuid/f41b21a7-e8be-48ac-b10d-cad641bf709b
The last part of the path is the uuid of the storage device that you can check from lsblk output.
3. Configure KDE System Settings - to run at startup
Finally you have to configure Kubuntu to run that command at startup so that the disk is mounted.
Go to System Settings > Workspace > Startup & Shutdown > Autostart.
The Autostart configuration dialog can also be launched from terminal with the following command:
$ kcmshell5 autostart
Here you can specify programs or scripts that you wish to start at system startup. Click "Add Program" and just copy paste the udisksctl command as shown above with the device path.
udisksctl mount -b /dev/disk/by-uuid/f41b21a7-e8be-48ac-b10d-cad641bf709b
Make sure to use the UUID based mount command since uuid remains constant and the command would mount the correct drive everytime on system startup.
This will save the command for running at system startup.
Usually partitions are mounted by adding an entry to /etc/fstab file.
Check out the previous tutorial here:
Ubuntu - automatically mount partition at startup with fstab