Saturday, June 1, 2013

Mount NTFS portable USB drive in RHEL5 OEL or CenOS Linux 5

Mount NTFS portable USB drive in RHEL5 OEL or CenOS Linux 5

So you have a USB flash or portable hard drive formated with NTFS partition that you want to use in Enterprise Linux 5?
The problem is EL5 does not recognize the drives formatted with NTFS partition.
To solve the issue:
- we will enable an extra package repository called EPEL
- install the ntfs-3g package
- mount the usb portable Hard drive
The exact version of epel-release-5-4.noarch.rpm may vary. Please navigate to the URL where the package is stored.
(ex: http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel//5Server/x86_64/ and search for “epel-release” and download the available version)
Download and install EPEL repository as root user:
# rpm -Uvh http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel//5Server/x86_64/epel-release-5-4.noarch.rpm
Retrieving http://ftp.jaist.ac.jp/pub/Linux/Fedora/epel//5Server/x86_64/epel-release-5-4.noarch.rpm
warning: /var/tmp/rpm-xfer.bwnAza: Header V3 DSA signature: NOKEY, key ID 217521f6
Preparing…                ########################################### [100%]
   1:epel-release           ########################################### [100%]
- install ntfs-3g package which is used to mount NTFS formatted drives.

# yum install ntfs-3g

Sample output:
[root@oratemp yum.repos.d]# yum install ntfs-3g
Loaded plugins: rhnplugin, security
This system is not registered with ULN.
ULN support will be disabled.
epel                                                                                                                | 3.7 kB     00:00
epel/primary_db                                                                                                     | 3.8 MB     00:29
Setting up Install Process
Resolving Dependencies
–> Running transaction check
—> Package ntfs-3g.i386 2:2011.4.12-5.el5 set to be updated
—> Package ntfs-3g.x86_64 2:2011.4.12-5.el5 set to be updated
–> Finished Dependency Resolution Dependencies Resolved
===========================================================================================================================================
 Package                        Arch                          Version                                    Repository                   Size
===========================================================================================================================================
Installing:
 ntfs-3g                        i386                          2:2011.4.12-5.el5                          epel                        319 k
 ntfs-3g                        x86_64                        2:2011.4.12-5.el5                          epel                        301 k
Transaction Summary
===========================================================================================================================================
Install       2 Package(s)
Upgrade       0 Package(s)
Total download size: 619 k
Is this ok [y/N]: y
Downloading Packages:
(1/2): ntfs-3g-2011.4.12-5.el5.x86_64.rpm                                                                           | 301 kB     00:00
(2/2): ntfs-3g-2011.4.12-5.el5.i386.rpm                                                                             | 319 kB     00:00
——————————————————————————————————————————————-
Total                                                                                                      126 kB/s | 619 kB     00:04
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID 217521f6
epel/gpgkey                                                                                                         | 1.7 kB     00:00
Importing GPG key 0x217521F6 “Fedora EPEL ” from /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : ntfs-3g                                                                                                             1/2
  Installing     : ntfs-3g                                                                                                             2/2
Installed:
  ntfs-3g.i386 2:2011.4.12-5.el5                                      ntfs-3g.x86_64 2:2011.4.12-5.el5
Complete!

How Do I Find Out NTFS Partition Name?

Immediately after you plug in the USB device run dmesg command:
$ dmesg
usb 1-5: new high speed USB device using ehci_hcd and address 3
usb 1-5: configuration #1 chosen from 1 choice
scsi6 : SCSI emulation for USB Mass Storage devices
usb-storage: device found at 3
usb-storage: waiting for device to settle before scanning
  Vendor: Kingston  Model: DataTraveler G3   Rev: PMAP
  Type:   Direct-Access                      ANSI SCSI revision: 00
SCSI device sdb: 62603264 512-byte hdwr sectors (32053 MB)
sdb: Write Protect is off
sdb: Mode Sense: 03 41 00 00
sdb: assuming drive cache: write through
SCSI device sdb: 62603264 512-byte hdwr sectors (32053 MB)
sdb: Write Protect is off
sdb: Mode Sense: 03 41 00 00
sdb: assuming drive cache: write through
 sdb: sdb1
sd 6:0:0:0: Attached scsi removable disk sdb
sd 6:0:0:0: Attached scsi generic sg6 type 0
usb-storage: device scan complete
fuse init (API version 7.8)
fuse distribution version: 2.7.4
usb 1-5: USB disconnect, address 3


Form the output of dmesg we see that the device name is ‘sdb’ so ‘/dev/sdb’
Then simply type the following command to list what is in /dev/sdb :
# fdisk -l /dev/sdb
Sample outputs:
Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xf0000000
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          13      102400    7  HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/dev/sdb2              14       60802   488281089    5  Extended
/dev/sdb5              14       59767   479970304   83  Linux
/dev/sdb6           59767       60802     8309760   82  Linux swap / Solaris

How Do I Mount /dev/sda1 NTFS Partition at /mnt/ntfs?

Create a mount point, enter:
# mkdir /mnt/ntfs
To mount the ntfs partition, enter:
#
ntfs-3g /dev/sda1 /mnt/ntfs
You can use regular Unix commands to copy or access the files:
$ df -h
$ mount
$ cd /mnt/ntfs
$ cp foo /tmp

How Do I Unmount(safely remove) NTFS Disk/Partition?

Type the following command:
# umount /mnt/ntfs
or
# umount /dev/sdb1
Redhat Enterprise 5 - 5.6, Oracle Enterprise Linux 5 - 5.6, CentOS 5 to 5.7

rsync with delete option and different ssh port

How to rsync e.g PIPELINE dir from Source to Destination? #rsync -avzr   --delete-before  -e "ssh -p $portNumber"  /local...