fdisk的命令

bfdisk的命令

参考http://www.linuxsir.org/main/?q=node/81

[@more@] #查看fdisk的命令
[root@cnscn ~]# fdisk /dev/sdb
Command (m for help): m
Command action
a 设置成可引导分区 toggle a bootable flag
b 编辑BSD分区的磁盘卷标 edit bsd disklabel
c 设置成与DOS兼容的分区 toggle the dos compatibility flag
d 删除分区 delete a partition
l 列出所有支持的分区文件系统类型 list known partition types
m 帮助命令 print this menu
n 建立新的分区 add a new partition
o 建立新的DOS分区 create a new empty DOS partition table
p 列出目前分区的状态 print the partition table
q 不存储分区更改而退出 quit without saving changes
s 建立新的SUN分区 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)


================== [ 分区与格式化开始] ========================
[root@cnscn ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 4863.
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)

#查看/dev/sdb盘内的分区情况
Command (m for help): p

Disk /dev/sdb: 40.0 GB, 40007761408 bytes
255 heads, 63 sectors/track, 4863 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 3590 28836643+ 6 FAT16

#删除现有分区1
Command (m for help): d 1
No partition is defined yet!

#查看删除分区后的分区情况
Command (m for help): p

Disk /dev/sdb: 40.0 GB, 40007761408 bytes
255 heads, 63 sectors/track, 4863 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
[已经没有分区了]


#创建一个新分区
Command (m for help): n
Command action
e extended 扩展分区
p primary partition (1-4) 主分区
#选择主分区
p
#分区号选1(因为此时是我们创建的第一个/dev/sdb的分区即/dev/sdb1)
Partition number (1-4): 1
First cylinder (1-4863, default 1): 开始盘柱为1,直接回车采用默认
Using default value 1

#最后一个盘柱或大小,注意这里的 +
Last cylinder or +size or +sizeM or +sizeK (1-4863, default 4863): +10240M

#查看分区情况
Command (m for help): p
Disk /dev/sdb: 40.0 GB, 40007761408 bytes
255 heads, 63 sectors/track, 4863 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 1246 10008463+ 83 Linux

#如上来创建第二个分区,只是要注意参数的变化
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p #创建第2个分区
Partition number (1-4): 2
#开始盘柱,采用默认
First cylinder (1247-4863, default 1247):
Using default value 1247

#结束盘柱,采用默认
Last cylinder or +size or +sizeM or +sizeK (1247-4863, default 4863):
Using default value 4863


#查看最后的分区情况
Command (m for help): p

Disk /dev/sdb: 40.0 GB, 40007761408 bytes
255 heads, 63 sectors/track, 4863 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 1246 10008463+ 83 Linux
/dev/sdb2 1247 4863 29053552+ 83 Linux

#修改第2个分区的文件系统类型为FAT32

#执行修改文件系统类型命令t
Command (m for help): t

#选择要修改文件系统类型的分区号2
Partition number (1-4): 2

#选择FAT32分区的类型号bHex code (type L to list codes): b
Changed system type of partition 2 to b (W95 FAT32)

#查看修改后的分区结果
Command (m for help): p

Disk /dev/sdb: 40.0 GB, 40007761408 bytes
255 heads, 63 sectors/track, 4863 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 1246 10008463+ 83 Linux
/dev/sdb2 1247 4863 29053552+ b W95 FAT32

#保存修改后的分区表,并退出
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.


#格式化/dev/sdb1分区为ext3类型
[root@cnscn ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.38 (30-Jun-2005)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1251712 inodes, 2502115 blocks
125105 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2562719744
77 block groups
32768 blocks per group, 32768 fragments per group
16256 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.


#格式化/dev/sdb2分区为FAT32类型
[root@cnscn ~] # mkfs.vfat /dev/sdb2
mkfs.vfat 2.11 (12 Mar 2005)

#查看系统分区列表
[root@cnscn ~]# fdisk -l

...
Disk /dev/sdb: 40.0 GB, 40007761408 bytes
255 heads, 63 sectors/track, 4863 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 1246 10008463+ 83 Linux
/dev/sdb2 1247 4863 29053552+ b W95 FAT32


================== [ 分区与格式化完毕] ========================


================== [ 测试分区开始] ==========================
[root@cnscn ~]# mount -t auto -o rw /dev/sdb1 /media/usb/

[root@cnscn ~]# cd /media/usb/

[root@cnscn usb]# ls
cllost+found

[root@cnscn usb]# touch a.txt

[root@cnscn usb]# ls
a.txt lost+found

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/161840/viewspace-944393/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/161840/viewspace-944393/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值