Automatic mounting of hard disks in Ubuntu

Source: Internet
Author: User
The system was reinstalled some time ago, with the change and configuration of hard disk partitions. Specifically, I used the AcronisDiskDirectorSuite software to format the Ubuntu originally installed under ext4, because the original Ubuntu failed to update the kernel ,...

The system was reinstalled some time ago, with the change and configuration of hard disk partitions. Specifically, I used the Acronis Disk ctor Suite software to format the Ubuntu originally installed under ext4, because the original Ubuntu crashed because of kernel update, the graphic interface is unavailable. Currently, it is necessary for me to use the graphic interface. After many attempts, I gave up retrieving the Ubuntu and directly chose to reinstall it. although I regret why I used the weak wubi installation, as a result, every time you enter the startup interface, you must first select Ubuntu on the windows boot interface, and then start grub to select Ubuntu (as a result, you can select Ubuntu on the first interface, the other one chooses to go back to Win7 ). If I knew this, I may not leave a retreat for myself. I just installed a Ubuntu hard disk, which is much less troublesome and easier. (In this article: Workshop ).



I spoke a lot of nonsense and the problem came out. After each startup, you must manually attach each disk, such as the fun disk and learn disk, to listen to music and see what the e-book is. If it is not attached, my banshee won't be able to open the music in the list. it may be difficult to start it several times. Therefore, it is an automated process to manually mount it after each startup.

After Google and baidu, I felt that the effect was not very satisfactory. I mainly talked about too many things, not what I wanted or the content was too complicated. Therefore, let's take a look at the instructions. There are two main parts: Command mount and fstab.
(It is best to perform the following operations under sudo; otherwise, permission issues may occur)
Backup file/etc/fstab and edit the file. Observe the sample format and find

 

The preceding description and examples of proc in the instance.


Proc/proc nodev, noexec, nosuid 0 0

So try to rewrite it in your own way. Sudo fdisk-l view hard disk information.
Device Boot Start End Blocks Id System
/Dev/sda1*1 7572 60820168 + 7 HPFS/NTFS
Partition 1 does not end on cylinder boundary.
/Dev/sda2 7572 11494 31498240 7 HPFS/NTFS
Partition 2 does not end on cylinder boundary.
/Dev/sda3 11494 26506 120588288 + 5 Extended
Partition 3 does not end on cylinder boundary.
/Dev/sda4 26507 30401 31283280 7 HPFS/NTFS
Partition 4 does not end on cylinder boundary.
/Dev/sda5 11494 16715 41943040 7 HPFS/NTFS
/Dev/sda6 16716 21937 41943040 7 HPFS/NTFS
/Dev/sda7 21937 26506 36700160 7 HPFS/NTFS then mount the partitions one by one to see which one is the corresponding learn disk and fun disk. First, create a file under/media, such as test, then run the following command:
Sudo mount/dev/sda1/media/test
By judging the post-Mount content, you can know the disks in the above partitions, and then let's talk about them.

