Monday, July 27, 2015

How to mount/connect usb drive in Linux server

If you want to copy something from/to the server from usb drive, your required to connect it or simply mounting the usb, below are steps

a. Connect the usb drive to the server

b. Check if it is connected by running the following command

  #fdisk -l

eg.

root@myserver:/home/admin# fdisk -l

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders, total 312581808 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cff3c

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048      499711      248832   83  Linux
/dev/sda2          501758   312580095   156039169    5  Extended
/dev/sda5          501760   312580095   156039168   8e  Linux LVM

Disk /dev/mapper/cpvirt--vg-root: 155.6 GB, 155604484096 bytes
255 heads, 63 sectors/track, 18917 cylinders, total 303915008 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/cpvirt--vg-root doesn't contain a valid partition table

Disk /dev/mapper/cpvirt--vg-swap_1: 4177 MB, 4177526784 bytes
255 heads, 63 sectors/track, 507 cylinders, total 8159232 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/mapper/cpvirt--vg-swap_1 doesn't contain a valid partition table
Note: sector size is 4096 (not 512)

Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes
255 heads, 63 sectors/track, 45600 cylinders, total 732566646 sectors
Units = sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000b061a

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *         256   732566591  2930265344   83  Linux



c. Create a new mount point/directory where the usb disk will be mounted

# mkdir /mnt/sdb1


d.  Mount /dev/sdb1 which is the location of our usb disk to the new created mount point

#mount -t ext4 /dev/sdb1 /mnt/sdb1

e. To make the change permanent edit /etc/ftab with the new mount point

# echo ''/dev/sdb1 /mnt/sdb1 ext4 defaults 0 0'' >> /etc/fstab


f. Mount all entries in /etc/fstab in not already mounted

# mount -a

g. Check if the usb drive is mounted

#mount | grep sdb1

h. The mounting is done, to access usb drive content, you may run the following command

# cd /mnt/sdb1



Enjoy!



No comments:

Post a Comment