LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 805|回复: 7

问个复制系统的问题

[复制链接]
发表于 2007-4-16 22:20:50 | 显示全部楼层 |阅读模式
俺想把现在用的ubuntu6.06复制到另一个硬盘分区上,但是不想复制 home目录,当然想能启动到新系统用,源系统所在硬盘有15G,所有linux目录包括home都在这个盘里,系统用了有不到5G,另一个硬盘分区6G,如何做啊?

俺没有启动光盘,能不能启动到现在的 linux下做?how to?

是不是除了/sys和 /proc和 /home 直接考过去就行了?
 楼主| 发表于 2007-4-17 09:16:16 | 显示全部楼层
为什么没人理呢,是俺的问题没解,还是 too naive?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-4-17 18:50:57 | 显示全部楼层
用百度搜了一下居然最多的
"利用Ghost复制您的Linux系统",真扫兴。准备直接拷贝.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-4-17 19:58:56 | 显示全部楼层
搜到一个台湾同胞的东东,不错,还是得向台湾同胞学习啊。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-4-17 20:24:19 | 显示全部楼层
再来一个,估计比较老,可能 sir上就有:


备份LINUX系统
 本文讲述一种实践方法:将REDHAT LINUX系统(包括操作系统,应用程序,数据)从一个物 理的系统复制到另一个兼容的物理的系统. 此方法可应用于系统迁移(Server Migration), 系统硬件升级(Server H/W Upgrade), 系统灾难恢复(O.S. Disaster Recovery)等.

  假定被复制的系统(源系统)为A系统,将要建立的系统(目标系统)为B系统.两者都采用固定IP.

  步骤如下:

  1. 在目标系统上安装小的操作系统

  在B系统上安装一个小的Linux,并配制其网络.在安装过程中选择"Server",且去除X Window, Web, Samba, FTP等.只需建2个分区, /(够用就行)和swap(亦将在最终系统上被使用).安装光盘的版本须与源系统的版本一致.

  2. 在目标系统上创建文件系统

  按照A系统上的文件系统层次和大小,在B系统上创建相应的相同大小的文件系统.文件系统的大小可根据实际情况作相应调整.譬如,A系统上有 /, /boot, /tmp, /usr, /var, /var/www, /home, 那么,在B系统上就创建/x, /x/boot, /x/tmp, /x/usr, /x/var, /x/var/www, /x/home.此步骤亦可在安装操作系统时进行.

  3. 将数据从源系统复制到目标系统

  把操作系统,应用程序及其数据从A系统复制到B系统的新建的相应的文件系统上,并修改/x/etc/fstab.

