码迷,mamicode.com
首页 > 其他好文 > 详细

mount 挂载1T硬盘

时间:2015-11-23 15:01:31      阅读:264      评论:0      收藏:0      [点我收藏+]

标签:mount

参考链接:http://blog.chinaunix.net/uid-25829053-id-3067619.html

http://blog.itpub.net/23718752/viewspace-1146471/

192.168.20.249挂载1T硬盘

 1 fdisk -l #查看要挂载的硬盘容量

  显示如下:

  Disk /dev/sdb: 999.7 GB

   

 2 fdisk /dev/sdb   #创建分区

   m 打印帮助菜单

   p 显示分区/打印分区

   d 删除分区

   n 新建分区

   

  3 格式化

    mkfs -t ext4 /dev/sdb1 

    

    

具体操作如下:

root@ubu020249:/opt/backup# fdisk -l


Disk /dev/sda: 599.6 GB, 599550590976 bytes

255 heads, 63 sectors/track, 72891 cylinders, total 1170997248 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0x0006ca04


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048  1137901567   568949760   83  Linux

/dev/sda2      1137903614  1170995199    16545793    5  Extended

/dev/sda5      1137903616  1170995199    16545792   82  Linux swap / Solaris


Disk /dev/sdb: 999.7 GB, 999653638144 bytes

2 heads, 1 sectors/track, 976224256 cylinders, total 1952448512 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0x27638d58


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048  1048578047   524288000   83  Linux

/dev/sdb2      1952448511  1952448511           0+  83  Linux    #这里的0+表示该分区容量为0,分区划分的有问题


root@ubu020249:/opt/backup# fdisk /dev/sdb   #重新划分分区


Command (m for help): p  #打印分区


Disk /dev/sdb: 999.7 GB, 999653638144 bytes

2 heads, 1 sectors/track, 976224256 cylinders, total 1952448512 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0x27638d58


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048  1048578047   524288000   83  Linux

/dev/sdb2      1952448511  1952448511           0+  83  Linux


Command (m for help): d  #删除分区,

Partition number (1-4): 1   #选择删除哪个分区


Command (m for help): p


Disk /dev/sdb: 999.7 GB, 999653638144 bytes

2 heads, 1 sectors/track, 976224256 cylinders, total 1952448512 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0x27638d58


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb2      1952448511  1952448511           0+  83  Linux


Command (m for help): d  #默认删除第二个分区

Selected partition 2


Command (m for help): p  #打印分区表


Disk /dev/sdb: 999.7 GB, 999653638144 bytes

2 heads, 1 sectors/track, 976224256 cylinders, total 1952448512 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0x27638d58


   Device Boot      Start         End      Blocks   Id  System

   

Command (m for help): n    #新建分区

Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

Select (default p): p   #划分主分区

Partition number (1-4, default 1): 1   #选择1 

First sector (2048-1952448511, default 2048):    #此处默认回车即可

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-1952448511, default 1952448511): +600G

 

Command (m for help): n  #新建分区

Partition type:

   p   primary (1 primary, 0 extended, 3 free)

   e   extended

Select (default p): p  #划分主分区

Partition number (1-4, default 2): 2  #选择2 

First sector (1258293248-1952448511, default 1258293248):   此处默认回车

Using default value 1258293248

Last sector, +sectors or +size{K,M,G} (1258293248-1952448511, default 1952448511): +390G

Value out of range.       #报超出范围

Last sector, +sectors or +size{K,M,G} (1258293248-1952448511, default 1952448511): +330G  #不报错


Command (m for help): p   #打印分区


Disk /dev/sdb: 999.7 GB, 999653638144 bytes

2 heads, 1 sectors/track, 976224256 cylinders, total 1952448512 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0x27638d58


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048  1258293247   629145600   83  Linux

/dev/sdb2      1258293248  1950353407   346030080   83  Linux


Command (m for help): d     #删除第二个分区