Edit the/etc/fstab file and add the configuration information of the disk to be automatically mounted at the end of the file, as shown below:
/Dev/sda4/media/Code ntfs nodev, noexec, nosuid 0 0
/Dev/sda5/media/Learn ntfs nodev, noexec, nosuid 0 0
/Dev/sda6/media/Fun ntfs nodev, noexec, nosuid 0 0 the only thing you need to note is the file type. here, my disks are of the ntfs type, therefore, you can view the document to find out the type (you don't know why it is OK to start using hpfs, but it will not work later). after several tests, you will find a type error.

Information error can be viewed by dmesg or tail.

After a type error is found, modify ntfs to mount the file correctly.

Then, use sudo mount/media/Fun ...... to mount the file.
Currently, note that the configuration file contains/media/Code ...... folder, so you need to create the corresponding folder under the/media folder, otherwise it will fail, note that it is also the administrator permission.

Finally, log out and log on again. you will be able to see the automatically mounted drive letter. at this time, you cannot detach umount, prompting that it is not a root user. So far, the first goal has been achieved. it can be automatically mounted upon startup.
If you want to use more personalized options and operations, you can view references. In addition, Man documents have a lot of useful information. reading documents is the fastest and most direct way.

If you want to cancel the mounting, use the umount command directly. For example, if you want to mount fun, run the following command: sudo umount/media/fun.

P.S: how to mount the ISO document? I downloaded lossless music in ISO format and didn't want to decompress it. how can I mount it?
Key: sudo mount *. iso/mnt-o loop (set *. change iso to the path where your iso is located. In addition, you do not have to mount it to the mnt Directory. you can create another folder, similar to creating Fun under media, same as Learn and other folders .)

P.S. S: What should I do if I want to add sudo to the terminal after entering the command? I also need to move the direction keys to select the insertion point. how troublesome is it?
Key:
Press Ctrl + A (case-insensitive) to jump to the first character, enter sudo, and press enter.


References:
In linux, we often use the mount command to mount hard disk partitions or discs to the file system. /Etc/fstab is the file system automatically mounted to linux during boot.

In linux, the data items of/etc/fstab are as follows:

/Dev/device mountpoint type rules dump order

Device Name Mount point partition type mount option dump option fsck option

For example, this is a common/etc/fstab:

/Dev/hda2/ext3 defaults 0 1

/Dev/hda3 swap defaults 0 0

/Dev/hda5/usr ext3 defaults 0 0

/Dev/fdo/mnt/flopy ext3 noauto 0 0

/Dev/cdrom/mnt/cdrom iso9660 noauto, ro 0 0

(1) device name
/Dev/device is the device to be mounted, and/hda2 is the second partition of the primary hard disk on the first IDE slot. If it is the third partition of the primary hard disk of the second IDE slot, it is/dev/hdc3. you can use fdisk-l in linux to view details.

(2) mount point
Mountpoint is the mount point. //,/Usr, and swap are default mount points in the system installation time zone.
If you want to mount a new device, you should think about it, because the new device will be a permanent part of the file system, according to FSSTND (file system standard) and its role, user needs. For example, if you want to use it as a shared resource, put it under/home is a good choice.

(3) partition type
Type refers to the file system type. The following lists several common types:

Linux file systems: ext2, ext3, jfs, reiserfs, reiser4, xfs, swap.
Windows:
Vfat = FAT 32, FAT 16
Ntfs = NTFS
Note: For NTFS rw NTFS-3G
CD/DVD/iso: iso9660
Network file systems:
Nfs: server:/shared_directory/mnt/nfs 0 0
Smb: // win_box/shared_folder/mnt/samba smbfs rw, credentials =/home/user_name/winbox-credentials.txt 0 0
Auto: The file system type (ext3, iso9660, etc) it detected automatically. usually works. used for removable devices (CD/DVD, Floppy drives, or USB/Flash drives) as the file system may vary on thesedevices.

(4) mount options
Rules refers to the rules for mounting. Below are several common examples:
Auto mount
Default sets the Mount definition according to the default values of most permanent file systems.
Noauto is not automatically mounted upon startup
Nouser can be mounted only by super users.
Ro mounting by Read-only permission
Rw mount by read/write permission
User any user can mount
Note that the optical drive and soft drive can be mounted only when the media is installed, so it is noauto

(5) dump options
If this parameter is set to 0, no backup is performed. If the last dump backup was used, the number of days since the backup is displayed.

(6) fsck options
Order refers to the order in which fsck checks are performed at startup ). If the value is 0, the check is not performed. (/) partitions are always 1. other partitions can only start with 2. when the numbers are the same, the check is performed simultaneously (but there cannot be two 1 ).

If I want to mount windows C on the primary hard drive of the second IDE slot to the file system, the data items are:

/Dev/hdc1/c vfat defaults 0 0

(/C is a pre-created folder, which serves as the Mount point of drive c .)

After you modify/etc/fstab, you must reboot the system to make it effective.

Fstab stores important information related to partitions. each row is a partition record, and each row can be divided into six parts, the following uses/dev/hda7/ext2 defaults 1 as an example to describe one by one:

1. The first is the physical location of the storage device you want to mount, such as hdb or/dev/hda7 in the above example.

2. the second item is the directory to which you want to add it, such as/home or/in the above example. this is the mount point prompted during installation.

3. the third item is the so-called local filesystem, which contains the following formats: ext, ext2, msdos, iso9660, nfs, swap, etc., or ext2, for more information, see/prco/filesystems.

4. the fourth item is the status you want to set when you mount, such as ro (read-only) or the above example of ULTS (including other parameters such as rw, suid, exec, auto, nouser, and async), you can refer to "mount nfs 」.

5. the fifth item is to provide the DUMP function. it indicates whether the BACKUP flag is required during system DUMP. The value is 0.

6. the sixth item is to set whether the filesystem needs to perform the check action at startup. except for the root filesystem, the required check value is 1. the other items can be set as needed. the internal value is 0.

Bytes

1. http://www.2cto.com/kf/201110/106716.html2.http://www.2cto.com/ OS /201110/106719.html
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.