转:复制linux文件系统
how to copy linux file system to another hard disk* To: [email protected]
* Subject: how to copy linux file system to another hard disk
* From: Terrence Miao <[email protected]>
* Date: Tue, 20 Jan 2004 15:35:19 +1100
* User-agent: Mutt/1.4.1i
how to copy linux file system to another hard disk
--------------------------------------------------
1. partition the new hard disk; create /boot, /, swap partitions; make file
system (including swap, use commands mkfs.ext3 and mkswap, swapon)
# fdisk -l /dev/hda
Disk /dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks IdSystem
/dev/hda1 * 1 208016707568+ 7HPFS/NTFS
/dev/hda2 2081 2093 104422+83Linux
/dev/hda3 2094 2347 2040255 82Linux swap
/dev/hda4 2348 972959295915 fWin95 Ext'd (LBA)
/dev/hda5 2348 972959295883+83Linux
2. use "cp -a" command, copy the following directories to new hard
disk (ignore "/proc" directory):
# ls -1
bin
boot
dev
etc
home
initrd
lib
lost+found
misc
mnt
opt
root
sbin
tmp
usr
var
# mkdir proc (on the new hard disk)
3. install grub boot loader:
# cat /boot/grub/device.map
# this device map was generated by anaconda
(fd0) /dev/fd0
(hd0) /dev/hda
# grub-install --root-directory=/boot '(hd0)'
OR
boot the new hard disk with GRUB Boot floppy, install GRUB natively:
# cd /usr/share/grub/i386-pc
# dd if=stage1 of=/dev/fd0 bs=512 count=1
1+0 records in
1+0 records out
# dd if=stage2 of=/dev/fd0 bs=512 seek=1
153+1 records in
153+1 records out
Once booted from floppy, GRUB will show the command-line interface (*note
Command-line interface::). First, set the GRUB's "root device"(1)
(*note Installing GRUB natively-Footnote-1::) to the boot directory,
like this:
grub> root (hd0,0)
Once you've set the root device correctly, run the command `setup'
(*note setup::):
grub> setup (hd0)
4. modify file "fstab" and "grub.conf":
# cat /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devptsgid=5,mode=6200 0
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/hda3 swap swap defaults 0 0
/dev/cdrom /mnt/cdrom udf,iso9660
noauto,owner,kudzu,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0
0
# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:You have a /boot partition.This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,1)
# kernel /vmlinuz-version ro root=/dev/hda5
# initrd /initrd-version.img
#boot=/dev/hda
default=0
timeout=30
splashimage=(hd0,1)/grub/splash.xpm.gz
title Red Hat Linux (2.4.20-8)
root (hd0,1)
kernel /vmlinuz-2.4.20-8 ro root=LABEL=/
initrd /initrd-2.4.20-8.img
title Red Hat Linux (2.4.20-8 with FrameBuffer)
root (hd0,1)
kernel /vmlinuz-2.4.20-8 ro root=LABEL=/ vga=773
initrd /initrd-2.4.20-8.img
title Windows XP
rootnoverify (hd0,0)
chainloader +1
--
[m
页:
[1]