Linux Frequently Asked Questions with Answers (Part 3 of 6)

Linux Frequently Asked Questions with Answers (Part 3 of 6)

Post by rkiesl.. » Tue, 03 Sep 2002 18:07:24



Archive-Name: linux/faq/part3
URL: http://www.mainmatter.com/
Reply-to: rkiesl...@mainmatter.com
Posting-Frequency: weekly
Last-modified: 12/04/2001

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.

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.

[Jim Dennis]

4.2. How To Undelete Files.

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.

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.

The Midnight Commander file manager provides an undelete facility that
uses Ext2 file system library functions and an undelete directory for
each file system. Commercial distribution packages of MC may or may
not have this feature enabled, so be sure to look in the source code
distribution for instructions on how to enable the undelete feature.

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. But it can be done. Run grep on the raw device;
e.g.:

   grep -b 'bookmarks' /dev/hda

If the data has not been overwritten, you should be able to recover it
with a text editor.

[Dave Cinege, Daniel Novotny]

4.3. How To Make Backups.

You can back up a directory hierarchy or complete file system to any
media using GNU tar or cpio, the standard *nix tools for this purpose.
tar seems to be the more commonly used program currently, and includes
command line options to make compressed, incremental, and multi-volume
backups. Complete information is contained in the documentation, which
is in GNU Texinfo format.

The free program, Amanda, receives a lot of mentions on Usenet. Its
home page is http://www.amanda.org/.

Several commercial backup utilities also exist. They are often
included in commercial distributions.

4.4. How To Resize a Partition (Non-Destructively).

Use the FIPS.EXE program, included with most Linux distributions,under
MS-DOS.

GNU parted, a partition editor, is stable enough for non-guru,
mere-mortal use with relative confidence. Source code for the latest
version is at: ftp://ftp.gnu.org/pub/gnu/parted/. There's also a boot
disk image for resizing root partitions and for running parted on
non-Linux machines. The disk image may be easier for beginners.
Building from source could require some extra configuration.

Parted also has tutorial-style, plain-text documentation for Linux and
FAT (MS-DOS) file systems.

Also, some commercial distributions come with their own partitioning
software, like Partition Magic.

4.5. Is There a Defragmenter for Ext2fs?

Yes. There is defrag, a Linux file system defragmenter for ext2,
Minix, and old-style ext file systems. It is available at
ftp://metalab.unc.edu/pub/Linux/system/filesystems/defrag-0.70.tar.gz.

Users of the ext2 file system can probably do without defrag, because
ext2 contains extra code to keep fragmentation reduced even in very
full file systems.

4.6. How To Create a File System on a Floppy.

To format a 3.5-inch, high density floppy:

$ fdformat /dev/fd0H1440
$ mkfs -t ext2 -m 0 /dev/fd0H1440 1440

For a 5.25 inch floppy, use fd0h1200 and 1200 as appropriate. For the
B: drive use fd1 instead of fd0.

The -m 0 option tells mkfs.ext2 not to reserve any space on the disk
for the superuser--usually the last 10% is reserved for root.

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 cp and mv files, etc.

Device naming conventions generally are the same as for other unices.
They can be found in Matt Welsh's Installation and Getting Started
guide. Refer to ("Where Is the Documentation?") A more detailed and
technical description is Linux Allocated Devices by H. Peter Anvin,
h...@zytor.com, which is included in LaTeX and ASCII form in the kernel
source distribution (probably in /usr/src/kernel/Documentation/), as
devices.tex and devices.txt.

4.7. Does Linux Support Virtualized File Systems Like RAID?

The most recent Linux kernels support software RAID, and they will
work with RAID disk controllers.

An automounter for NFS partitions is part of most Linux distributions.

In addition, several virtual file system projects exist. One of them,
the Linux Logical Volume Manager, is located at
http://linux.msede.com/lvm/.

4.8. Does Linux Support File System Encryption?

Yes. One file system, ppdd, is archived at
http://pweb.de.uu.net/flexsys.mtk/.

4.9. Linux Prints Nasty Messages about Inodes, Blocks, and the Like.

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.

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.

NB: don't try to check a file system that's mounted read/write--this
includes the root partition, if you don't see

   VFS: mounted root ... read-only

at boot time.

4.10. The Swap Area Isn't Working.

When you boot (or enable swapping manually) you should see

   Adding Swap: NNNNk swap-space

If you don't see any messages at all you are probably missing

   swapon -av