A:/boot       --> B:/x/boot
A:/           --> B:/x
A:/usr        --> B:/x/usr
A:/var        --> B:/x/var
A:/var/www        --> B:/x/var/www
A:/home       --> B:/x/home
  

  根文件系统的复制须包括所有在A系统根文件系统上,除了/proc, /tmp, /dev的数据.

  将数据从A:/复制到B:/x的命令行大致为(须根据实际情况):[ B # ] ssh A "cd /; tar -czf - bin etc initrd misc lib sbin root" | (cd /x; tar -xzf -)

  将数据从A:/boot复制到B:/x/boot的命令行为:[ B # ] ssh A "cd /; tar -czf - boot" | (cd /x; tar -xzf -)

  将数据从A:/var/www复制到B:/x/var/www的命令行为:[ B # ] ssh A "cd /var; tar -czf - www" | (cd /x/var; tar -xzf -)

  若A:/var上一些大的日志文件或临时文件无需复制,可用在tar命令行中加--exclude-from:[ B # ] ssh A "cd /;tar --exclude-from=/home/chinaux/var.exclude -czf" | (cd /x; tar -xzf -)然后在B:/x/var上根据实际需要"touch"这些文件.

  4. 复制新装系统的设备文件

  在目标系统上将新装系统的设备文件复制到新建文件系统/x上:[ B # ] (cd /; tar -czf - dev) | (cd /x; tar xzf -)

  5. 创建/proc, /tmp等

  [ B # ] mkdir -m 755 /x/proc
  [ B # ] mkdir -m 755 /x/mnt
  [ B # ] mkdir -m 755 /x/mnt/floppy /x/mnt/cdrom
  [ B # ] mkdir -m 1777 /x/tmp   ## 若/tmp将在根文件系统上或,[ B # ] chmod 1777 /x/tmp   ## 若/tmp将为一独立的文件系统

  6. 置换设备驱动程序

  比较/etc/modules.conf, /x/etc/modules.conf; 比较"lsmod"在系统A和系统B上的输 出. 若两者使用不同的设备驱动,在系统B上安装所需设备驱动程序(若有此需要; 安装的根 目录为/x),修改/etc/modules.conf, 重建RAMDISK(# chroot /x; mkinitrd ...).

  通常需要置换设备驱动程序是SCSI,NIC设备驱动.此步骤可省略若源系统和目标系统的 硬件相同或相似.

  7. 修改引导菜单,网络配置

  添加复制的操作系统到/boot/grub/grub.conf上(保留其原有行,以防复制的系统不可引导); 修改/x/etc/hosts, /x/etc/sysconfig/network和/x/etc/sysconfig/network-scripts/ifcfg-eth0.

  8. 重启目标系统

  重启B系统,并引导复制的操作系统.若引导失败,引导至所安装的小系统,并解决问题.

  How to duplicate RedHat to another system

  The following describes a workaround to copy a Redhat Linux(inculding applications & data) from one system to another, even they have different models of HDs and different H/W.

  Assuming the box to be modelled after is system A, and the system to be built is system B, the prodedure is as follows:

  1. create a minimum O.S. on the target system

install mininum Linux on system B with networking enabled(a small / and desired swap, e.g. hda1 & hda2)

  2. create file systems on the target system

  follow the file system layout on system A to create partions on system B, and mount them, e.g. /mnt/boot, /mnt, /mnt/usr, /mnt/var. /mnt/tmp. re-use the swap, so no need to create a new swap.

note: mount /mnt at first, then create the directories /mnt/boot, /mnt/usr, etc., and mount the file systems.

  3. copy the data from the source system to the target systemcopy the O.S. and other data on system A to system B

  A: /boot  --> B: /mnt/boot
  A: /usr    --> B: /mnt/usr
  A: / (including /sbin, /etc, /bin, /etc, and the other stuff whatever on / file system, except for /proc, /tmp, /dev) -->    B: /mnt
  A: /var    --> B: /mnt/var

  the command to copy A:/boot to B:/mnt/boot is[ system B # ] ssh systemA "cd /; tar czf - boot" | (cd /mnt/; tar xzf -)

  the command to copy A:/sbin to B:/mnt/sbin is[ system B # ] ssh systemA "cd /; tar czf - boot" | (cd /mnt/; tar xzf -)

  4. fix /tmp, /proc, /dev on the target system

  [ system B # ]  mkdir -m 755 /mnt/proc
  [ system B # ] (cd /; tar czf - dev) | (cd /mnt/; tar xzf -)
  [ system B # ] mkdir -m 1777 /mnt/tmp   ## if /tmp will be on / file systemor,[ system B # ]  chmod 1777 /mnt/tmp   ## if /tmp will be a seperate file system

  5. fix driver issues (scsi driver, NIC drivers, etc)
  compare /etc/module.conf & /mnt/etc/module.conf; compare the outputs of "lsmod" on the 2 systems
  if a driver is required, install it (the root directory should be changed to /mnt), modify /mnt/etc/modules.conf, rebuild ramdisk image if neccessary(# chroot /mnt; mkinitrd ....)

  6. fix bootup, networking & file system table

  modify /boot/grub/grub.conf (don't remove the orignial entry in case the duplicated O.S. cannot be booted up), /mnt/etc/fstab, /mnt/etc/hosts, /mnt/etc/sysconfig/network and /mnt/etc/sysconfig/network-scripts/ifcfg-eth0.

  7. reboot system B, boot from the duplicated O.S. - done

if the bootup fails, boot it from original minimum O.S., and fix the problems.
回复 支持 反对

使用道具 举报

 楼主| 发表于 2007-4-17 20:25:51 | 显示全部楼层
据说用 cp -a 拷贝也可以。回头试试
回复 支持 反对

使用道具 举报

发表于 2007-4-18 17:23:23 | 显示全部楼层
Post by johnstrass
据说用 cp -a 拷贝也可以。回头试试



用 root  执行 cp -a 就行, -a 会保留文件属主,读写属性等

要修改的只有两个 /etc/fstab  , /boot/grub/menu.lst
回复 支持 反对

使用道具 举报

发表于 2007-4-20 19:52:49 | 显示全部楼层
cpio/tar/dumpfs
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表