Add the windwos partition to be automatically mounted when the Ubuntu service is started.

Source: Internet
Author: User

Add the windwos partition to be automatically mounted when the Ubuntu service is started.

For Linux service description, reference
========================================================== =
When Linux is started, it runs a program called init and starts subsequent tasks, including multi-user environments and networks.
So what is the runtime level? Simply put, the running level is the function level currently running in the operating system. This level ranges from 1 to 6 and has different functions.

Run-level description of RedHat:
0 indicates that the machine is shut down.
1 is the single-user mode, just like the security mode in Win9x.
2: multi-user mode, but not supported by NFS.
3 is a complete multi-user mode, which is a standard operation level.
4. Generally, you can use it to do things in some special cases.
5 is X11, And it enters the X Window System.
6. Restart the init 6 server.

These levels are in the/etc/inittab (this file is not available in Ubuntu)
File. This file is the main file found by the INIT program. The first service to run is the files stored in the/etc/rc. d directory (Ubuntu does not have this directory.
In most Linux releases, the startup is/etc/rc. d/init. d (Ubuntu is/etc/init. d
). These scripts are connected to/etc/rc. d/rcN. d by ln command (Ubuntu is/etc/rcN. d
) Directory. (Here N is the running level 0-6)
For example, the s10network under/etc/rc. d/rc2.d is connected to the network script under/etc/rc. d/init. d.
Therefore, we can know that the files under rc2.d are related to Operation Level 2.

"S" at the beginning of the file indicates that "start" indicates that the service is started, and "10" indicates the order in which the service is started. For example, in the same directory, you can also see the s80postfix file. The order of 80 is after 10, because if the network is not started, starting Postfix does not work.
Check/etc/rc. d/rc3.d again. You can see the file s60nfslock, but this file does not exist in the/etc/rc. d/rc2.d directory. NFS uses this file, which is generally used in multi-user environments, so it is stored in the rc3.d directory.
In addition, you can see files starting with K in/etc/rc. d/rc2.d, for example
/Etc/rc. d/rc2.d/k45named, K indicates kill.

The standard Linux operating level is 3 or 5. If it is 3, the system is in the multi-user State. If it is 5, the X Window System is running. If it is currently 3 or 5, and you reduce the running level to 2, init will execute the k45named script. (Ubuntu runs at Level 2 and can be viewed at runlevel.
)
Different running levels have different functions and should be set according to different situations. For example, if the root password is lost, you can set the machine startup status to a single user. Enter:
Init =/bin/sh RW
This allows the machine to enter runtime Level 1 and mount the root file system to read/write. He will skip all system authentication, so that you can use the passwd program to change the root password, and then start to a new running level.



========================================================== =

1. Create a directory to be mounted
$ CD/Media
$ Sudo mkdir c d e f D2 E2 F2

Creating a directory corresponds to the original windows partition label, which is easy to remember. The number of created directories varies with the number of partitions.

Ii. Create a mount script:
Create a mount script. Note that the required options, such as utf8, are added when fat/FAT32 is mounted. Otherwise, the Chinese directory and file name may not be displayed.
Automount. Sh

#! /Bin/bash
# File system type related options
Mount-T vfat/dev/sdb7/Media/F2-O nosuid, nodev, uhelper = Hal, shortname = mixed, uid = 1000, utf8, umask = 077, flush
Mount-t ntfs/dev/sda1/Media/c-o nosuid, nodev, noatime, allow_other, blksize = 4096
Mount-t ntfs/dev/sdb6/Media/e2-O nosuid, nodev, noatime, allow_other, blksize = 4096
Mount-t ntfs/dev/sdb5/Media/D2-O nosuid, nodev, noatime, allow_other, blksize = 4096
Mount-T vfat/dev/sda5/Media/d-o nosuid, nodev, uhelper = Hal, shortname = mixed, uid = 1000, utf8, umask = 077, flush
Mount-T vfat/dev/sda7/Media/f-o nosuid, nodev, uhelper = Hal, shortname = mixed, uid = 1000, utf8, umask = 077, flush
Mount-t ntfs/dev/sda6/Media/e-o nosuid, nodev, noatime, allow_other, blksize = 4096

Creates an automatic unmount script, which runs when the instance is restarted or shut down.
Autoumount. Sh

#! /Bin/bash
Umount/Media/F2
Umount/Media/C
Umount/Media/E2
Umount/Media/D2
Umount/Media/d
Umount/Media/F
Umount/Media/E

Set permissions for the two scripts:
$ Chmod 755 autoumount. Sh automount. Sh

3. Add a superuser to the init. d directory of the service.
$ Sudo CP/home/vange/autoumount. Sh automount. sh/etc/init. d/

Iv. Set the running levels for Automatic startup
The Linux Startup service is stored in init. d directory, and create the corresponding link files under Different Run-level directories. Starting with K/S, add the startup sequence number. k indicates that the service is not started, and s indicates that the service is started.
0 6 indicates running upon shutdown and restart
 
Set automatic Mount script run
$ Sudo update-rc.d autoumount. Sh defaults

Adding system startup for/etc/init. d/automount. Sh...
/Etc/rc0.d/k20automount. Sh->.../init. d/automount. Sh
/Etc/rc1.d/k20automount. Sh->.../init. d/automount. Sh
/Etc/rc6.d/k20automount. Sh->.../init. d/automount. Sh
/Etc/rc2.d/s20automount. Sh->.../init. d/automount. Sh
/Etc/rc3.d/s20automount. Sh->.../init. d/automount. Sh
/Etc/rc4.d/s20automount. Sh->.../init. d/automount. Sh
/Etc/rc5.d/s20automount. Sh->.../init. d/automount. Sh
Use the default startup level, that is, 0 1 6 does not run 2 3 4 5

Set automatic unmount script run
$ Sudo update-rc.d autoumount. Sh start 0 6 s. Stop 1 2 3 4 5.

Adding system startup for/etc/init. d/autoumount. Sh...
/Etc/rc2.d/k01autoumount. Sh->.../init. d/autoumount. Sh
/Etc/rc3.d/k01autoumount. Sh->.../init. d/autoumount. Sh
/Etc/rc4.d/k01autoumount. Sh->.../init. d/autoumount. Sh
/Etc/rc5.d/k01autoumount. Sh->.../init. d/autoumount. Sh
/Etc/rc6.d/s00autoumount. Sh->.../init. d/autoumount. Sh
/Etc/RCs. d/s00autoumount. Sh->.../init. d/autoumount. Sh

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.