New school: how to mount a hard disk in a Linux operating system

Source: Internet
Author: User
Article Title: New School: how to mount a hard disk in a Linux operating system. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Mount Windows partitions

1. Manual mounting

In Linux, you can also read Windows partitions, including fat32 and ntfs. First, you need to know the name of Hard Disk Partition in Linux. For example, in Windows, the C drive is generally hda1, the D Drive is hda5, And the e drive is hda6. For details, see the relevant documentation.

To mount Windows partitions, you must first determine the locale of your Linux system (this locale includes the language and character encoding information used by the system ). Common locale in Chinese Linux is zh_CN.gb2312, zh_CN.gbk, zh_CN.gb18030 and zh_CN.UTF-8.

In the default installation, locale for Debian Linux and Mandriva Linux is zh_CN.gb2312, while locale for Ubuntu Linux and Fedora Linux is a zh_CN.UTF-8. It is best not to change locale at will, otherwise there will be a lot of garbled characters. To view the locale of the system, run the following command on the terminal:

Echo $ LANG

Secondly, you need to know the format of your windows partition. This can be seen in the partition attributes of windows, which are generally in the fat32 and ntfs formats.

Assuming that your locale is a zh_CN.UTF-8, mount a windows partition in fat32 format in/dev/hda1 to the/mnt/C directory (if this directory does not exist, create a new one manually ), you can enter the following command in the terminal (sudo must be added before this command in Ubuntu ):

Mount-t vfat/dev/hda1/mnt/C-o iocharset = utf8

If your locale is not a zh_CN.UTF-8, change the utf8 command above to gb2312; if the windows partition is in ntfs format, change the vfat command above to ntfs.

In this way, only root partitions in ntfs format can be read. If you want normal users to read partitions, you need to add the umask = 022 option, as shown below:

Mount-t ntfs/dev/hda1/mnt/C-o iocharset = utf8, umask = 022

Similarly, if you want to allow all users to read and modify the mounted partition, you can change umask = 022 to umask = 0.

Detaching a partition is much easier:

Umount/dev/hda1

When detaching a partition, the system prompts that the partition is busy (device is busy). You can use the following command to check which process is using this partition:

Fuser-cu/dev/hda1

If the screen output is

/Dev/hda1: 8463 m (PCP)

You can use this command to view the program name of the process:

Ps 8463

Then you can run this command to end the process:

Kill-9 8463

In this way, you can unmount the partition normally.

2. automatic mounting

To enable the Linux system to automatically mount windows partitions at startup, you can write the preceding command to the/etc/fstab file. The following is an example:

        
         # /etc/fstab: static file system information.##[file system] [mount point] [type] [options] [dump] [pass]proc /proc proc defaults 0 0/dev/hda9 / ext3 defaults 0 1/dev/hda13 none swap sw 0 0/dev/hdc /media/cdrom iso9660 ro,user,noauto 0 0/dev/fd0 /media/floppy auto rw,user,noauto 0 0/dev/hda10 /mnt/debian ext3 defaults 0 0/dev/hda1 /mnt/C ntfs utf8,umask=022 0 0/dev/hda5 /mnt/D vfat utf8,umask=0 0 0
        
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.