Ubuntu mounts Windows partitions and reads and writes NTFS partitions automatically

Source: Internet
Author: User
Tags locale mkdir

A

Edit the Mount script Autowinfs by executing the following command.

sudo gedit/usr/sbin/autowinfs

Copy and paste the following referenced content,
Save the file and exit.

#!/bin/sh
#
#autowinfs Auto Mount Windows disks
#
# Copyright (c) Jiahua Huang <jhuangjiahua@gmail.com>
#License: GPLv2

#
#/usr/bin/sutowinfs
# used to automatically mount Windows partitions on the machine and write to/etc/fstab
# 52 months 14:06:12 CST 2005

Mkdir-p/windows/
rmdir/windows/* 1>/dev/null
Grep-v '/windows/'/etc/fstab >/ETC/FSTAB.SWP


# This script is used for UTF-8 Locale
# The individual fdisk-l cannot list partitions, so it's very rare to remove/dev/[hs]d[a-z]
# # Fdisk-l/dev/[hs]d[a-z] | Grep-e ' fat| NTFS ' | Cut-d '-f1 | cut-d/-F3 | While Read wdisks
# Looking for an NTFS partition, the new kernel's auto seems to have a problem, so now separate the NTFS from the VFST

Fdisk-l/dev/[hs]d[a-z] | grep ' NTFS ' | Cut-d '-f1 | cut-d/-F3 | While Read wdisks
Do echo "/dev/$WDISKS/windows/$WDISKS NTFS auto,user,nls=utf8,umask=0 0 0" >>/etc/fstab.swp
mkdir "/windows/$WDISKS"
Done

Fdisk-l/dev/[hs]d[a-z] | grep ' FAT ' | Cut-d '-f1 | cut-d/-F3 | While Read wdisks
Do echo "/dev/$WDISKS/windows/$WDISKS vfat auto,user,utf8,umask=0 0 0" >>/etc/fstab.swp
mkdir "/windows/$WDISKS"
Done

Mv/etc/fstab.swp/etc/fstab
Mount-a
Exit 0

To run the command again:

sudo chmod a+x/usr/sbin/autowinfs
Sudo/usr/sbin/autowinfs
On it, Windows partitions will be mounted under/windows/.


Two

In me and the actual use, the character set with UTF8 effect is very good, did not appear garbled problem, at the terminal Mount code as follows:
Mount-t vfat/dev/hda2/mnt/d-O Codepage=936,iocharset=utf8

My fstab.
#/etc/fstab:static File System information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
PROC/PROC proc Defaults 0 0
/DEV/HDC8/EXT3 Defaults,errors=remount-ro 0 1
/DEV/HDC9 None swap SW 0 0
/dev/hdb/media/cdrom0 udf,iso9660 User,noauto 0 0
/dev/hdc1/mnt/winc vfat Defaults,codepage=936,iocharset=utf8 0 0
/dev/hdc5/mnt/wind NTFS defaults,iocharset=utf8,umask=0222 0 0
/dev/hdc6/mnt/wine NTFS defaults,iocharset=utf8,umask=0222 0 0
/dev/hdc7/mnt/winf vfat Defaults,codepage=936,iocharset=utf8 0 0


(following from the network)
1. The mount point must be a directory.

2, a partition mount in an existing directory, this directory can not be empty, but after the download of this directory in the previous

The volume will not be available.
This is also true for the mounting of file systems built by other operating systems. But what you need to understand is: CDs, floppy disks, other actions

The file system used by the system is not the same as the file system format used by Linux. Disc is ISO9660; floppy disk is

FAT16 or Ext2;windows NT are FAT16, NTFS;WINDOWS98 are FAT16, fat32;windows2000 and

Windows XP is FAT16, FAT32, and NTFS. Before you mount, see if Linux supports the file system format you want to mount.


Use Mount command when mounting:
Format: Mount [-parameters] [device name] [Mount Point]

Some of the commonly used parameters are
-t< File System Type > Specifies the file system type of the device, which is common:
Minix Linux The earliest file system used
Ext2 Linux currently used in the file system
Msdos MS-DOS FAT is the FAT16
The common FAT32 of VFAT Windows98
NFS Network File System
ISO9660 CD-ROM standard file system
File systems for NTFS Windows NT 2000
HPFS OS/2 File System
Auto Auto Detect file system
-o< Options > Specify options for mounting file systems. Some can also be used in/etc/fstab. Commonly used to have
CODEPAGE=XXX code page
Iocharset=xxx Character Set
RO is mounted as read-only
RW mounts in read-write mode
Nouser makes it impossible for general users to Mount
User can mount devices for general users

To remind you that the Mount command does not have the ability to mount points, so you should make sure that when you execute the Mount command, the mount point is saved

In. (Don't understand.) The point is that you have to mount the file system, first of all to build a directory. That's OK. )

Example: Windows98 is mounted on the HDA1 partition, and there are floppy disks and discs on the computer that need to be mounted.
# Mk/mnt/winc
# Mk/mnt/floppy
# Mk/mnt/cdrom
# mount-t Vfat/dev/hda1/mnt/winc
# mount-t Msdos/dev/fd0/mnt/floppy
# mount-t Iso9660/dev/cdrom/mnt/cdrom
You can now access the/MNT/WINC and other directories to read and write these file systems.

To ensure that the last two lines of command are not faulted, make sure that there is a disk in the floppy drive and CD drive. (If disk slices on your hard disk can always

I don't think I would have made such a mistake if I had to change my:->.
If you have a Chinese file name in your Windows98 directory, use the command above to mount a stack of garbled characters. This will

Use the CodePage iocharset option in the-o argument. CODEPAGE specifies the code page for the file system, Simplified Chinese

Code is 936;iocharset specified character set, Simplified Chinese generally used cp936 or gb2312.


When the mounted file system Linux is not supported, mount a certain error, such as the Windows2000 NTFS file system. Can again

Compile the Linux kernel to gain support for the filesystem. About recompiling the Linux kernel, it's not here to say.

Four, automatic mount
Running the mount command on every boot access windows partition is obviously too cumbersome, why access to other Linux partitions does not make

With the Mount command.
In fact, every time the boot, Linux automatically will need to mount the Linux partition mount. So are we going to be able to set

Linux also mounts the partitions we want to mount, such as Windows partitions, to enable automatic mounting of the file system at boot time.


This is perfectly possible. There is a fstab file in the/etc directory that lists the file systems that are automatically mounted when Linux is powered on

The list. My/etc/fstab file is as follows:

/DEV/HDA2/EXT3 Defaults 1 1
/dev/hda1/boot ext3 Defaults 1 2
None/dev/pts devpts gid=5,mode=620 0 0
NONE/PROC proc Defaults 0 0
NONE/DEV/SHM TMPFS Defaults 0 0
/dev/hda3 Swap Defaults 0 0
/dev/cdrom/mnt/cdrom iso9660 noauto,codepage=936,iocharset=gb2312 0 0
/dev/fd0/mnt/floppy Auto Noauto,owner,kudzu 0 0
/dev/hdb1/mnt/winc vfat defaults,codepage=936,iocharset=cp936 0 0
/dev/hda5/mnt/wind vfat defaults,codepage=936,iocharset=cp936 0 0


In the/etc/fstab file, the first column is the device name of the mounted file system, the second column is the mount point, and the third column is the mounted text

System type, the fourth column is the option to mount, and the options are separated by commas. The 56th column does not know what meaning, also hope the master

Pointing.

In the last two lines I manually added the c;d disk under Windows, adding codepage=936 and iocharset=cp936 parameters to the support

Hold the file name in Chinese. The parameter defaults actually contains a set of default parameters:

RW mounts in readable and writable mode
SUID Open User ID and group ID settings bit
Dev can interpret character or block devices on a file system
EXEC executable binaries
Auto Mount automatically
Nouser makes it impossible for general users to Mount
Async performs an input-output operation of the file system in a unsynchronized manner

As you can see in this list, the optical drive and floppy drive are not mounted automatically, and the parameters are set to Noauto. (If you have to set

To automatically mount, you want to ensure that every time you turn on the CD-ROM and floppy drive must have a disk, hehe. )


(iii) Allow Ubuntu to support NTFS read and write
Using ntfs-3g (the source of cn99 can be installed directly) you can create unlimited new, deleted files on NTFS partitions!
1, installation
sudo apt-get install ntfs-3g
2. Configuration:
sudo gedit/etc/fstab
Find the one that you need to open read and write NTFS partitions, the original "NTFS" changed to "ntfs-3g", if you want to open all, replace All "NTFS" as "ntfs-3g", Save exit
sudo gedit/etc/modules
Add a row at the end of the file (if there are no more:-)
Fuse

Reboot or if you want to test now:

    sudo modprobe fuse
    sudo umount-a
    sudo mount-a     For more information please refer to: http://hj123.byethost13.com/?p=17
Important information (ntfs-3g support Chinese directory):
  Edit: fstab
  sudo  nano /etc/fstab
  The Mount of NTFS partitions in the following format:
  /dev/hda1    /windows/hda1 N tfs-3g Silent,umask=0,locale=zh_cn.utf8 0 0
Note that the red one should be changed to your own corresponding NTFS partition. Don't copy it.

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.