fdisk的命令

move8net發表於2007-08-11

bfdisk的命令

參考

[@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分割槽的型別號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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/161840/viewspace-944393/,如需轉載,請註明出處,否則將追究法律責任。

相關文章