学习 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
评论