-->
Previous | Table of Contents | Next |
Its a good idea to unmount a file system before checking it. This ensures that none of the files on the file system are in use when theyre being checked.
NOTE: Remember, you cant unmount a file system if any of the files on it are busy. For example, if a user is now in a directory on a file system that you try to unmount, you get a message saying that the file system is busy.
Trying to check the root file system presents an additional problem. You cant directly unmount the root file system, because Linux must be able to access it in order to run. To check the root file system, you should boot from a maintenance floppy disk that has a root file system on it, and then run fsck on your real root file system from the floppy by specifying the special device name of your root file system. If fsck makes any changes to your file system, its important that you reboot your system immediately. This allows Linux to reread important information about your file system and prevents your file system from further corruption.
CAUTION:
Be sure to reboot your computer immediately after you run fsck if any changes were made to your file system to prevent further corruption to your file system. Use the shutdown -r command or the reboot command to reboot.
When you add a new hard disk to your computer or want to change the partition information on an old hard disk, you go through the steps of creating a file system from a raw disk. Assuming that youve added a new hard disk to your system, you must set the disk partition information and then create the actual file systems on the disk before Linux can use the disk. To change disk partition information, you use the fdisk command. After you partition the hard drive, you need to create the file systems by using the mkfs command.
The fdisk command is used to create disk partitions and set the attributes that tell Linux what type of file system is on a particular partition. If you installed Linux from scratch on an MS-DOS system, you had to run fdisk to change the disk partition information before you could install Linux.
CAUTION:
Using fdisk on a disk can destroy all data on the disk. Because fdisk completely rewrites the file table on the disk, all your former files may be lost. Make sure that you have a complete, current backup of your disks before using fdisk.
You should always run the fdisk command on an unmounted file system. fdisk is an interactive, menu-driven program, not just a single command. To start fdisk, type this command
fdisk [drive]
where drive is the physical disk drive that you want to work on. If you dont specify a disk, the disk /dev/hda is assumed. For example, to run fdisk on the second IDE hard drive in your system, enter
fdisk /dev/hdb
at the superuser command prompt. Because fdisk is a menu-driven program, several different commands are available when youre using fdisk, as summarized in Table 14.8.
Command | Description |
---|---|
a | Toggles the bootable flag on a partition |
c | Toggles the DOS compatibility flag on a partition |
d | Deletes a partition |
l | Lists partition types known to fdisk |
m | Displays a menu listing all available commands |
n | Adds a new partition |
p | Prints the partition table for the current disk |
q | Quits without saving any changes |
t | Changes the file system type for a partition |
u | Changes display/entry units |
v | Verifies the partition table |
w | Writes the table to disk and exits |
x | Lists additional functions for experts: |
b | Moves the beginning location of data in a partition | |
c | Changes the number of cylinders | |
d | Prints the raw data in the partition table | |
e | Lists extended partitions on disk | |
h | Changes number of heads on disk | |
r | Returns to main menu | |
s | Changes number of sectors on disk | |
fdisk can set the file system type of a disk partition to any of several different types. Only use Linux fdisk to create partitions used under Linux. For MS-DOS or OS/2 partitions, you should use the fdisk tool thats native to that operating environment, and then use Linuxs fdisk to tag the partitions as Linux native or Linux swap.
Table 14.9 lists the partitions supported by Linux fdisk. Each partition type has an associated hexadecimal code that identifies it. You must enter the appropriate code in fdisk when you want to set a partition type.
Hex Code | Partition Type |
---|---|
0 | Empty |
1 | DOS 12-bit FAT |
2 | XENIX root |
3 | XENIX usr |
4 | DOS 16-bit file system, less than 32MB |
5 | Extended |
6 | DOS 16-bit file system supporting more than 32MB |
7 | OS/2 High Performance File System (HPFS) |
8 | AIX |
9 | AIX bootable |
a | OS/2 Boot Manager |
40 | Venix 80286 |
51 | Novell? |
52 | Microport |
63 | GNU HURD |
64 | Novell NetWare |
65 | Novell NetWare |
75 | PC/IX |
80 | Old MINIX |
81 | Linux/MINIX |
82 | Linux swap, used for swap files under Linux |
83 | Linux native, common Linux file system type |
93 | Amoeba |
94 | Amoeba BBT |
a5 | BSD/386 |
b7 | BSDI file system |
b8 | BSDI swap file system |
c7 | Syrinx |
db | CP/M |
e1 | DOS access |
e3 | DOS R/O |
f2 | DOS secondary |
ff | BBT |
Previous | Table of Contents | Next |