System Administration Guide: Devices and File Systems

ProcedureHow to Restore a Complete File System

Occasionally, a file system becomes so damaged that you must completely restore it. Typically, you need to restore a complete file system after a disk failure. You might need to replace the hardware before you can restore the software. For information on how to replace a disk, see Chapter 12, SPARC: Adding a Disk (Tasks) or Chapter 13, x86: Adding a Disk (Tasks).

Full restoration of a file system such as /export/home can take a lot of time. If you have consistently backed up file systems, you can restore them to their state from the time of the last incremental backup.


Note –

You cannot use this procedure to restore the root (/) or /usr file systems. For instructions on restoring these file systems, see How to Restore the root (/) and /usr File Systems.


Steps
  1. Become superuser or assume an equivalent role.

  2. If necessary, unmount the file system.


    # umount /dev/rdsk/device-name
    

    Or:


    # umount /file-system
    
  3. Create the new file system.


    # newfs /dev/rdsk/device-name
    

    You are asked if you want to construct a new file system on the raw device. Verify that the device-name is correct so that you don't destroy the wrong file system.

    For more information, see the newfs(1M) man page.

  4. Confirm that the new file system should be created.


    newfs: construct a new file system /dev/rdsk/cwtxdysz:(y/n)? y
    

    The new file system is created.

  5. Mount the new file system on a temporary mount point.


    # mount /dev/dsk/device-name /mnt
    
  6. Change to the mount point directory.


    # cd /mnt
    
  7. (Optional) Write-protect the tapes for safety.

  8. Insert the first volume of the level 0 tape into the tape drive.

  9. Restore the files.


    # ufsrestore rvf /dev/rmt/n
    

    The dump level 0 backup is restored. If the backup required multiple tapes, you are prompted to load each tape in numeric order.

  10. Remove the tape and load the next level tape in the drive.

    Always restore tapes starting with dump level 0 and continuing until you reach the highest dump level.

  11. Repeat Step 8 through Step 10 for each dump level, from the lowest to the highest level.

  12. Verify that the file system is restored.


    # ls
    
  13. Remove the restoresymtable file.


    # rm restoresymtable
    

    The restoresymtable file that is created and used by the ufsrestore command to check-point the restore is removed.

  14. Change to another directory.


    # cd /
    
  15. Unmount the newly restored file system.


    # umount /mnt
    
  16. Remove the last tape and insert a new tape that is not write-protected in the tape drive.

  17. Make a level 0 backup of the newly restored file system.


    # ufsdump 0ucf /dev/rmt/n /dev/rdsk/device-name
    

    A level 0 backup is performed. Always immediately do a full backup of a newly created file system because the ufsrestore command repositions the files and changes the inode allocation.

  18. Mount the restored file system.


    # mount /dev/dsk/device-name mount-point
    

    The restored file system is mounted and available for use.

  19. Verify that the restored and mounted file system is available.


    # ls mount-point
    

Example 25–5 Restoring a Complete File System

The following example shows how to restore the /export/home file system.


# umount /export/home
# newfs /dev/rdsk/c0t0d0s7
newfs: /dev/rdsk/c0t0d0s7 last mounted as /export/home
newfs: construct a new file system /dev/rdsk/c0t0d0s7: (y/n)? y
819314 sectors in 867 cylinders of 15 tracks, 63 sectors
        400.1MB in 55 cyl groups (16 c/g, 7.38MB/g, 3584 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
 32, 15216, 30400, 45584, 60768, 75952, 91136, 106320, 121504, 136688,
 681264, 696448, 711632, 725792, 740976, 756160, 771344, 786528, 801712,
 816896,
Verify volume and initialize maps
Media block size is 126
Dump   date: Tue Oct 07 08:41:41 2003
Dumped from: the epoch
Level 0 dump of a partial file system on starbug:/export/home/kryten
Label: none
Begin level 0 restore
Initialize symbol table.
Extract directories from tape
Calculate extraction list.
Extract new leaves.
Check pointing the restore
extract file ./export/home/kryten/filea
extract file ./export/home/kryten/fileb
extract file ./export/home/kryten/filec
extract file ./export/home/kryten/letters/letter1
extract file ./export/home/kryten/letters/letter2
extract file ./export/home/kryten/letters/letter3
extract file ./export/home/kryten/reports/reportA
extract file ./export/home/kryten/reports/reportB
extract file ./export/home/kryten/reports/reportC
Add links
Set directory mode, owner, and times.
Check the symbol table.
Check pointing the restore
# mount /dev/dsk/c0t0d0s7 /mnt
# cd /mnt
# ufsrestore rvf /dev/rmt/0
# ls
# rm restoresymtable
# cd /
# umount /mnt
# ufsdump 0ucf /dev/rmt/0 /export/home
                    .
                    .
                    .
# mount /dev/dsk/c0t3d0s7 /export/home
# ls /export/home