服务器新硬盘分区、格式化、挂载、开机自动挂载

有时服务器需要添加新的硬盘,添加之后要经过分区、格式化、挂载才能使用,还要做开机自动挂载!

1.分区一般使用fdisk命令,参数-l:

#fdisk -l


Disk /dev/sda: 600.1 GB, 600127266816 bytes
255 heads, 63 sectors/track, 72961 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: 0x000862c9

Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 3851 30720000 83 Linux
/dev/sda3 3851 4373 4194304 82 Linux swap / Solaris

Disk /dev/sdd: 600.1 GB, 600127266816 bytes
255 heads, 63 sectors/track, 72961 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


Disk /dev/sdb: 600.1 GB, 600127266816 bytes
255 heads, 63 sectors/track, 72961 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: 0x000862c9

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sdb2 26 3851 30720000 83 Linux
/dev/sdb3 3851 4373 4194304 82 Linux swap / Solaris

你可以看到有几块盘,大小,分区情况!

   找到你新加的硬盘,进行分区,命令还是fdisk:  

   以/dev/sdc为例;

#fdisk /dev/sdc


WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help):

 

按下m,看下有哪些参数

按下p,打印已经分区好的信息

按下n,新建分区,然后选择开始分区的地方、结束分区的地方;再次按下p,看下分区信息,按下w,保存;按下q,退出!!!

记住:分好区可以按下w保存,如果分区错了,不要按下w,直接按下q,离开并且不会保存你刚刚进行的分区操作!

 

2.格式化分区

# mkfs.ext4  /dev/sdc1

等着就行,一般不会报错

 

3.挂载

先创建挂载点/目录

mkdir  /xmon/

 

直接挂载

mount  /dev/sdc1  /xmon

4.开机自动挂载  实现方式很多

     (1)#vim  /etc/fstab

     增加一行    /dev/sdc1      /xmon      ext4  defaults   0    0

     (2)写入/etc/rc/loacl文件

      /dev/sdc1      /xmon      ext4  defaults   0    0

等等,也可以写入其他开机会读取的配置文件或者是系统的环境变量!

 

转载于:https://www.cnblogs.com/yanfeng-hb/p/6872874.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值