[ubuntu-nz] How to mount USB drive when no-one is logged in?

Bruce Kingsbury zcat at zcat.geek.nz
Wed Apr 30 06:31:00 BST 2008


dmesg will tell you how the device got detected; typically it'll be /dev/sdb
or similar

sudo mkdir /media/usb
sudo mount /dev/sdb /media/usb

If you want ordinary users to have r/w access, you will want to throw in
some options with that, such as;

sudo mount /dev/sdb /media/usb -o umask=0

(read/write access for everybody!)


2008/4/30 Sid Bachtiar <sid.bachtiar at gmail.com>:

> I think there are two ways that I'm aware of ... both using /etc/fstab
> (http://ubuntuforums.org/showthread.php?t=283131)
> - One is to allow users to use pmount command to mount the drive
> - Another is to set the mounting to auto which would mount the drive
> automatically when the system boot
>
> I'm a newbie myself so I don't have the details on top of my head.
>
> On Wed, Apr 30, 2008 at 2:29 PM, Johann Schoonees
> <j.schoonees at irl.cri.nz> wrote:
> > I've googled and searched the archives but I'm getting swamped with
> >  marginally related "USB drive does not mount" hits.  Here goes:
> >
> >  When I log into the kubuntu Feisty desktop, there is an icon showing
> >  that my external USB drive is connected and mounted.
> >
> >  However, cron runs a nightly back-up script for me at 3 am when no-one
> >  should be logged in, but after migrating from Fedora to Feisty, it
> fails
> >  at the point where I try to mount the external USB drive:
> >
> >  MOUNT_OK=no
> >  for DISK in $DISK_LABELS
> >  do
> >  # mount -w "$MOUNT_POINT/$DISK" 2> /dev/null
> >  mount -w "$MOUNT_POINT/$DISK"
> >  MOUNT_RES=$?
> >  if [ "$MOUNT_RES" = "0" ]; then
> >  MOUNT_OK=yes
> >  break
> >  fi
> >  done
> >
> >  results in:
> >
> >  mount: can't find /media/backup_0 in /etc/fstab or /etc/mtab
> >  mount: can't find /media/backup_1 in /etc/fstab or /etc/mtab
> >  mount: can't find /media/backup_2 in /etc/fstab or /etc/mtab
> >  ...
> >
> >  even when a disk with label backup_1 (or 2 etc.) is connected.
> >
> >  There is no entry for /dev/sdb1 in /etc/fstab.  There is one in
> etc/mtab
> >  when someone is logged into the desktop, but not when not.  It looks
> >  something like this:
> >
> >  /dev/sdb1 /media/backup_1 ext3 rw,noexec,nosuid,nodev,sync,data=ordered
> 0 0
> >
> >  Under Fedora it used to look like this:
> >
> >  /dev/sdb1 /media/backup_1 ext3 rw,nosuid,nodev 0 0
> >
> >  The exact mount point depends on the disk label.  I have more than one
> >  back-up disk, each with a unique label.
> >
> >  Under Fedora there used to be an entry in fstab like this:
> >
> >  /dev/sdb1 /media/backup_1 ext3 pamconsole,exec,noauto,managed 0 0
> >
> >  which changed automatically (apparently under control of something
> >  called fstab-sync which I don't see in kubuntu) according to the label
> >  of the connected drive.
> >
> >  In short, how should my script detect and mount a connected USB
> external
> >  drive when no-one is logged in?
> >
> >  Any help appreciated,
> >  Johann
> >
> >  --
> >  ubuntu-nz mailing list
> >  ubuntu-nz at lists.ubuntu.com
> >  https://lists.ubuntu.com/mailman/listinfo/ubuntu-nz
> >
>
> --
> ubuntu-nz mailing list
> ubuntu-nz at lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-nz
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/ubuntu-nz/attachments/20080430/6349588e/attachment.htm 


More information about the ubuntu-nz mailing list