提示2分:
*要添加新硬盘,必须重新启动服务器fdisk -l
*使用根帐户执行以下操作
就像这样。 视图-分区-格式-装载-重新启动-自动装载
1、添加硬盘后,重新启动服务器查看
[root@test199 ~]#fdisk -l
磁盘/dev/sdb : 214.7 GB,214748364800 bytes
255 heads,63 sectors/track,26108 cylinders
units=cylinders of 16065 * 512=8225280 bytes
sector size (逻辑/物理) : 512字节/512字节
I/osize (最小/最佳) : 512字节/512字节
磁盘标识符:0x 00000000
磁盘/dev/sdb doesn ' tcontainavalidpartitiontable
磁盘/dev/sda : 85.9 GB,85899345920 bytes
255 heads,63 sectors/track,10443 cylinders
units=cylinders of 16065 * 512=8225280 bytes
sector size (逻辑/物理) : 512字节/512字节
I/osize (最小/最佳) : 512字节/512字节
磁盘标识符:0x 000 CD 039
dvicebootstartendblocksidsystem
/dev/sda1 * 1 26 204800 83 Linux
分区1 doesnotendoncylinderboundary。
/dev/sda 226536409600082 Linux swap/Solaris
分区2 doesnotendoncylinderboundary。
/dev/sda 3536104447958425683 Linux
2、分区
fdisk可以在m命令中看到fdisk命令的内部命令;
答:命令指定启动分区;
d :命令删除存在的分区;
l :用于显示分区ID号列表的命令;
查看fdisk命令的帮助;
n :命令创建新分区;
p :用于显示分区列表的命令;
t :命令更改分区的类型ID号;
w :指令是让分区表的修改内存发挥作用。
[root@test199 ~]# fdisk /dev/sdb
devicecontainsneitheravaliddospartitiontable,nor Sun,SGI or OSF磁盘标签
buildinganewdosdisklabelwithdiskidentifier0x 515 AE 162。
更改will remain in memory only,until you decide to write them。
After that,of course,thepreviouscontentwon ' tbe recoverable。
警告: invalid flag0x 0000 ofpartitiontable4willbecorrectedbyw (rite ) )。
warning : dos-compatiblemodeisdeprecated.it ' sstronglyrecommendedto
switchoffthemode(command'c ' ) and change显示单元到
安全(命令' u )。
命令(mfo rhelp ) : n
命令动作
输入e extended//将创建扩展分区
主分区(1-4) /输入p创建逻辑分区
p
分区编号(1-4) : 1 //如果在此输入l,则进入划分逻辑分区的阶段
firstcylinder(1-26108,默认值1 ) : //注:这是分区的开始值; 你最好在这里直接按回车。 输入非默认数字会浪费空间;
using默认值1
Last cylin
der, +cylinders or +size{K,M,G} (1-26108, default 26108): 我这直接回车了全部用上。注:这个是定义分区大小的,+200M 就是大小为200M ;当然您也可以根据p提示的单位cylinder的大小来算,然后来指定 End的数值。回头看看是怎么算的;还是用+200M这个办法来添加,这样能直观一点。如果您想添加一个10G左右大小的分区,请输入 +10000M ;Using default value 26108
Command (m for help): w //最后输入w回车保存。
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
保存后查看一下
[root@test199 ~]# fdisk -l
Disk /dev/sdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x515ae162
Device Boot Start End Blocks Id System
/dev/sdb1 1 26108 209712478+ 83 Linux
Disk /dev/sda: 85.9 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000cd039
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 536 4096000 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 536 10444 79584256 83 Linux
3、格式化
[root@test199 ~]#mkfs.ext3 /dev/sdb1 //注:将/dev/sdb1格式化为ext3类型,确认好,我上面/dev/sdb1是新加的200GB硬盘,这一步直接回车就可以了,格式化完会自动跳出来
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
13107200 inodes, 52428119 blocks
2621405 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1600 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
4、挂载
--先创建个目录、再挂载到目录上
[root@test199 ~]# mkdir /data
[root@test199 ~]# mount /dev/sdb1 /data
[root@test199 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 75G 21G 51G 29% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/sda1 194M 25M 160M 14% /boot
/dev/sdb1 197G 188M 187G 1% /data
5、重启开机自动挂载,要写到fstab里面(就是最后一行了),否则重启后找不到那个新家的硬盘了
[root@test199 ~]#vi /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Apr 16 01:33:57 2013
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=f87d8e1f-9a62-4cb8-93a8-a4793465eb23 / ext4 defaults 1 1
UUID=cdb27acf-3bbb-4f03-b20c-cfbc9d8450b9 /boot ext4 defaults 1 2
UUID=63399012-86b0-43e7-8cee-a0ace153dd7e swap swap defaults 0 0
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
/dev/sdb1 /data ext3 defaults 0 0
至此OK!