(the command to enable swapping) in your /etc/rc.local or /etc/rc.d/*
(the system startup scripts), or have forgotten to make the right
entry in /etc/fstab:

   /dev/hda2       none       swap       sw

for example.

If you see:

   Unable to find swap-space signature

you have forgotten to run mkswap. See the manual page for details; it
works much like mkfs.

Running, free in addition to showing free memory, should display:

          total       used       free
Swap:        10188       2960       7228

If typing "cat /proc/swaps" reveals only file or partition names, but
no swap space information, then the swap file or partition needs
re-initialization.

Use fdisk (as root) to determine which partition on a hard drive has
been designated as the swap partition. The partition still needs to be
initialized with mkswap before enabling it with swapon.

[Andy Jefferson, Steve Withers]

4.11. How To Add Temporary Swap Space.

In addition to a swap partition, Linux can also use a swap file. Some
programs, like g++, can use huge amounts of virtual memory, requiring
the temporary creation of extra space. To install an extra 64 MB of
swap space, for example, use the following shell commands:

# dd if=/dev/zero of=/swap bs=1024 count=65535
# mkswap /swap
# swapon /swap

The count= argument to dd determines how big the swap file will be. In
this example the swap file's name is /swap, but the name and location
are, generally, arbitrary, depending only on the file system's
available space and your having write permissions in the directory.

When you don't need the swap space any more, remove it with the
following statements:

# swapoff /swap
# rm /swap

Take a look also at the Installation HOWTO and Installation & Getting
Started for detailed instructions.

If that still doesn't provide enough swap space, refer to ("How To
Have More Than 128Mb of Swap.")

4.12. How To Remove LILO So the System Boots DOS Again?

The lilo program (not the complete LILO package), uses the command
line option -u to uninstall the LILO boot loader. You have to supply
the device name of the device you installed LILO on, for example:

   lilo -u /dev/hda

This rewrites the original, pre-LILO master boot record back to the
first hard drive, from the boot record saved in /boot/boot.0300. If
you installed LILO to a partition as a secondary boot loader, for
example, /dev/hda1, lilo re-installs the original boot sector from the
save file /boot/boot.0301. Refer to the lilo manual page for details.
Thanks to Villy Kruse for reminding me to update this answer.

If you have an earlier version of LILO, you will have to use the DOS
(MS-DOS 5.0 or later, or OS/2) FDISK /MBR (which is not documented).
This will restore a standard MS-DOS Master Boot Record. If you have
DR-DOS 6.0, go into FDISK.EXE in the normal way and then select the
Re-write Master Boot Record option.

If you create a boot floppy during the Windows installation process,
make sure that it contains the programs FDISK.EXE, FORMAT.COM, and
SYS.COM, and use that to re-install MS-DOS on the hard disk.

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 boot.0301 or some such. Type:

   dd if=boot.0301 of=/dev/hda bs=445 count=1

(or /dev/sda if you're using a SCSI disk). This may also wipe out your
partition table, so beware! If you're desperate, you could use

   dd if=/dev/zero of=/dev/hda bs=512 count=1

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.

Note that the DOS MBR boots whichever (single!) partition is flagged
as "active." You may need to use fdisk to set and clear the active
flags on partitions appropriately.

4.13. Why Does fdformat Require ...

read more »

 
 
 

Linux Frequently Asked Questions with Answers (Part 3 of 6)

Post by rkiesl.. » Tue, 10 Sep 2002 21:51:44


Archive-Name: linux/faq/part3
URL: http://www.mainmatter.com/
Reply-to: rkiesl...@mainmatter.com
Posting-Frequency: weekly
Last-modified: 12/04/2001

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.

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.

[Jim Dennis]

4.2. How To Undelete Files.

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.

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.

The Midnight Commander file manager provides an undelete facility that
uses Ext2 file system library functions and an undelete directory for
each file system. Commercial distribution packages of MC may or may
not have this feature enabled, so be sure to look in the source code
distribution for instructions on how to enable the undelete feature.

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. But it can be done. Run grep on the raw device;
e.g.:

   grep -b 'bookmarks' /dev/hda

If the data has not been overwritten, you should be able to recover it
with a text editor.

[Dave Cinege, Daniel Novotny]

4.3. How To Make Backups.

You can back up a directory hierarchy or complete file system to any
media using GNU tar or cpio, the standard *nix tools for this purpose.
tar seems to be the more commonly used program currently, and includes
command line options to make compressed, incremental, and multi-volume
backups. Complete information is contained in the documentation, which
is in GNU Texinfo format.

The free program, Amanda, receives a lot of mentions on Usenet. Its
home page is http://www.amanda.org/.

Several commercial backup utilities also exist. They are often
included in commercial distributions.

4.4. How To Resize a Partition (Non-Destructively).

Use the FIPS.EXE program, included with most Linux distributions,under
MS-DOS.

GNU parted, a partition editor, is stable enough for non-guru,
mere-mortal use with relative confidence. Source code for the latest
version is at: ftp://ftp.gnu.org/pub/gnu/parted/. There's also a boot
disk image for resizing root partitions and for running parted on
non-Linux machines. The disk image may be easier for beginners.
Building from source could require some extra configuration.

Parted also has tutorial-style, plain-text documentation for Linux and
FAT (MS-DOS) file systems.

Also, some commercial distributions come with their own partitioning
software, like Partition Magic.

4.5. Is There a Defragmenter for Ext2fs?

Yes. There is defrag, a Linux file system defragmenter for ext2,
Minix, and old-style ext file systems. It is available at
ftp://metalab.unc.edu/pub/Linux/system/filesystems/defrag-0.70.tar.gz.

Users of the ext2 file system can probably do without defrag, because
ext2 contains extra code to keep fragmentation reduced even in very
full file systems.

4.6. How To Create a File System on a Floppy.

To format a 3.5-inch, high density floppy:

$ fdformat /dev/fd0H1440
$ mkfs -t ext2 -m 0 /dev/fd0H1440 1440

For a 5.25 inch floppy, use fd0h1200 and 1200 as appropriate. For the
B: drive use fd1 instead of fd0.

The -m 0 option tells mkfs.ext2 not to reserve any space on the disk
for the superuser--usually the last 10% is reserved for root.

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 cp and mv files, etc.

Device naming conventions generally are the same as for other unices.
They can be found in Matt Welsh's Installation and Getting Started
guide. Refer to ("Where Is the Documentation?") A more detailed and
technical description is Linux Allocated Devices by H. Peter Anvin,
h...@zytor.com, which is included in LaTeX and ASCII form in the kernel
source distribution (probably in /usr/src/kernel/Documentation/), as
devices.tex and devices.txt.

4.7. Does Linux Support Virtualized File Systems Like RAID?

The most recent Linux kernels support software RAID, and they will
work with RAID disk controllers.

An automounter for NFS partitions is part of most Linux distributions.

In addition, several virtual file system projects exist. One of them,
the Linux Logical Volume Manager, is located at
http://linux.msede.com/lvm/.

4.8. Does Linux Support File System Encryption?

Yes. One file system, ppdd, is archived at
http://pweb.de.uu.net/flexsys.mtk/.

4.9. Linux Prints Nasty Messages about Inodes, Blocks, and the Like.

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.

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.

NB: don't try to check a file system that's mounted read/write--this
includes the root partition, if you don't see

   VFS: mounted root ... read-only

at boot time.

4.10. The Swap Area Isn't Working.

When you boot (or enable swapping manually) you should see

   Adding Swap: NNNNk swap-space

If you don't see any messages at all you are probably missing

   swapon -av

(the command to enable swapping) in your /etc/rc.local or /etc/rc.d/*
(the system startup scripts), or have forgotten to make the right
entry in /etc/fstab:

   /dev/hda2       none       swap       sw

for example.

If you see:

   Unable to find swap-space signature

you have forgotten to run mkswap. See the manual page for details; it
works much like mkfs.

Running, free in addition to showing free memory, should display:

          total       used       free
Swap:        10188       2960       7228

If typing "cat /proc/swaps" reveals only file or partition names, but
no swap space information, then the swap file or partition needs
re-initialization.

Use fdisk (as root) to determine which partition on a hard drive has
been designated as the swap partition. The partition still needs to be
initialized with mkswap before enabling it with swapon.

[Andy Jefferson, Steve Withers]

4.11. How To Add Temporary Swap Space.

In addition to a swap partition, Linux can also use a swap file. Some
programs, like g++, can use huge amounts of virtual memory, requiring
the temporary creation of extra space. To install an extra 64 MB of
swap space, for example, use the following shell commands:

# dd if=/dev/zero of=/swap bs=1024 count=65535
# mkswap /swap
# swapon /swap

The count= argument to dd determines how big the swap file will be. In
this example the swap file's name is /swap, but the name and location
are, generally, arbitrary, depending only on the file system's
available space and your having write permissions in the directory.

When you don't need the swap space any more, remove it with the
following statements:

# swapoff /swap
# rm /swap

Take a look also at the Installation HOWTO and Installation & Getting
Started for detailed instructions.

If that still doesn't provide enough swap space, refer to ("How To
Have More Than 128Mb of Swap.")

4.12. How To Remove LILO So the System Boots DOS Again?

The lilo program (not the complete LILO package), uses the command
line option -u to uninstall the LILO boot loader. You have to supply
the device name of the device you installed LILO on, for example:

   lilo -u /dev/hda

This rewrites the original, pre-LILO master boot record back to the
first hard drive, from the boot record saved in /boot/boot.0300. If
you installed LILO to a partition as a secondary boot loader, for
example, /dev/hda1, lilo re-installs the original boot sector from the
save file /boot/boot.0301. Refer to the lilo manual page for details.
Thanks to Villy Kruse for reminding me to update this answer.

If you have an earlier version of LILO, you will have to use the DOS
(MS-DOS 5.0 or later, or OS/2) FDISK /MBR (which is not documented).
This will restore a standard MS-DOS Master Boot Record. If you have
DR-DOS 6.0, go into FDISK.EXE in the normal way and then select the
Re-write Master Boot Record option.

If you create a boot floppy during the Windows installation process,
make sure that it contains the programs FDISK.EXE, FORMAT.COM, and
SYS.COM, and use that to re-install MS-DOS on the hard disk.

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 boot.0301 or some such. Type:

   dd if=boot.0301 of=/dev/hda bs=445 count=1

(or /dev/sda if you're using a SCSI disk). This may also wipe out your
partition table, so beware! If you're desperate, you could use

   dd if=/dev/zero of=/dev/hda bs=512 count=1

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.

Note that the DOS MBR boots whichever (single!) partition is flagged
as "active." You may need to use fdisk to set and clear the active
flags on partitions appropriately.

4.13. Why Does fdformat Require ...

read more »