script to mount partition and open a Nemo-window

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
bill99
Level 2
Level 2
Posts: 79
Joined: Tue Jan 26, 2016 12:37 pm

script to mount partition and open a Nemo-window

Post by bill99 »

Hello forum

I am trying to r/w mount a FAT32 partition from cli under a Mint live system, but do get the following error message:

mint@mint ~ $ 'sudo mount /dev/sdb2 on /media/mint/BU type fuseblk rw,nosuid,nodev,allow_other,default_permissions,blksize=4096'

1.
What's the problem with this command?


2.
In addition (after mounting) a Nemo-instance should be started and a predefined folder should be opended.
(e.g. a forder "test" under /media/mint/BU)

How can this two commands be integrated into a shell-script?


Any feedback is appreciated. Thanks!

Bill
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
User avatar
spamegg
Level 14
Level 14
Posts: 5104
Joined: Mon Oct 28, 2019 2:34 am
Contact:

Re: script to mount partition and open a Nemo-window

Post by spamegg »

What is the error message?

You need to remove the quotes when you type it in the command line.
User avatar
AndyMH
Level 21
Level 21
Posts: 13757
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: script to mount partition and open a Nemo-window

Post by AndyMH »

What's the problem with this command?
Quite a lot, read man mount. The folder /media/mint/BU must exist.

Code: Select all

sudo mount -t vfat /dev/sdb2  /media/mint/BU -o rw,umask=0000
There are a number of options you could use, windows_names if the drive is going anywhere near windows, uid=1000,gid=1000 will probably work in place of rw,umask=0000.

For running nemo, see viewtopic.php?p=2001397#p2001397
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
bill99
Level 2
Level 2
Posts: 79
Joined: Tue Jan 26, 2016 12:37 pm

Re: script to mount partition and open a Nemo-window

Post by bill99 »

spamegg wrote: Thu Apr 15, 2021 11:34 am What is the error message?

You need to remove the quotes when you type it in the command line.
Sorry.. but forgot to mention that it's a NTFS-partition....


#'sudo mount' among other entries does list:
/dev/sdb2 on /media/mint/BU type fuseblk (rw,nosuid,nodev,allow_other,default_permissions,blksize=4096)


Therefore I used the following command: (the folder "test" does exist on /media/mint)

#sudo mount /dev/sdb2 on /media/mint/BU/test type fuseblk rw,nosuid,nodev,allow_other,default_permissions,blksize=4096

