1

Every time i boot into my kubuntu i run

sudo mount -t ntfs-3g /dev/sda3 /home/username/Ntfs/C/
sudo mount -t ntfs-3g /dev/sda4 /home/username/Ntfs/Other/

I wanted to automate it hence i used sudo crontab -e and added the line @reboot /home/username/Ntfs/Mount.sh to it

Then in konsole i ran sudo chmod 777 Mount.sh at /home/username/Ntfs/Other/ dir

Contents of Mount.sh is as follows sudo mount -t ntfs-3g /dev/sda3 /home/username/Ntfs/C/ sudo mount -t ntfs-3g /dev/sda4 /home/username/Ntfs/Other/ exit 0
Questions

  • is it okay to mount ntfs drives inside my home dir......most guides suggested to mount them in /mnt/ dir
  • is it necessary to put exit 0 at last of my script.
  • because my script will anyway be executed with root privileges should i use sudo mount in the script also?
  • why do we use the argument -t with mount

1 Answers1

3

is it okay to mount ntfs drives inside my home dir......most guides suggested to mount them in /mnt/ dir

You can mount in anywhere you want ;) but the generic way is: /mnt/ for permanent disks and /media/ for removables.

is it necessary to put exit 0 at last of my script.

No. But it is cleaner. You could expand your script to catch errors and do an exit 1 when there is a problem.

because my script will anyway be executed with root privileges should i use sudo mount in the script also?

Do use /etc/crontab; you can add a user to those cron tab lines so no need for sudo. Or user sudo -i and use the crontab for root.

why do we use the argument -t with mount

-t indicates the type used to mount. In this case "ntfs-3g"

sudo chmod 777 Mount.sh

Never use 777 when 700 is more than enough. Others and group have no business with scripts run by root.

Please use /etc/fstab see for instance:

How do I correctly mount a NTFS partition in /etc/fstab?

btw does fstab mount the drives as read and write?

Yes if you tell it to do so. But do make sure the partition is clean: linux refuses to mount it writable if it is in an unsafe state.

Rinzwind
  • 299,756