Partition number (1-4): 2


Command (m for help): p


Disk /dev/sdb: 999.7 GB, 999653638144 bytes

2 heads, 1 sectors/track, 976224256 cylinders, total 1952448512 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0x27638d58


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048  1258293247   629145600   83  Linux


Command (m for help): n    #新建分区

Partition type:

   p   primary (1 primary, 0 extended, 3 free)

   e   extended

Select (default p): p   #创建主分区 

Partition number (1-4, default 2): 2 

First sector (1258293248-1952448511, default 1258293248):   默认回车

Using default value 1258293248

Last sector, +sectors or +size{K,M,G} (1258293248-1952448511, default 1952448511): 1258293248   #选择了起始值


Command (m for help): p  #打印分区


Disk /dev/sdb: 999.7 GB, 999653638144 bytes

2 heads, 1 sectors/track, 976224256 cylinders, total 1952448512 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0x27638d58


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048  1258293247   629145600   83  Linux

/dev/sdb2      1258293248  1258293248           0+  83  Linux      #显示该分区容量为0


Command (m for help): d   #删除第二个分区

Partition number (1-4): 2


Command (m for help): p  #打印分区表


Disk /dev/sdb: 999.7 GB, 999653638144 bytes

2 heads, 1 sectors/track, 976224256 cylinders, total 1952448512 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0x27638d58


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048  1258293247   629145600   83  Linux


Command (m for help): n   #新建分枢

Partition type:

   p   primary (1 primary, 0 extended, 3 free)

   e   extended

Select (default p): p  #主分区

Partition number (1-4, default 2): 2

First sector (1258293248-1952448511, default 1258293248):  #此处默认回车 

Using default value 1258293248

Last sector, +sectors or +size{K,M,G} (1258293248-1952448511, default 1952448511): 1952448511  #输入末位的这个值


Command (m for help): p  #打印分区


Disk /dev/sdb: 999.7 GB, 999653638144 bytes

2 heads, 1 sectors/track, 976224256 cylinders, total 1952448512 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0x27638d58


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048  1258293247   629145600   83  Linux

/dev/sdb2      1258293248  1952448511   347077632   83  Linux


Command (m for help): w   #保存

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.


格式化分区

mkfs -t ext4 /dev/sdb1

mkfs -t ext4 /dev/sdb2


挂载

mount /dev/sdb1 /opt/backup/online/

mount /dev/sdb2 /opt/backup/offline/


root@ubu020:/opt/backup# df -Th   #查看硬盘容量

Filesystem     Type      Size  Used Avail Use% Mounted on

/dev/sda1      ext4      534G  1.5G  506G   1% /

none           tmpfs     4.0K     0  4.0K   0% /sys/fs/cgroup

udev           devtmpfs  7.8G  4.0K  7.8G   1% /dev

tmpfs          tmpfs     1.6G  1.1M  1.6G   1% /run

none           tmpfs     5.0M     0  5.0M   0% /run/lock

none           tmpfs     7.8G  4.0K  7.8G   1% /run/shm

none           tmpfs     100M     0  100M   0% /run/user

/dev/sdb1      ext4      591G   70M  561G   1% /opt/backup/online    #999.7 GB的盘,挂上来之后只有870G

/dev/sdb2      ext4      326G   67M  310G   1% /opt/backup/offline


卸载

umount /opt/backup/online 

umount /opt/backup/offline 

 

root@ubu020249:/opt/backup# df -Th   #查看硬盘容量   已成功卸载

Filesystem     Type      Size  Used Avail Use% Mounted on

/dev/sda1      ext4      534G  1.5G  506G   1% /

none           tmpfs     4.0K     0  4.0K   0% /sys/fs/cgroup

udev           devtmpfs  7.8G  4.0K  7.8G   1% /dev

tmpfs          tmpfs     1.6G  1.1M  1.6G   1% /run