Usage: mount -V : print version
mount -h : print this help
mount : list mounted filesystems
mount -l : idem, including volume labels
So far the informational part. Next the mounting.
The command is `mount [-t fstype] something somewhere'.
Details found in /etc/fstab may be omitted.
mount -a [-t|-O] ... : mount all stuff from /etc/fstab
mount device : mount device at the known place
mount directory : mount known device here
mount -t type dev dir : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
mount --bind olddir newdir
or move a subtree:
mount --move olddir newdir
One can change the type of mount containing the directory dir:
mount --make-shared dir
mount --make-slave dir
mount --make-private dir
mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
mount --make-rshared dir
mount --make-rslave dir
mount --make-rprivate dir
mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using -L label or by uuid, using -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
bill99
Level 2
Level 2
Posts: 79
Joined: Tue Jan 26, 2016 12:37 pm

Re: script to mount partition and open a Nemo-window

Post by bill99 »

Also tried this command:

mint@mint ~ $ sudo mount -t ntfs /dev/sdb2 /media/mint/BU/test
fuse: failed to access mountpoint /media/mint/BU/test: No such file or directory

But folder "test" does exist...…

mint@mint /media/mint/BU/test $
User avatar
shedyed
Level 4
Level 4
Posts: 313
Joined: Wed Feb 03, 2021 5:12 pm

Re: script to mount partition and open a Nemo-window

Post by shedyed »

You may have to paste the script within code tags. But does your code take up two lines, it could just be missing a continuity character. Otherwise the line is split in two, and you're giving the system two half-baked requests.

/media/mnt/blabla was treated as the next command, but you get 'file not found', as it's not a command; it's a location
User avatar
shedyed
Level 4
Level 4
Posts: 313
Joined: Wed Feb 03, 2021 5:12 pm

Re: script to mount partition and open a Nemo-window

Post by shedyed »

sorry, my bad. i can see better from my laptop instead of the phone.
your command syntax has to follow a certain order, like the -t ntfs should come after mount /dev/whatev /here. That is probably why you're getting the mount manual handed to you.
It's like the really important parts in mount would be mount A B, anything else (like the little details -t ntfs, etc) should be identified accordingly, like type or option. Once you start using them, all the succeeding ones should have theirs, too.

Somebody might be able to explain it better, or maybe I could show you
mount /dev/sdb2 /media/mint/BU/test -t ntfs

Or a useful reference on https://www.extremetech.com/computing/1 ... -commands
User avatar
all41
Level 19
Level 19
Posts: 9523
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: script to mount partition and open a Nemo-window

Post by all41 »

You can mount using the partition uuid---example:

pkexec mount UUID=a275d558-6d53-4290-a25d-f7efeb3d4d2s && nemo "path_to_directory"

(use quotes around path if the path contains spaces or characters)
You can copy the UUID from the Disks utility in your menu. This way that partition will get mounted regardless of the naming.
The device number (/dev/sxxx) can change when other memory devices are used.
After a correct mount the above example Nemo will open the directory specified


Just to add:
Only root can mount so you will be prompted for admin password

You can also run
sudo mkdir /media/mint/BU
If that directory exists it will tell you, if not it will create it.
Everything in life was difficult before it became easy.
User avatar
AndyMH
Level 21
Level 21
Posts: 13757
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: script to mount partition and open a Nemo-window

Post by AndyMH »

shedyed wrote: Wed Apr 21, 2021 4:12 pm your command syntax has to follow a certain order, like the -t ntfs should come after mount /dev/whatev /here.
Incorrect, read the man page, it can come before

Code: Select all

mount [-fnrsvw] [-t fstype] [-o options] device dir
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
bill99
Level 2
Level 2
Posts: 79
Joined: Tue Jan 26, 2016 12:37 pm

Re: script to mount partition and open a Nemo-window

Post by bill99 »

Thanks a lot to all of you for the help! It seems that I still have to learn a lot (tried to mount a folder :-)

Now the whole thing has to be integrated into a working scell-script. Probably like that:

#!/bin/sh
sudo mkdir /media/mint/BU
sudo mount /dev/sdb2 /media/mint/BU -t ntfs
xdg-open /media/mint/BU/test


$ sh ./Desktop-Linux-Setup-Scripts__mount-Partition-BU.sh
would work, but since I would like to place that shell-script on the desktop
of a simple linux-remaster (and afterwards used as a Linux Live System) it should
be "executeable" by clicking on it with the filemanger.
In my case it's simply opended in the text-editor(xed) of LM. "Open with" is too complicated for my mom.....


Question:
Is there a way to run this script by clicking on it with the filemanger?
E.g. by adding some code to the script? Better appraoches are wellcomed :)


Thank you very much!

Bill
deepakdeshp
Level 20
Level 20
Posts: 12341
Joined: Sun Aug 09, 2015 10:00 am

Re: script to mount partition and open a Nemo-window

Post by deepakdeshp »

If you double click the NTFS partition, it should be mounted.
If I have helped you solve a problem, please add [SOLVED] to your first post title, it helps other users looking for help.
Regards,
Deepak

Mint 21.1 Cinnamon 64 bit with AMD A6 / 8GB
Mint 21.1 Cinnamon AMD Ryzen3500U/8gb
User avatar
AndyMH
Level 21
Level 21
Posts: 13757
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: script to mount partition and open a Nemo-window

Post by AndyMH »

$ sh ./Desktop-Linux-Setup-Scripts__mount-Partition-BU.sh
would work, but since I would like to place that shell-script on the desktop
of a simple linux-remaster (and afterwards used as a Linux Live System) it should
be "executeable" by clicking on it with the filemanger.
In my case it's simply opended in the text-editor(xed) of LM. "Open with" is too complicated for my mom.....
Is there any reason why, as deepakdeshp suggested, you don't just double click on it in your file manager to mount it?

Make the script executable, right click on it in your file manager, properties > permissions and check the box 'allow executing file as program'.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
Locked

Return to “Beginner Questions”