在
Linux
下硬盘分区、创建文件系统并挂载硬盘
服务器的硬盘阵列再次出现问题,RAID又掉了,重做RAID后,将重新分区、创建文件系统、挂载硬盘的操作过程记录下来:
操作服务器共计5块硬盘,一块做系统盘,其余四块RAID0,现在具体操作如下:
[@91.21 ~]# cd /dev/cciss/
察看其下的设备:
[@91.21 cciss]# ls
c0d0 c0d0p1 c0d0p2 c0d0p3 c0d0p4 c0d0p5 c0d0p6 c0d1
c0d0 c0d0p1 c0d0p2 c0d0p3 c0d0p4 c0d0p5 c0d0p6 c0d1
要对设备c0d1进行分区。
具体步骤:
1
)分区
使用fdisk命令:
[@91.21 cciss]# fdisk /dev/cciss/c0d1
The number of cylinders for this disk is set to 35419.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help):
这里填m可以看到帮助指令
填n,新建一个分区
Command (m for help): n
Command action
e extended
p primary partition (1-4)
Command action
e extended
p primary partition (1-4)
通常这里填P,建主盘而非扩展盘
Command action
e extended
p primary partition (1-4)
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
Partition number (1-4): 1
如果只想分一个区,后面两个都取默认值就好,否则就要指明该区从哪个簇到哪个簇。
First cylinder (1-35419, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-35419, default 35419):
Using default value 35419
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-35419, default 35419):
Using default value 35419
最后,用w命令,将分区信息记录下来
Command (m for help): w
The partition table has been altered!
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
Syncing disks.
现在再看一下,目录下多了一个设备c0d1p1:
[@91.21 cciss]# ls
c0d0 c0d0p1 c0d0p2 c0d0p3 c0d0p4 c0d0p5 c0d0p6 c0d1 c0d1p1
c0d0 c0d0p1 c0d0p2 c0d0p3 c0d0p4 c0d0p5 c0d0p6 c0d1 c0d1p1
2
)创建文件系统(相当于格式化)
使用mkfs命令:
[@91.21 cciss]# mkfs -t ext3 -c /dev/cciss/c0d1p1
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
35569664 inodes, 71125771 blocks
3556288 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=71303168
2171 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
35569664 inodes, 71125771 blocks
3556288 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=71303168
2171 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
Checking for bad blocks (read-only test): 57501888/ 71125771
done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information:
done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
180 days, whichever comes first. Use tune2fs -c or -i to override.
3
)硬盘挂载
最后一步是硬盘挂载,先创建挂载点目录,然后使用mount命令挂载硬盘:
[@91.21 ~]# mount /dev/cciss/c0d1p1 /UserData/
这样硬盘就被挂载上了,如果要每次重启都自动挂载,再编辑/etc/fstab文件:
[@91.21 ~]# vi /etc/fstab
在文件末尾添加这么一行:
/dev/cciss/c0d0p1 /UserData ext3 defaults 1 2