Linux (CentOS) Mount U disk, mobile hard disk and file copy, backup __linux

Source: Internet
Author: User
Tags file copy locale mkdir

Description
Environment: VMware Workstation
System: centos6.2
The following actions are performed under root

1.U Disk Mount

MKDIR/MNT/USB//Create a directory for mounting USB drive
Fdisk-l//View the System Mount U disk, if the system has a hard disk SDB1 on behalf of your U disk,/DEV/SDB1 show that the machine has identified the U disk,
MOUNT/DEV/SDB1/MNT/USB///DEV/SDB1 mount the U disk to the/MNT/USB directory
CD/MNT/USB//Enter U disk directory, you can view the contents of U disk
Umount/mnt/usb or UMOUNT/DEV/SDB1//uninstall U disk

2. mount a removable hard drive
We usually use the mobile hard disk is in NTFS format, Linux by default is not supported NTFS partitions, so need to install a Third-party plug-in ntfs-3g Linux.

Install ntfs-3g
Yum install gcc//install compiler, always press Y, and if you fail to compile ntfs-3g after installing GCC, GCC is a compiler for programming in Linux.

MKDIR/USR/LOCAL/NTFS3G//Create folder ntfs3g for later compile installation ntfs-3g
CD/USR/LOCAL/SRC//linux The default source code package storage location; Source Package compile installation bit
Place:/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/decompression ntfs-3g software compression pack
CD ntfs-3g_ntfsprogs-2011.4.12//Enter just unzipped folder, do not know directory name can be used LS to view directory name
./configure--prefix=/usr/local/ntf3g//compilation, specifying the installation directory/usr/local/ntf3g
Make&&make Install//compile installation
CD//Back to root directory
Rm-r-F ntfs-3g_ntfsprogs*//Delete all ntfs-3g_ntfsprogs headed all files without a reminder, "*" means match all, r recursive processing, will All files and subdirectories under the specified directory are processed together, and-F forces the file or directory to be deleted.

Mount
Fdisk-l//View mount information to see if the system recognizes the removable hard drive,/dev/sda1 represents the first partition of the first hard drive,/DEV/SDB1 represents the first partition of the second hard drive,

disk/dev/sdb:160.0 GB, 160041885696 bytes
255 heads, Sectors/track, 19457 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Sector size (logical/physical): bytes/512 bytes
I/O size (minimum/optimal): 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 a piece of information

CD/MNT//Enter directory
mkdir usb1 USB2 USB3 usb4//Create 4 directories mount a removable hard disk separately mount command one:

Ntfs-3g/dev/sdb1/mnt/usb1-o Locale=ar_sa. UTF-8, the red part can also be changed to ZH_CN. GBK, it is obvious that the use of some kind of code to mount, to prevent garbled;//mount each partition to the corresponding directory, the following section can not add

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 two:
Mount NTFS-3G/DEV/SDB1/MNT/USB1
......
LS//view mobile hard drive information
Copy, back up files
Cp-r/web/mnt/usb1//Copy all files in the Web directory into the/MNT/USB1 directory, that is, copy to the/DEV/SDB1 partition on the mounted mobile hard disk
UMOUNT/DEV/SDB1 or UMOUNT/MNT/USB1//uninstall mounted removable drive

Mount the removable hard drive automatically on the boot
----Edit/etc/fstab
Cp/etc/fstab/etc/fstabbak//edit before the backup, develop this good habit.
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 exit and the system will automatically mount the removable hard drive after reboot










This article is from the "AOEIUÜBPMF" blog, please be sure to keep this source http://hellopyl.blog.51cto.com/4271020/932639

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.