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

本文介绍了如何在Linux系统中添加新的硬盘,并将其挂载到指定目录,确保开机自动挂载。通过fdisk查看磁盘信息,然后进行挂载操作,并编辑/etc/fstab文件来实现开机自动挂载。详细步骤包括识别新硬盘,创建挂载点,以及设置挂载参数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >



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


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里面


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值