Member Avatar for Josue198s

how do i mount a hardrive on Ubuntu via terminal?

First you have to find out what device name the system has given the new drive. Normally it is something like /dev/sda (which stands for scsi or sata drive a) or /dev/hda (pata drive a) and then it will be broken down by partitions. For example the second sata drive primary partition would be /dev/sdb0 .
You can check what partitions the system sees with

fdisk -l

and then mount the partition as a directory on the system. The /mnt directory is normally used for this and the contents or the drive replace what was previously visible in the directory (so don't mount anything to /home or /var or /etc OK). To mount the second PATA hard drive primary partition as /mnt you would use:

mount /dev/hdb0 /mnt

If you are not sure about the mount options use the man pages to get more info:

man mount

This may be of use - it normally works for me.

First plug in the USB device and check that it has been seen.

[shibblez@server mnt]$ dmesg
usb 1-5: new high speed USB device using address 12
scsi9 : SCSI emulation for USB Mass Storage devices
  Vendor: SanDisk   Model: Cruzer            Rev: 8.02
  Type:   Direct-Access                      ANSI SCSI revision: 02
Attached scsi removable disk sda at scsi9, channel 0, id 0, lun 0
USB Mass Storage device found at 12
SCSI device sda: 7856127 512-byte hdwr sectors (4022 MB)
sda: Write Protect is off
sda: Mode Sense: 45 00 00 08
sda: assuming drive cache: write through
SCSI device sda: 7856127 512-byte hdwr sectors (4022 MB)
sda: Write Protect is off
sda: Mode Sense: 45 00 00 08
sda: assuming drive cache: write through
sda: sda1
[shibblez@server mnt]$

Now mount the device - note that it is /dev/sda1 and not /dev/sda. Ithen list its contents and unmount it.

[shibblez@server mnt]$ sudo mount /dev/sda1 usb00/
[shibblez@server mnt]$ ls usb00
Documents  LaunchU3.exe  System
[shibblez@server mnt]$ sudo umount usb00
[shibblez@server mnt]$ ls usb00
[shibblez@server mnt]$
Member Avatar for Josue198s

in order for fdisk -l to work you have to write sudo first...ie sudo fdisk -l

Member Avatar for Josue198s

after writing sudo mount /dev/sdb /mnt then i press enter gives me this message.

lnx@lnx:~$ sudo mount /dev/sdb /mnt
mount: /dev/sdb already mounted or /mnt busy
lnx@lnx:~$ sudo mount /dev/sdb /mnt

Ah I cheat and run
sudo su -
Opens a root shell with all of roots paths and variables.

I am always use the Ubuntu.. and this through get the speedway work out and very easy way to support...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.