在linux下挂载硬盘

来源:互联网 发布:java上传图片回显 编辑:程序博客网 时间:2024/06/05 05:04

http://blog.csdn.net/season_hangzhou/article/details/36423223

http://blog.csdn.net/season_hangzhou/article/details/36423223


一、安装硬盘到物理机上。(略)

二、查看硬盘是否正确安装。

使用“fdisk -l”命令查看硬盘代号。

[plain] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. root@greatms-All-Series:/home/share# fdisk -l  
  2.   
  3. Disk /dev/sda: 500.1 GB, 500107862016 bytes  
  4. 255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors  
  5. Units = 扇区 of 1 * 512 = 512 bytes  
  6. Sector size (logical/physical): 512 bytes / 4096 bytes  
  7. I/O size (minimum/optimal): 4096 bytes / 4096 bytes  
  8. Disk identifier: 0x000aab9b  
  9.   
  10.    设备 启动      起点          终点     块数   Id  系统  
  11. /dev/sda1   *        2048   488282111   244140032   83  Linux  
  12. /dev/sda2       488284158   976771071   244243457    5  扩展  
  13. Partition 2 does not start on physical sector boundary.  
  14. /dev/sda5       488284160   820314111   166014976   83  Linux  
  15. /dev/sda6       820316160   976771071    78227456   82  Linux 交换 / Solaris  
  16.   
  17. WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.  
  18.   
  19.   
  20. Disk /dev/sdb: 3000.6 GB, 3000592982016 bytes  
  21. 255 heads, 63 sectors/track, 364801 cylinders, total 5860533168 sectors  
  22. Units = 扇区 of 1 * 512 = 512 bytes  
  23. Sector size (logical/physical): 512 bytes / 4096 bytes  
  24. I/O size (minimum/optimal): 4096 bytes / 4096 bytes  
  25. Disk identifier: 0x00000000  
  26.   
  27.    设备 启动      起点          终点     块数   Id  系统  
  28. /dev/sdb1               1  4294967295  2147483647+  ee  GPT  
  29. Partition 1 does not start on physical sector boundary.  
可以看到我新增了的硬盘标识为sdb。


三、将硬盘分区。

1、当硬盘小于等于2T时,可以用fdisk。

[plain] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. fdisk /dev/sdb  
  2. 1、查看帮助。  
  3. 输入:m  
  4. 2、新建分区。  
  5. 输入:n  
  6. 3、创建逻辑分区  
  7. 输入:p  
  8. 4、输入分区号以及指定分区大小  
  9. 依照提示,回车表示默认。  
  10. 5、检查分区情况(此时还未执行分区操作)  
  11. Command(m for help):p   
  12. 6、保存退出  
  13. Command(m for help):w  

2、当硬盘大于2T时,用parted命令。

[plain] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. parted /dev/sdb   (用part命令对3T硬盘进行分区处理)  
  2. mklabel gpt       (用gpt格式可以将3TB弄在一个分区里)  
  3. unit TB           (设置单位为TB)  
  4. mkpart primary 0 3 (设置为一个主分区,大小为3TB,开始是0,结束是3)  
  5. print              (显示设置的分区大小)  
  6. quit               (退出parted程序)  

四、格式化分区。

mkfs.ext4 /dev/sdb1


五、将硬盘挂载到文件夹下。

1、手动挂载。

新建一个文件夹:mkdir /home/sdb1

挂载:mount /dev/sdb1 /home/sdb1

2、开机自动挂载。

输入:vi /etc/fstab

在最后加入:

[cpp] view plain copy
 在CODE上查看代码片派生到我的代码片
  1. /dev/sdb1    /home/sdb1    ext4    defaults    1    1  

0 0
原创粉丝点击