<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> <HTML> <HEAD> <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.7"> <TITLE>Linux Frequently Asked Questions with Answers: Linux's handling of file systems, disks, and drives </TITLE> <LINK HREF="Linux-FAQ-5.html" REL=next> <LINK HREF="Linux-FAQ-3.html" REL=previous> <LINK HREF="Linux-FAQ.html#toc4" REL=contents> </HEAD> <BODY> <A HREF="Linux-FAQ-5.html"><IMG SRC="next.gif" ALT="Next"></A> <A HREF="Linux-FAQ-3.html"><IMG SRC="prev.gif" ALT="Previous"></A> <A HREF="Linux-FAQ.html#toc4"><IMG SRC="toc.gif" ALT="Contents"></A> <HR> <H2><A NAME="Linux's handling of file systems, disks, and drives"></A> <A NAME="s4">4. Linux's handling of file systems, disks, and drives </A></H2> <P>------------------------------------------------------------------------------- <P> <H2><A NAME="How can I get Linux to work with my disk?"></A> <A NAME="ss4.1">4.1 How can I get Linux to work with my disk? </A> </H2> <P>If your disk is an IDE or EIDE drive, you should read the file <CODE>/usr/src/linux/drivers/block/README.ide</CODE> (part of the Linux kernel source code). This README contains many helpful hints about IDE drives. Many modern IDE controllers do translation between `physical' cylinders/heads/sectors, and `logical' ones. <P>SCSI disks are accessed by linear block numbers. The BIOS invents some `logical' cylinder/head/sector fiction to support DOS. <P>An IBM PC-compatible BIOS will usually not be able to access partitions which extend beyond 1024 logical cylinders, and will make booting a Linux kernel from such partitions using LILO problematic at best. <P>You can still use such partitions for Linux or other operating systems that access the controller directly. <P>It's recommend that you create at least one Linux partition entirely under the 1024 logical cylinder limit, and boot from that. The other partitions will then be okay. <P>Also there seems to be a bit of trouble with the newer Ultra-DMA drives. I haven't gotten the straight scoop on them--but they are becoming a very common problem at the SVLUG installfests. When you can get 8 to 12 Gig drives for $200 to $300 it's no wonder. <P>[Jim Dennis] <P>------------------------------------------------------------------------------- <P> <H2><A NAME="How can I undelete files?"></A> <A NAME="ss4.2">4.2 How can I undelete files? </A> </H2> <P>In general, this is very hard to do on Unices because of their multitasking nature. Undelete functionality for the ext2fs file system is being worked on, but don't hold your breath. <P>There are a number of packages available which instead provide new commands for deleting and copying which move deleted files into a `wastebasket' directory. The files can be recovered until cleaned out automatically by background processing. <P>Alternatively, you can search the raw disk device which holds the file system in question. This is hard work, and you will need to be logged in as root to do this. <P>------------------------------------------------------------------------------- <P> <H2><A NAME="Is there a defragmenter for ext2fs etc.?"></A> <A NAME="ss4.3">4.3 Is there a defragmenter for ext2fs etc.? </A> </H2> <P>Yes. There is <CODE>defrag</CODE>, a Linux file system defragmenter for ext2, Minix, and old-style ext file systems. It is available at <A HREF="ftp://sunsite.unc.edu/pub/Linux/system/filesystems/defrag-0.70.tar.gz">sunsite.unc.edu/pub/Linux/system/filesystems/defrag-0.70.tar.gz</A>. <P>Users of the ext2 file system can probably do without <CODE>defrag</CODE>, because ext2 contains extra code to keep fragmentation reduced even in very full file systems. <P>------------------------------------------------------------------------------- <P> <H2><A NAME="How do I format and create a file system on a floppy?"></A> <A NAME="ss4.4">4.4 How do I format and create a file system on a floppy? </A> </H2> <P>To format a 3.5-inch, high density floppy: <PRE> $ fdformat /dev/fd0H1440 $ mkfs -t ext2 -m 0 /dev/fd0H1440 1440 </PRE> For a 5.25 inch floppy, use <CODE>fd0h1200</CODE> and <CODE>1200</CODE> as appropriate. For the `B' drive use <CODE>fd1</CODE> instead of <CODE>fd0</CODE>. <P>The <CODE>-m 0</CODE> option tells <CODE>mkfs.ext2</CODE> not to reserve any space on the disk for the superuser--usually the last 10% is reserved for root. <P>The first command performs a low-level format. The second creates an empty file system. You can mount the floppy like a hard disk partition and simply <CODE>cp</CODE> and <CODE>mv</CODE> files, etc. <P>Device naming conventions generally are the same as for other Unices. They can be found in Matt Welsh's <EM>Installation and Getting Started</EM> Guide. (See `` <A HREF="Linux-FAQ-2.html#Where can I get the HOWTO's and other documentation?">Where can I get the HOWTO's and other documentation?</A> '') A more detailed and technical description is <EM>Linux Allocated Devices</EM> by H. Peter Anvin, <A HREF="mailto:hpa@zytor.com">hpa@zytor.com</A>, which is included in LaTeX and ASCII form in the kernel source distribution (probably in <CODE>/usr/src/kernel/Documentation</CODE>), as <CODE>devices.tex</CODE> and <CODE>devices.txt</CODE>. <P>------------------------------------------------------------------------------- <P> <H2><A NAME="I get nasty messages about inodes, blocks, and the like."></A> <A NAME="ss4.5">4.5 I get nasty messages about inodes, blocks, and the like. </A> </H2> <P>You may have a corrupted file system, probably caused by not shutting Linux down properly before turning off the power or resetting. You need to use a recent shutdown program to do this--for example, the one included in the util-linux package, available on sunsite and tsx-11. <P>If you're lucky, the program fsck (or e2fsck or xfsck as appropriate if you don't have the automatic fsck front-end) will be able to repair your file system. If you're unlucky, the file system is trashed, and you'll have to re-initialize it with mkfs (or mke2fs, mkxfs, etc.), and restore from a backup. <P>NB: don't try to check a file system that's mounted read/write--this includes the root partition, if you don't see <PRE> VFS: mounted root ... read-only </PRE> at boot time. <P>------------------------------------------------------------------------------- <P> <H2><A NAME="My swap area isn't working."></A> <A NAME="ss4.6">4.6 My swap area isn't working. </A> </H2> <P>When you boot (or enable swapping manually) you should see <PRE> Adding Swap: NNNNk swap-space </PRE> If you don't see any messages at all you are probably missing <PRE> swapon -av </PRE> (the command to enable swapping) in your <CODE>/etc/rc.local</CODE> or <CODE>/etc/rc.d/*</CODE> (the system startup scripts), or have forgotten to make the right entry in <CODE>/etc/fstab</CODE>: <P> <PRE> /dev/hda2 none swap sw </PRE> for example. <P>If you see <PRE> Unable to find swap-space signature </PRE> you have forgotten to run <CODE>mkswap</CODE>. See the manual page for details; it works much like <CODE>mkfs</CODE>. <P>Running, 'free' in addition to showing free memory, should display: <PRE> total used free Swap: 10188 2960 7228 </PRE> <P>[Andy Jefferson] <P>Take a look also at the Installation HOWTO for detailed instructions of how to set up a swap area. <P>------------------------------------------------------------------------------- <P> <H2><A NAME="How do I remove LILO so my system boots DOS again?"></A> <A NAME="ss4.7">4.7 How do I remove LILO so my system boots DOS again? </A> </H2> <P>Using DOS (MS-DOS 5.0 or later, or OS/2), type <CODE>FDISK /MBR</CODE> (which is not documented). This will restore a standard MS-DOS Master Boot Record. If you have DR-DOS 6.0, go into FDISK in the normal way and then select the `Re-write Master Boot Record' option. <P>If you don't have MS-DOS or DR-DOS, you need to have the boot sector that LILO saved when you first installed it. You did keep that file, didn't you? It's probably called <CODE>boot.0301</CODE> or some such. Type <PRE> dd if=boot.0301 of=/dev/hda bs=445 count=1 </PRE> (or <CODE>/dev/sda</CODE> if you're using a SCSI disk). This may also wipe out your partition table, so beware! If you're desperate, you could use <PRE> dd if=/dev/zero of=/dev/hda bs=512 count=1 </PRE> This will erase your partition table and boot sector completely: you can then reformat the disk using your favorite software. But this will render the contents of your disk inaccessible--you'll lose it all unless you're an expert. <P>Note that the DOS MBR boots whichever (single!) partition is flagged as `active'. You may need to use <CODE>fdisk</CODE> to set and clear the active flags on partitions appropriately. <P>------------------------------------------------------------------------------- <P> <H2><A NAME="Why can't I use fdformat except as root?"></A> <A NAME="ss4.8">4.8 Why can't I use fdformat except as root? </A> </H2> <P>The system call to format a floppy can only be done as root, regardless of the permissions of <CODE>/dev/fd0*</CODE>. If you want any user to be able to format a floppy, try getting the <CODE>fdformat2</CODE> program. This works around the problems by being setuid to root. <P>------------------------------------------------------------------------------- <P> <H2><A NAME="My ext2fs partitions are checked each time I reboot."></A> <A NAME="ss4.9">4.9 My ext2fs partitions are checked each time I reboot. </A> </H2> <P>See `` <A HREF="Linux-FAQ-9.html#EXT2-fs: warning: mounting unchecked file system.">EXT2-fs: warning: mounting unchecked file system.</A>''. <P>------------------------------------------------------------------------------- <P> <H2><A NAME="My root file system is read-only!"></A> <A NAME="ss4.10">4.10 My root file system is read-only! </A> </H2> <P>Remount it. If <CODE>/etc/fstab</CODE> is correct, you can simply <PRE> mount -n -o remount / </PRE> If <CODE>/etc/fstab</CODE> is wrong, you must give the device name and possibly the type, too: e.g. <PRE> mount -n -o remount -t ext2 /dev/hda2 / </PRE> To understand how you got into this state, see, `` <A HREF="Linux-FAQ-9.html#EXT2-fs: warning: mounting unchecked file system.">EXT2-fs: warning: mounting unchecked file system.</A>'' <P>------------------------------------------------------------------------------- <P> <H2><A NAME="I have a huge /proc/kcore! Can I delete it?"></A> <A NAME="ss4.11">4.11 I have a huge /proc/kcore! Can I delete it? </A> </H2> <P>None of the files in /proc are really there--they're all, ``pretend,'' files made up by the kernel, to give you information about the system and don't take up any hard disk space. <P>/proc/kcore is like an `alias' for the memory in your computer. Its size is the same as the amount of RAM you have, and if you read it as a file, the kernel does memory reads. <P>------------------------------------------------------------------------------- <P> <H2><A NAME="My AHA1542C doesn't work with Linux."></A> <A NAME="ss4.12">4.12 My AHA1542C doesn't work with Linux. </A> </H2> <P>The option to allow disks with more than 1024 cylinders is only required as a workaround for a PC-compatible BIOS misfeature and should be turned `off' under Linux. For older Linux kernels you need to turn off most of the `advanced BIOS' options--all but the one about scanning the bus for bootable devices. <P>=============================================================================== <P> <HR> <A HREF="Linux-FAQ-5.html"><IMG SRC="next.gif" ALT="Next"></A> <A HREF="Linux-FAQ-3.html"><IMG SRC="prev.gif" ALT="Previous"></A> <A HREF="Linux-FAQ.html#toc4"><IMG SRC="toc.gif" ALT="Contents"></A> </BODY> </HTML>