您的位置:首页 > 运维架构 > Linux

linux下fdisk工具分区使用

2008-02-20 17:15 537 查看
一块新的硬盘拿到手后,怎么进行分区那,除了可以在安装操作系统的时候可以利用操作系统代的软件进行分区以外,可以在windwos下利用磁盘管理工具或者是利用windows自带的管理工具等图形界面分区。在‘我的电脑’上面点击右键选择‘管理’,然后在计算机管理选项中选择‘磁盘管理’选项,然后选择‘本地磁盘管理’然后在图形界面下对磁盘进行操作。当然这些是在有操作系统情况下,并且磁盘的跳线设置正确的情况下进行的(IDE硬盘情况下)。
不过还有一种就是在linux下对磁盘进行分区。利用fdisk工具。以ubuntu系统下,对第二块硬盘进行分区为例介绍一、 fdisk的分区过程。
对第二块硬盘进行分区,命令(需要超级用户权限)~#
fdisk /dev/hd 会看到
The number of cylinders for this disk is set to 155061.
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)
输入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)
下面开始分区

1、输入 n
Command action
e extended 创建扩展分区
p primary partition (1-4) 创建主分区
我们只创建主分区可创建4个主分区
2、选择p
然后是分区的序号,输入 1 即创建第一个主分区
3、First cylinder (1-155061, default 1): 开始柱面号,默认从1当前空闲没有分配的开始
不输入数字只回车是从1开始,输入数字是从输入的合理的数字开始。
4、Last cylinder or +size or +sizeM or +sizeK (1-155061, default 155061): 40000 接束扇区号

扇区的大小 fdisk -l得到的信息
Disk /dev/hdb: 80.0 GB, 80026361856 bytes
16 heads, 63 sectors/track, 155061 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Disk identifier: 0x00000000
5、重复上面的1-4的操作完成4个主分区的分区操作。
6、输入w命令将分区表写入磁盘 Command (m for help): w 完成分区过程

二、格式化磁盘。
一般把磁盘格式化为ext3
1、利用mkfs.ext3 /dev/hdb1命令格式化磁盘,等等系统格式完毕,系统显示
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
2、重复1的操作将其他磁盘格式化完毕。

三、挂载磁盘。
1、创建磁盘挂载点 mkdir /mnt/hdb1 /mnt/hdb2 /mnt/hdb3 /mnt/hdb4
2、挂载磁盘 mount /dev/hdb1 /mnt/hdb
3、重复上面2操作,将磁盘都挂载到相应的挂载点上。
至此,新的磁盘可以工作了。

利用命令查看磁盘空间
df -lh
文件系统 容量 已用 可用 已用% 挂载点
/dev/hdb1 19G 173M 18G 1% /mnt/hdb1
/dev/hdb2 19G 173M 18G 1% /mnt/hdb2
/dev/hdb3 19G 173M 18G 1% /mnt/hdb3
/dev/hdb4 17G 173M 16G 2% /mnt/hdb4
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: