|
|||
|
The fdisk command is a useful Linux tool for listing and changing disk partitions. Keep in mind that modifying or deleting partitions can cause valuable data to be removed, so be sure of your changes before writing them to disk. To use the fdisk command to list information about the partitions on your hard disk, type the following command as root user:
# fdisk –l: List disk partitions for every disk Disk /dev/sda: 82.3 GB, 82348277760 bytes 255 heads, 63 sectors/track, 10011 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Code:
Device Boot Start End Blocks Id System /dev/sda1 * 1 13 104391 83 Linux /dev/sda2 14 9881 79264710 83 Linux /dev/sda3 9882 10011 1044225 82 Linux swap NOTE: In Fedora 7 and later, both IDE and SCSI disks use device names /dev/sd?, where the ? is replaced by a letter (a, b, or c, and so on). In RHEL5 and earlier versions of Fedora, only SCSI disks and USB flash drives used the /dev/sd? names. IDE hard drives used /dev/hd? instead. If multiple disks are present, fdisk -l will list them all unless you indicate the specific disk you want: # fdisk -l /dev/sdb: List disk partitions for a specific disk To work with a specific disk with the fdisk command, simply indicate the disk you want with no other options: # fdisk /dev/sda: Start interactive fdisk session with disk 1 Command (m for help): m: Type m to list help text as shown Command action a: toggle a bootable flag b: edit bsd disklabel c: toggle the dos compatibility flag d: delete a partition l: list known partition types m: print this menu n: add a new partition o: create a new empty DOS partition table p: print the partition table q: quit without saving changes s: 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) Command (m for help): With the prompt displayed, you can use any of the commands shown to work with your hard disk. In particular, you can use p (to print the same listing as fdisk -l), n (to create a new partition), d (to delete an existing partition), l (to list known file system types), or t (to change the file system type for a partition). The following examples show some of those fdisk commands in action: Command (m for help): d: Ask to delete a partition Partition number (1-4): 4: Type partition number to delete Command (m for help): n: Create a new disk partition First cylinder (1-4983, default 1): 1: Select start (or Enter) Last cylinder ... (default 4983): 4983: Select end (or Enter) Command (m for help): a: Make a partition bootable Partition number (1-3): 1: Type bootable partition number Command (m for help): t: Select a file system type Partition number (1-3): 3: Select partition to change Hex code (type L to list codes): 82: Assign partition as swap Unless you tell it otherwise, fdisk assumes the new partition is a Linux ext3 partition (83). You could have typed L to see the same listing of file system types and hex codes produced from the l command. As noted above, 82 can assign the partition as swap. Other Linux partitions that may interest you include Linux extended (85), Linux LVM (8e), Linux software raid (fd), and EFI/GTP (ee). For Windows partitions, you can assign a partition as HPFS/NTFS (7), Windows 95 FAT32 (b), FAT 16 (6), or Windows 95 FAT32 LBA (c). Other Unix-type file systems include Minix (be or bf), BSD/OS (e4), FreeBSD (ee), OpenBSD (ef), NeXTSTEP (f0), Darwin UFS (f1), and NetBSD (f4). Any of these file system types might be useful if you have old backup media from those file systems that you want to restore. So far, you have not made any permanent changes to your partition table. If you are now very sure that your new settings are correct, type w to write those changes to the partition table. To abandon your changes (or quit after writing your changes), type q to quit your fdisk session. Last edited by prashant; 08-21-2008 at 01:55 AM. |