CentOS mounting USB flash drives, mobile hard disks, and file copying and backup

Source: Internet
Author: User
Note: Environment: VMwareworkstation system: 1. mount mkdir/mnt/usb // to create a directory for mounting the usb disk fdisk-l // view the usb disk mounted in the system. if the system has a hard disk, sdb1 indicates your usb disk, /dev/sdb1 indicates the machine

Note:
Environment: VMware workstation
System: centos6.2
The following operations are performed under root

1. USB flash disk mounting

Mkdir/mnt/usb // create a directory for attaching a usb flash drive
Fdisk-l // view the USB flash drive mounted in the system. if the system has a hard disk, sdb1 indicates your USB flash drive./dev/sdb1 indicates that the USB flash drive has been recognized by the machine,
Mount/dev/sdb1/mnt/usb // mount the usb flash drive/dev/sdb1 to the/mnt/usb directory.
Cd/mnt/usb // enter the usb flash drive directory to view the content in the usb flash drive.
Umount/mnt/usb or umount/dev/sdb1 // uninstall the usb flash drive

2. Mount a mobile hard disk
We usually use the mobile hard disk is NTFS format, linux by default is not supported NTFS partition, so you need to install a third-party plug-in NTFS-3G in linux.

Install NTFS-3G
Yum install gcc // install the compiler, always press Y, if you do not install gcc after the compilation of NTFS-3G will fail, gcc is a language lonux system programming compiler,

Mkdir/usr/local/ntfs3g // create the folder ntfs3g for subsequent compilation and installation of NTFS-3g
Cd/usr/local/src // Default source code package storage location in linux; source code package compilation and installation bit
Set:/usr/local/software name
Wget http://tuxera.com/opensource/ntfs-3g_ntfsprogs-2011.4.12.tgz // download NTFS-3G
Tar zxvf ntfs-3g_ntfsprogs-2011.4.12.tgz // decompress NTFS-3G software package
Cd ntfs-3g_ntfsprogs-2011.4.12 // enter the unzipped folder, do not know the directory name available ls to view the directory name
./Configure -- prefix =/usr/local/ntf3g // compile and specify the installation directory/usr/local/ntf3g
Make & make install // compile and install


Cd // return the root directory
Rm-r-f ntfs-3g_ntfsprogs * // delete all files headed by ntfs-3g_ntfsprogs don't mention waking, '*' indicates matching all,-r recursive processing, processes all files and subdirectories under the specified directory, and-f forces the deletion of files or directories. Mount
Fdisk-l // Check the mounting information to see if the system recognizes the mobile hard disk./dev/sda1 indicates the first partition of the first hard disk, /dev/sdb1 indicates the first partition of the second hard disk,

Disk/dev/sdb: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 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: 0x7ab8d700

Device Boot Start End Blocks Id System
/Dev/sdb1*1 5222 41945683 + 7 HPFS/NTFS
/Dev/sdb2 5223 10444 41945715 7 HPFS/NTFS
/Dev/sdb3 10445 15666 41945715 7 HPFS/NTFS
/Dev/sdb4 15667 19457 30451207 + 7 HPFS/NTFS
The above is my drive information

Cd/mnt // enter the Directory
Mkdir usb1 usb2 usb3 usb4 // create four directories to mount each partition of the mobile hard disk.


Mount Command 1: NTFS-3G/dev/sdb1/mnt/usb1-o locale = ar_SA.UTF-8, red can also be changed to zh_CN.GBK, it is obvious that the use of some encoding for mounting, to prevent garbled; // mount each partition to the corresponding directory, and do not add the following parts

 

NTFS-3G/dev/sdb2/mnt/usb2-o locale = ar_SA.UTF-8
NTFS-3G/dev/sdb3/mnt/usb3-o locale = ar_SA.UTF-8
NTFS-3G/dev/sdb4/mnt/usb4-o locale = ar_SA.UTF-8
Mount Command 2:


Mount NTFS-3G/dev/sdb1/mnt/usb1
......
Ls // view mobile hard disk information
Copy and backup files
Cp-r/web/mnt/usb1 // Copy all files in the web directory to the/mnt/usb1 Directory, that is, copy the files to the/dev/sdb1 partition mounted to the mobile hard disk.
Umount/dev/sdb1 or umount/mnt/usb1 // unmount the mounted mobile hard disk

Automatically mount the mobile hard drive at startup
---- Edit/etc/fstab
Cp/etc/fstab/etc/fstabbak // back up data before editing.
Vi/etc/fstab // edit the file, add the following information at the end of the file, and press G (shift + g) at the end of the jump file)
/Dev/sdb1/mnt/usb1 NTFS-3G defaults 0 0
/Dev/sdb2/mnt/usb2 NTFS-3G defaults 0 0
/Dev/sdb3/mnt/usb3 NTFS-3G defaults 0 0
/Dev/sdb4/mnt/usb4 NTFS-3G defaults 0 0
: Wq! // Save and exit. after restart, the system will automatically mount the mobile hard disk.
 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.