通过修改配置文件实现开机自动挂载
=====================================================================
[root@lxglinux ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Jan 3 09:21:36 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=baebbff6-5cfd-4865-a9c2-11a07a8b9769 / ext4 defaults 1 1
UUID=471ba3e4-87fe-4bbc-8c34-7886756779ab /boot ext4 defaults 1 2
UUID=302c21dc-3d71-4a66-b022-9726de1f8b9d swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
[root@lxglinux ~]# ls /etc/rc.local
/etc/rc.local
[root@lxglinux ~]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
======================================================================
======================================================================
第一种方法,修改/etc/fstab配置文件
[root@lxglinux dev]# vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sun Jan 3 09:21:36 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=baebbff6-5cfd-4865-a9c2-11a07a8b9769 / ext4 defaults 1 1
UUID=471ba3e4-87fe-4bbc-8c34-7886756779ab /boot ext4 defaults 1 2
UUID=302c21dc-3d71-4a66-b022-9726de1f8b9d swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/sda5 /mnt ext4 defaults 0 0此行为添加修改内容
1.最后两列为两个0,倒数第二个0代表是否备份,ext2,ext3,ext4有日志功能,在非法断电时磁盘数据没有保存完整,如果有日志的话重启时可以恢复数据。1备份。0不备份。
倒数第一个0,代表开机不检测磁盘。根写1,其他写2开机检测磁盘
2.defaults 挂载选项
========================================================================
第二种方法
[root@lxglinux dev]# vim /etc/rc.local 修改配置文件
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
mount /dev/sda1 /home/lxg/123 将此行写入,开机自动挂载
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"/etc/rc.local" 8L, 250C
====================================================================================
[root@lxglinux dev]# mount -o noatime,rw,usrquota /dev/sda1 /home/lxg/123 注意前面mount的选项,可以添加多个选项修改参数。
[root@lxglinux dev]# mount 查看挂载信息,查看挂在了哪些参数
/dev/sdb3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sdb1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sda5 on /mnt type ext4 (rw)
/dev/sda1 on /home/lxg/123 type ext4 (rw,noatime,usrquota)
============================================================================
[root@lxglinux dev]# mount -a自动加载在配置文件中的配置
[root@lxglinux dev]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sdb3 18G 2.5G 15G 15% /
tmpfs 504M 0 504M 0% /dev/shm
/dev/sdb1 97M 26M 67M 29% /boot
/dev/sda5 2.0G 68M 1.9G 4% /mnt
/dev/sda1 2.0G 74M 1.9G 4% /home/lxg/123