linux挂载硬盘

随着固态硬盘的普及,机械硬盘已经不再适合作系统盘了。

linux系统一般会安装在固态银盘上,但是机械键盘仍然有其优势,就是便宜,存储空间大。

 

查看当前的硬盘一览:

fdisk -l

  

找到新追加的硬盘,一般为/dev/sdb,为新硬盘简历分区:

fdisk /dev/sdb

命令(输入 m 获取帮助):m
命令操作
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

命令(输入 m 获取帮助):n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): 
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-3221225471,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-3221225471,默认为 3221225471):
将使用默认值 3221225471
分区 1 已设置为 Linux 类型,大小设为 1.5 TiB

 

fdisk最后要按w以保存分区

命令(输入 m 获取帮助):w
The partition table has been altered!

Calling ioctl() to re-read partition table.
正在同步磁盘。

  

格式化分区:

mkfs.xfs -f /dev/sdb1

  

挂载分区到指定的文件夹

mount /dev/sdb1 /home/data/

  

其它:

开机即挂载硬盘:

修改/etc/fstab文档

/etc/fstab里面每列大概意思为:

第一列为设备号或该设备的卷标,即需要挂载的文件系统或存储设备; 
第二列为挂载点 
第三列为文件系统或分区的类型 
第四列为文件系统参数,即挂载选项,详细参考man mount.命令,defaults就没有问题,除非你有特殊需求; 
第五列为dump选项,设置是否让备份程序dump备份文件系统。0:不备份,1:备份,2:备份(但比1重要性小)。设置了该参数后,linux中使用dump命令备份系统的时候就可以备份相应设置的挂载点了。 
第六列为是否在系统启动的时候,用fsck检验分区,告诉fsck程序以什么顺序检查文件系统。因为有些挂载点是不需要检验的,比如:虚拟内存swap、/proc等。0:不检验,1:要检验,2要检验(但比1晚检验),一般根目录设置为1,其他设置为2就可以了。

 

/dev/sdb1  /home/data xfs  defaults  0  0

  

 

posted @ 2017-06-19 13:52  VoctrALs  阅读(249)  评论(0编辑  收藏  举报