文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>fdisk应用实例

fdisk应用实例

时间:2006-11-15  来源:cnscn2008

[Author]   cnscn 

[描述]
            移动硬盘40GB (255 heads, 63 sectors/track, 4863 cylinders),在Linux中的标识为/dev/sdb

[操作]
            把盘分成 10G的ext3格式的Linux分区和30G的Fat32格式的Windows分区

#查看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分区的类型号b
Hex 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

==================  [测试分区完毕]  ==========================
相关阅读 更多 +
排行榜 更多 +
漫云天气

漫云天气

生活实用 下载
奇点阅读源2025

奇点阅读源2025

系统软件 下载
千城聚合库

千城聚合库

系统软件 下载