您的位置:首页 > 运维架构 > Linux

linux添加新硬盘-添加到开机自动挂载

2016-11-29 14:20 495 查看

   有时候系统硬盘不够用,这时候需要添加新的硬盘,创建文件系统,挂载到新的目录。如果不把挂载加到开机启动,机器重启后,新挂载的硬盘里的内容就会访问不到,这时候就需要开机启动的时候自动挂载。

1.fdisk  -l  查看磁盘信息

[root@test1 etc]# fdisk -l

Disk /dev/sda: 12.9 GB, 12884901888 bytes

255 heads, 63 sectors/track, 1566 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0007c1f4

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        1502    12057600   83  Linux

/dev/sda2            1502        1567      524288   82  Linux swap / Solaris

Disk /dev/sdb: 53.7 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x999df6f7

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        6527    52428096   83  Linux

Disk /dev/mapper/vg01-lv01: 53.7 GB, 53682896896 bytes

255 heads, 63 sectors/track, 6526 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

2.挂载磁盘

[root@test1 ~]#

mount /dev/mapper/vg01-lv01   /xebest   把vg01挂载到 /xebest 目录

 

3.添加开机启动



vi /etc/fstab

添加以下代码:
/dev/mapper/vg01-lv01           /xebest      ext4    defaults        0 0

 

- device name,设备名,例如/dev/sdb1

- mount point,挂载点,是一个系统上存在的文件夹,例如/xebest

- fs-type,要挂载设备的类型,例如ext4。用man fstab可以查到支持的类型。

- options,挂载时采用的参数,一般是defaults。

- dump-freq 和 pass-num,一般都设置为0,启动时不检查要挂载的设备。

或者 在/etc/rc.local 添加  mount /dev/mapper/vg01-lv01  /xebest


不过不推荐放在这里,因为系统启动完之后,最后加载这个配置文件,推荐放在 /etc/fstab里面
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息