none           tmpfs     5.0M     0  5.0M   0% /run/lock

none           tmpfs     7.8G  4.0K  7.8G   1% /run/shm

none           tmpfs     100M     0  100M   0% /run/user


以下是最简便的划分分区方法:即只划分一个分区

root@ubu020249:/opt/backup# fdisk -l  #查看分区情况


Disk /dev/sda: 599.6 GB, 599550590976 bytes

255 heads, 63 sectors/track, 72891 cylinders, total 1170997248 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0x0006ca04


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048  1137901567   568949760   83  Linux

/dev/sda2      1137903614  1170995199    16545793    5  Extended

/dev/sda5      1137903616  1170995199    16545792   82  Linux swap / Solaris


Disk /dev/sdb: 999.7 GB, 999653638144 bytes

2 heads, 1 sectors/track, 976224256 cylinders, total 1952448512 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0x27638d58


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048  1258293247   629145600   83  Linux     #第二盘有两个分区

/dev/sdb2      1258293248  1952448511   347077632   83  Linux

root@ubu020249:/opt/backup# fdisk /dev/sdb      #对第二块盘重新分区

 

Command (m for help): p  #打印分区


Disk /dev/sdb: 999.7 GB, 999653638144 bytes

2 heads, 1 sectors/track, 976224256 cylinders, total 1952448512 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0x27638d58


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048  1258293247   629145600   83  Linux

/dev/sdb2      1258293248  1952448511   347077632   83  Linux


Command (m for help): d   #删除分区

Partition number (1-4): 1  


Command (m for help): d

Selected partition 2


Command (m for help): p


Disk /dev/sdb: 999.7 GB, 999653638144 bytes

2 heads, 1 sectors/track, 976224256 cylinders, total 1952448512 sectors

Units = sectors of 1 * 512 = 512 bytes

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

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

Disk identifier: 0x27638d58


   Device Boot      Start         End      Blocks   Id  System


Command (m for help): n  #新建分区

Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

Select (default p): p  #主分区

Partition number (1-4, default 1): 1

First sector (2048-1952448511, default 2048):    #此处默认回车

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-1952448511, default 1952448511): 1952448511   #写默认最后边的数


Command (m for help): w  #保存

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.


格式化

mkfs -t ext4 /dev/sdb1  


挂载

mount /dev/sdb1 /opt/backup/


查看硬盘容量

root@ubu020249:/opt/backup# df -Th

Filesystem     Type      Size  Used Avail Use% Mounted on

/dev/sda1      ext4      534G  1.5G  506G   1% /

none           tmpfs     4.0K     0  4.0K   0% /sys/fs/cgroup

udev           devtmpfs  7.8G  4.0K  7.8G   1% /dev

tmpfs          tmpfs     1.6G  1.1M  1.6G   1% /run

none           tmpfs     5.0M     0  5.0M   0% /run/lock

none           tmpfs     7.8G  4.0K  7.8G   1% /run/shm

none           tmpfs     100M     0  100M   0% /run/user

/dev/sdb1      ext4      917G   72M  870G   1% /opt/backup    #查看硬盘容量也是870G


配置开机启动项

vi /etc/fstab

/dev/sdb1       /opt/backup     ext4    defaults        1       2 


/dev/sdb1   代表哪个分区

/opt/backup 挂载的位置  

ext4  是该分区的格式 

defaults  是挂载时所要设定的参数(只读,读写,启用quota等),

输入defaults包括的参数有(rw、dev、exec、auto、nouser、async) ,

1 是使用dump是否要记录,0是不要。 

2 是开机时检查的顺序,是boot系统文件就为1,其他文件系统都为2,如不要检查就为0


本文出自 “青春邓勇” 博客,请务必保留此出处http://dengyong.blog.51cto.com/8409869/1715870

mount 挂载1T硬盘

标签:mount

原文地址:http://dengyong.blog.51cto.com/8409869/1715870

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!