linux挂载新硬盘 fdisk / parted 不指定

jed , 2011-9-8 11:34 , 服务器技术 , 评论(0) , 阅读(3241) , Via 本站原创 | |
linux挂载新硬盘 fdisk / parted
Linux的硬盘识别:
一般使用”fdisk -l”命令可以列出系统中当前连接的硬盘
设备和分区信息.新硬盘没有分区信息,则只显示硬盘大小信息.
1.关闭服务器加上新硬盘
2.启动服务器,以root用户登录
3.查看硬盘信息
#fdisk -l
Disk /dev/sda: 146.1 GB, 146163105792 bytes
255 heads, 63 sectors/track, 17769 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot       Start          End       Blocks    Id   System
/dev/sda1    *            1           13       104391    83   Linux
/dev/sda2               14         5112     40957717+   83   Linux
/dev/sda3             5113         5243      1052257+   82   Linux swap /

Solaris
/dev/sda4             5244        17769    100615095     5   Extended
/dev/sda5             5244        17769    100615063+   83   Linux

Disk /dev/sdb: 291.3 GB, 291331192320 bytes
255 heads, 63 sectors/track, 17769 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb1: 291.3 GB, 291331192320 bytes
4.创建新硬盘分区
fdisk可以用m命令来看fdisk命令的内部命令;
a:命令指定启动分区;
d:命令删除一个存在的分区;
l:命令显示分区ID号的列表;
m:查看fdisk命令帮助;
n:命令创建一个新分区;
p:命令显示分区列表;
t:命令修改分区的类型ID号;
w:命令是将对分区表的修改存盘让它发生作用。
进入磁盘,对磁盘进行分区
#fdisk /dev/sdb
Command (m for help):n
Command action
     e    extended    //输入e为创建扩展分区
     p    primary partition (1-4)
p
Partion number(1-4):1
注:在这里输入l,就进入划分逻辑分区阶段了;
First cylinder (51-125, default 51):   注:这个就是分区的Start 值;这里最好直接按回车,如果您输入了一个非默认的数字,会造成空间浪费;
Using default value 51
Last cylinder or +size or +sizeM or +sizeK (51-125, default 125): +200M 注:这个是定义分区大小的,+200M 就是大小为200M ;当然您也可以根据p提示的单位cylinder的大小来算,然后来指定 End的数值。回头看看是怎么算的;还是用+200M这个办法来添加,这样能直观一点。如果您想添加一个10G左右大小的分区,请输入 +10000M ;

Command (m for help): w
最后输入w回车保存。
查看一下:
fdisk -l
可以看到/dev/sdb1分区
5.格式化分区:
mkfs.ext3 /dev/sdb1
注:将/dev/sdb1格式化为ext3类型
      Writing inode tables: done
      Creating journal (4096 blocks): done
      Writing superblocks and filesystem accounting information: 注:在这里直接回车;
      done
      This filesystem will be automatically checked every 26 mounts or
      180 days, whichever comes first. Use tune2fs -c or -i to override.
      这样就格式化好了,我们就可以用mount 加载这个分区,然后使用这个文件系统;
6.创建/data1目录:
mkdir /data1
7.挂载分区:
mount /dev/sdb1 /data1
8.配置开机自动挂载
因为mount挂载在重启服务器后会失效,所以需要将分区信息写到/etc/fstab文件中让它永久挂载:
/etc/fstab
加入:
/dev/sdb1(磁盘分区)            /mnt/dat(挂载目录)    ext3(文件格式)     defaults         0  0

9.重启系统

#################################
当超过2T的硬盘不可以用fdisk来进行分区,必须得用parted.
[root@csc-document dev]# parted /dev/sdb
GNU Parted 1.8.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mkpart
Partition type?  primary/logical? primary    #创建主分区        
                      
File system type?  [ext2]? ext3                                    
Start? 1050G
End? 2247G                                                                
(parted) q                                                                
Information: Don't forget to update /etc/fstab, if necessary.            
(parted) print
Model: DELL PERC 6/i (scsi)
Disk /dev/sdb: 2247GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number  Start   End     Size    File system  Name  Flags
1      17.4kB  1049GB  1049GB  ext3                    
2      1050GB  2247GB  1197GB  ext3         ora
接着对其进行格式化:
[root@csc-document dev]# mkfs -t ext3 /dev/sdb2
创建目录:
[root@csc-document /]# mkdir ora
挂载到ora目录下:
[root@csc-document /]# mount -t ext3 /dev/sdb2 /ora
[root@csc-document /]# vi /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/opt1             /opt                    ext3    defaults        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-sda3         swap                    swap    defaults        0 0
/dev/sdb2               /ora                    ext3    defaults        0 0
  
  
<<<<<<关于创建扩展分区并滑划分逻辑卷部分
(parted) print                                                            
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number  Start   End     Size    Type     File system  Flags
1      32.3kB  10.0GB  10.0GB  primary  ext3              
3      15.0GB  20.0GB  4985MB  primary  ext3              
(parted) mkpart                                                          
Partition type?  primary/extended? extended                              
Start? 20G                                                                
End? 30G                                                                  
(parted) print                                                            
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number  Start   End     Size    Type      File system  Flags
1      32.3kB  10.0GB  10.0GB  primary   ext3              
3      15.0GB  20.0GB  4985MB  primary   ext3              
2      20.0GB  30.0GB  9994MB  extended               lba  
(parted) mkpart                                                          
Partition type?  primary/logical? logical                                
File system type?  [ext2]? ext3                                          
Start? 20G                                                                
End? 25G                                                                  
(parted) print                                                            
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 32.2GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number  Start   End     Size    Type      File system  Flags
1      32.3kB  10.0GB  10.0GB  primary   ext3              
3      15.0GB  20.0GB  4985MB  primary   ext3              
2      20.0GB  30.0GB  9994MB  extended               lba  
5      20.0GB  25.0GB  4993MB  logical   ext3              

OK!至此完成!
Tags: , ,
发表评论

昵称

网址

电邮

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