How to automount a partition of a USB stick at /media/lubuntu/name every time the stick is plugged into the PC when the /etc/fstab file is empty on every new boot?
I assume this is because I'm running a persistent live lubuntu 22.04 made with mkusb (dus method) and /etc/fstab is not a part of persistence
What I've tried and did not work:
- edit /etc/fstab with
UUID=0123 /media/lubuntu/name ntfs defaults 0 0 - edit ~/.bashrc with
sudo mount -o rw,users,umask=000,exec UUID=0123 /media/lubuntu/name - according to this question, making a custom /etc/fstab in a custom distro and burning that to the stick also won't work, because mkusb makes its own /etc/fstab
What 'kind of' works:
- If I edit the label of the partition to
namethe system automounts it to/media/lubuntu/name1, yet if I do this with a mmc card, it automounts to/media/lubuntu/namewhich I find confusing and would simply like to set this up myself - if there is no label to the partition, the system automounts it to its UUID, a very long number, resulting in many confusing folders at
/media/lubuntu/
Any help appreciated
.../name1makes me think that it is mounted automatically before you mount it. – sudodus Feb 16 '24 at 15:36lsblk -e7 -fin a wide terminal window, and the NTFS file system was automounted at/media/lubuntu/name, which matches what you want. This should work as long as you have not another file system mounted at that mountpoint. In that case it will use/media/lubuntu/name1. – sudodus Feb 16 '24 at 19:20/media/lubuntu/nameagain. In other words, I cannot make Lubuntu act like you describe (unless I mount another file system with the same label). – sudodus Feb 16 '24 at 19:22code):ls -l /media/lubuntu/;lsblk -e7 -o model,name,size,fstype,label,mountpoints-- You can do it before connecting the USB stick and after unplugging and after connecting it again. This may help understanding what is happening. – sudodus Feb 16 '24 at 20:38ls -l /media/lubuntu/and found I have many empty (non-mounted) folders with root permissions in /media/lubuntu, so I've cleaned those withsudo rm -r. Honestly I do not know why this was heppening. Example: for a device with label PROJ, I would have /media/lubuntu/PROJ, /media/lubuntu/PROJ1, media/LUBUNTU/PROJ2, ... up to media/lubuntu/PROJ32, so every time the PROJ device automounted when inserted into the PC a folder with a number n+1 would be added. All those were owned by root, e.g.: =>drwxr-xr-x 6 root root 4096 Feb 19 19:38 PROJ32– andrej Feb 19 '24 at 20:24sudo nano /var/lib/polkit-1/localauthority/10-vendor.d/com.ubuntu.desktop.pklaAnd add # at the start of line 2Identity=unix-group:admin;unix-group:sudochanging it to#Identity=unix-group:admin;unix-group:sudonow the USB drive auto-mounts only with user permissions andls -l /media/lubuntu/outputsdrwxrwxrwx 1 lubuntu lubuntu 4096 Feb 18 18:45 PROJand so when it is unplugged, the folder /media/lubuntu/PROJ where it mounts is eleted and on succesivce mounts, it automounts to /media/lubuntu/PROJ again... so solved. – andrej Feb 19 '24 at 20:29/etc/fstab. Use a portable installed system in the USB drive. This works particularly well, if you use an SSD (connected via USB), because it is not as sensitive to wear and corruption of the file system as a cheap USB pendrive. See this link, which describes how you can start with a compressed image of Ubuntu Server 'Jammy' (22.04.x LTS) and installlubuntu-desktopinto it. – sudodus Feb 20 '24 at 10:18