Nov 27

Linux 挂载新硬盘的方法 不指定

harrie , 12:02 , 生活笔记 , 评论(0) , 引用(0) , 阅读(433) , Via 本站原创 | |
连接好新硬盘后输入fdisk -l命令看当前磁盘信息
Disk /dev/sda: 146.8 GB, 146815733760 bytes
255 heads, 63 sectors/track, 17849 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0xcf3ecf3e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          13      104391   83  Linux
/dev/sda2              14         274     2096482+  82  Linux swap / Solaris
/dev/sda3             275       17849   141171187+  83  Linux

Disk /dev/sdb: 146.8 GB, 146815733760 bytes
255 heads, 63 sectors/track, 17849 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0009c046

可以看到除了当前的第一块硬盘sda之外还有一块sdb的第二块硬盘,然后用fdisk /dev/sdb 进行分区
输入m 可以得到帮助信息。
Command action
    a   toggle a bootable flag
    b   edit bsd disklabel
    c   toggle the dos compatibility flag
    d   delete a partition
    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)


这里我输入了n 添加一个新的分区
Command action
    e   extended
    p   primary partition (1-4)


输入了1
Partition number (1-4): 1
到这里输入该主分区为第几个主分区,由于是新盘我们输入1来分第一个主分区
First cylinder (1-17849, default 1):
First Cylinder是选择该分区的起始磁盘数,这里可自定义也可不做选择,默认是1,如无特殊需求强烈建议选择默认,也就是1来分区(直接按回车)
Last cylinder or +size or +sizeM or +sizeK (1-17849, default 17849):
接下来是定义该分区的大小,如果按默认(按回车)即是使用全部可用存储额,也可以是用M或m单位结尾的数字(大写M是大B的意思,如果输入1M实际上是X8也就是8m的空间),这里我们先分一个1G的空间,所以输入+1024m
或者输入空
提示
Using default value 17849
之后输入w写入分区,等待结束皆可


之后会自动返回到Shell
再输入fdisk -l 可以看到我们刚才分的一个分区,之后用mkfs -t ext3 -c /dev/sdb1进行格式化,如有多个分区可把sdb1改成sdb2 sdb3...以此类推,具体可用fdisk -l看到每个分区的名字
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1          13      104391   83  Linux
/dev/sda2              14         274     2096482+  82  Linux swap / Solaris
/dev/sda3             275       17849   141171187+  83  Linux

Disk /dev/sdb: 146.8 GB, 146815733760 bytes
255 heads, 63 sectors/track, 17849 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0009c046

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       17849   143372061   83  Linux

Writing superblocks and filesystem accounting information: done
上图蓝色部分是写硬盘卷标的,如不想要卷标可直接按回车,现在分区好了我们用mount 挂载一下该分区即可使用了,这里我把它挂载到mnt目录下,也可以自建一个目录挂载
mount /dev/sdb1 /backup/
如果想每次系统重启都能自动挂载该分区可修改/etc/fstab文件,在最后加一段 /dev/sdb1    /www    ext3    defaults 1 2 (格式说明:/dev/sdb1 代表哪个分区  ext3是该分区的格式 defaults 是挂载时所要设定的参数(只读,读写,启用quota等),输入defaults包括的参数有(rw、dev、exec、auto、nouser、 async) ,1是使用dump是否要记录,0是不要。 2是开机时检查的顺序,是boot系统文件就为1,其他文件系统都为2,如不要检查就为0)
这里我用
/dev/sdb1        /backup ext3    defaults                0 2



参考文章:http://blog.csdn.net/zhouy... 这篇文章写的比我的详细清楚,我只是记录下来自己的方法。


Tags: ,
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]