學習 Linux,101: 建設分區和文件系統
清單 8. 修改分區類型
Command (m for help): t
Partition number (1-9): 4
Hex code (type L to list codes): 82
Changed system type of partition 4 to 82 (Linux swap / Solaris)
Command (m for help): t
Partition number (1-9): 9
Hex code (type L to list codes): b
Changed system type of partition 9 to b (W95 FAT32)
Command (m for help):
保管分區表
到當前為止,我們只是對分區表舉行了內存中編輯。我們能夠用 q 命令退出,不保管修改。假設某些分區不能滿足您的要求,您能夠運用 d 命令來刪除一個或多個分區,以便重新定義它們。假設您對配置滿意,則能夠運用 v 命令來驗證您的配置,然后運用 w 命令來寫入新的分區表并退出。參見清單 9。假設您再次運轉 fdisk -l 命令,您將看到,Linux 如今已能夠識別新分區。與其他操作系統不一樣的是,Linux 并不總是須要重新啟動才干看到修改。舉例來說,假設 /dev/hda3 變成 /dev/hda2,則須要重新啟動,由于原來的 /dev/hda2 已被刪除。假設須要重新啟動,fdisk 應該會通知您。
清單 9. 保管分區表
Command (m for help): v
999521580 unallocated 512-byte sectors
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.
root@Microknoppix:~# fdisk -l /dev/sda
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000de20f
Device Boot Start End Blocks Id System
/dev/sda1 * 1 9111 73184076 7 HPFS/NTFS
/dev/sda2 9634 9730 779152+ 83 Linux
/dev/sda3 9731 116679 859067842+ 5 Extended
/dev/sda4 9112 9633 4192965 82 Linux swap / Solaris
/dev/sda5 9731 20917 89859546 83 Linux
/dev/sda6 20918 39644 150424596 83 Linux
/dev/sda7 39645 53905 114551451 83 Linux
/dev/sda8 53906 59128 41953716 83 Linux
/dev/sda9 59129 59384 2056288+ b W95 FAT32
Partition table entries are not in disk order
高級 fdisk
您能夠已留意到,我們沒有修改恣意分區上的 bootable 標志。如今,我們的硬盤尚有 Windows Master Boot Record (MBR),因而將啟動標志為 bootable 的第一個主分區(我們的示例中為 NTFS 分區)。
LILO 和 GRUB 都不運用 bootable 標志。假設其中一個裝置在 MBR 中,那么它就能夠引導 Windows/xp 分區。您也可以夠將 LILO 或 GRUB 裝置到您的 /boot 分區(/dev/hda2)中,將該分區標志為 bootable 并移除 /dev/hda1 的 bootable 標志。假設機器今后將恢復為 Windows 自用機器,那么保管原始 MBR 能夠會有用。
假設須要,您還能夠運用 fdisk 來修正分區表中的分區順序。這通常將會修改分區編號,因而您能夠須要完成其他任務才干將您的系統恢復為任務系統。要舉行這個修改,運用 f 子命令切換到專家方式,然后運用 r 子命令修正分區順序,如清單 10 所示。假設您只是想看看新的分區順序而不實踐修改,能夠運用 q 子命令退出(本例的做法),而不是將更新后的分區表寫到硬盤中。
清單 10. 修正分區表順序
Command (m for help): p
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000de20f
Device Boot Start End Blocks Id System
/dev/sda1 * 1 9111 73184076 7 HPFS/NTFS
/dev/sda2 9634 9730 779152+ 83 Linux
/dev/sda3 9731 116679 859067842+ 5 Extended
/dev/sda4 9112 9633 4192965 82 Linux swap / Solaris
/dev/sda5 9731 20917 89859546 83 Linux
/dev/sda6 20918 39644 150424596 83 Linux
/dev/sda7 39645 53905 114551451 83 Linux
/dev/sda8 53906 59128 41953716 83 Linux
/dev/sda9 59129 59384 2056288+ b W95 FAT32
Partition table entries are not in disk order
Command (m for help): x
Expert command (m for help): f
Done.
Expert command (m for help): r
Command (m for help): p
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x000de20f
Device Boot Start End Blocks Id System
/dev/sda1 * 1 9111 73184076 7 HPFS/NTFS



![[Android開發視頻教學]代碼編寫(五)(33)](http://editerupload.eepw.com.cn/201011/ff2db959a0524a66b92ba263a0e808aa.jpg)



![[Android開發視頻教學]代碼編寫(六)(34)](http://editerupload.eepw.com.cn/201011/0a58f918d1bef1323ddf0a08cca5af0c.jpg)
![[Android開發視頻教學]代碼編寫(四)(32)](http://editerupload.eepw.com.cn/201010/7dc01b86eebb701735c9a4fbe67c6375.jpg)

Linux環境搭建](http://editerupload.eepw.com.cn/201010/f5d70054400b96d1d942b1233ca52078.jpg)



評論