虾击吧扯

吃鸡巴亏上鸡巴当倒鸡巴霉!

setenforce 0
yum install -y kernel-xen* xen*
sed -i "s/default=1/default=0/g" /etc/grub.conf
wget http://download.lxcenter.org/download/hypervm/production/hypervm-install-slave.sh
sh ./hypervm-install-slave.sh --virtualization-type=xen
lphp.exe /usr/local/lxlabs/hypervm/bin/misc/fixcentos5xen.php #解决Centos xen内核不同步
#Fedora系统为/usr/local/lxlabs/hypervm/bin/misc/fixfc6xen.php
reboot

guest使用windows系统需要使用软连接或者直接将windows iso文件命名为windcd.img存放到/home目录下


ln -sf /home/windows.iso /home/wincd.img

What’s LVM? Why using Linux Logical Volume Manager or LVM? Well, these questions are not the scope here. But in brief, the most attractive feature of Logical Volume Manager is to make disk management easier in Linux!

Basically, LVM allows users to dynamically extend or shrink Linux “partition” or file system in online mode! The LVM can resize volume groups (VG) online by adding new physical volumes (PV) or rejecting those existing PVs attached to VG.

A visualized concept diagram of the Linux Logical Volume Manager or LVM.
A visualized concept diagram of the Linux Logical Volume Manager or LVM

In this 3-minutes Linux LVM guide, let’s assume that
 


  • The LVM is not currently configured or in used. Having say that, this is the LVM tutorial if you’re going to setup LVM from the ground up on a production Linux server with a new SATA / SCSI hard disk.
  • Without a luxury server hardware, I tested this LVM tutorial on PC with the secondary hard disk dedicated for LVM setup. So, the Linux dev file of secondary IDE hard disk will be /dev/hdb (or /dev/sdb for SCSI hard disk).
  • This guide is fully tested in Red Hat Enterprise Linux 4 with Logical Volume Manager 2 (LVM2) run-time environment (LVM version 2.00.31 2004-12-12, Library version 1.00.19-ioctl 2004-07-03, Driver version 4.1.0)!


How to setup Linux LVM in 3 minutes at command line?
 


  1. Login with root user ID and try to avoid using sudo command for simplicity reason.
  2. Using the whole secondary hard disk for LVM partition:
    fdisk /dev/hdb

    At the Linux fdisk command prompt,
    1. press n to create a new disk partition,
    2. press p to create a primary disk partition,
    3. press 1 to denote it as 1st disk partition,
    4. press ENTER twice to accept the default of 1st and last cylinder – to convert the whole secondary hard disk to a single disk partition,
    5. press t (will automatically select the only partition – partition 1) to change the default Linux partition type (0×83) to LVM partition type (0x8e),
    6. press L to list all the currently supported partition type,
    7. press 8e (as per the L listing) to change partition 1 to 8e, i.e. Linux LVM partition type,
    8. press p to display the secondary hard disk partition setup. Please take note that the first partition is denoted as /dev/hdb1 in Linux,
    9. press w to write the partition table and exit fdisk upon completion.
  3. Next, this LVM command will create a LVM physical volume (PV) on a regular hard disk or partition:
    pvcreate /dev/hdb1
  4. Now, another LVM command to create a LVM volume group (VG) called vg0 with a physical extent size (PE size) of 16MB:
    vgcreate -s 16M vg0 /dev/hdb1

    Be properly planning ahead of PE size before creating a volume group with vgcreate -s option!
  5. Create a 400MB logical volume (LV) called lvol0 on volume group vg0:
    lvcreate -L 400M -n lvol0 vg0

    This lvcreate command will create a softlink /dev/vg0/lvol0 point to a correspondence block device file called /dev/mapper/vg0-lvol0.
  6. The Linux LVM setup is almost done. Now is the time to format logical volume lvol0 to create a Red Hat Linux supported file system, i.e. EXT3 file system, with 1% reserved block count:
    mkfs -t ext3 -m 1 -v /dev/vg0/lvol0
  7. Create a mount point before mounting the new EXT3 file system:
    mkdir /mnt/vfs
  8. The last step of this LVM tutorial – mount the new EXT3 file system created on logical volume lvol0 of LVM to /mnt/vfs mount point:
    mount -t ext3 /dev/vg0/lvol0 /mnt/vfs


To confirm the LVM setup has been completed successfully, the df -h command should display these similar message:

/dev/mapper/vg0-lvol0 388M 11M 374M 3% /mnt/vfs

Some of the useful LVM commands reference:
 


vgdisplay vg0
To check or display volume group setting, such as physical size (PE Size), volume group name (VG name), maximum logical volumes (Max LV), maximum physical volume (Max PV), etc.
pvscan
To check or list all physical volumes (PV) created for volume group (VG) in the current system.
vgextend
To dynamically adding more physical volume (PV), i.e. through new hard disk or disk partition, to an existing volume group (VG) in online mode. You’ll have to manually execute vgextend after pvcreate command that create LVM physical volume (PV).


 

转载自:http://www.walkernews.net/2007/07/02/maximum-size-of-a-logical-volume-in-lvm/


Centos 5.1 Linux LVM逻辑卷标管理指南

一、前言
  




  每个Linux使用者在安装Linux时都会遇到这样的困境:在为系统分区时,如何精确评估和分配各个硬盘分区的容量,因为系统管理员不但要考虑到当前某个分区需要的容量,还要预见该分区以后可能需要的容量的最大值。因为如果估计不准确,当遇到某个分区不够用时管理员可能甚至要备份整个系统、清除硬盘、重新对硬盘分区,然后恢复数据到新分区。
  
  虽然现在有很多动态调整磁盘的工具可以使用,例如PartationMagic等等,但是它并不能完全解决问题,因为某个分区可能会再次被耗尽;另外一个方面这需要重新引导系统才能实现,对于很多关键的服务器,停机是不可接受的,而且对于添加新硬盘,希望一个能跨越多个硬盘驱动器的文件系统时,分区调整程序就不能解决问题。
  
  因此完美的解决方法应该是在零停机前提下可以自如对文件系统的大小进行调整,可以方便实现文件系统跨越不同磁盘和分区。幸运的是Linux提供的逻辑盘卷管理(LVM,LogicalVolumeManager)机制就是一个完美的解决方案。
  
  LVM是逻辑盘卷管理(LogicalVolumeManager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分区管理的灵活性。通过LVM系统管理员可以轻松管理磁盘分区,如:将若干个磁盘分区连接为一个整块的卷组(volumegroup),形成一个存储池。管理员可以在卷组上随意创建逻辑卷组(logicalvolumes),并进一步在逻辑卷组上创建文件系统。管理员通过LVM可以方便的调整存储卷组的大小,并且可以对磁盘存储按照组的方式进行命名、管理和分配,例如按照使用用途进行定义:“development”和“sales”,而不是使用物理磁盘名“sda”和“sdb”。而且当系统添加了新的磁盘,通过LVM管理员就不必将磁盘的文件移动到新的磁盘上以充分利用新的存储空间,而是直接扩展文件系统跨越磁盘即可。
  
  二、LVM基本术语
  
  前面谈到,LVM是在磁盘分区和文件系统之间添加的一个逻辑层,来为文件系统屏蔽下层磁盘分区布局,提供一个抽象的盘卷,在盘卷上建立文件系统。首先我们讨论以下几个LVM术语:
  
  *物理存储介质(Thephysicalmedia)
  这里指系统的存储设备:硬盘,如:/dev/hda1、/dev/sda等等,是存储系统最低层的存储单元。
  
  *物理卷(physicalvolume)
  物理卷就是指硬盘分区或从逻辑上与磁盘分区具有同样功能的设备(如RAID),是LVM的基本存储逻辑块,但和基本的物理存储介质(如分区、磁盘等)比较,却包含有与LVM相关的管理参数。
  
  *卷组(VolumeGroup)
  LVM卷组类似于非LVM系统中的物理硬盘,其由物理卷组成。可以在卷组上创建一个或多个“LVM分区”(逻辑卷),LVM卷组由一个或多个物理卷组成。
  
  *逻辑卷(logicalvolume)
  LVM的逻辑卷类似于非LVM系统中的硬盘分区,在逻辑卷之上可以建立文件系统(比如/home或者/usr等)。
  
  *PE(physicalextent)
  每一个物理卷被划分为称为PE(PhysicalExtents)的基本单元,具有唯一编号的PE是可以被LVM寻址的最小单元。PE的大小是可配置的,默认为4MB。
  
  *LE(logicalextent)
  逻辑卷也被划分为被称为LE(LogicalExtents)的可被寻址的基本单位。在同一个卷组中,LE的大小和PE是相同的,并且一一对应。

介绍了LVM接下来我们来做个实验,虚拟机上添加3块8g的硬盘,启动centos 5.1

[root@myadcls ~]# fdisk -l//查看全部添加的硬盘

Disk /dev/sda: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 268 2048287+ 82 Linux swap / Solaris
/dev/sda3 269 2610 18812115 83 Linux

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdd doesn't contain a valid partition table
[root@myadcls ~]# pvcreate /dev/sdb /dev/sdc /dev/sdd //创建pv物理卷
Physical volume "/dev/sdb" successfully created
Physical volume "/dev/sdc" successfully created
Physical volume "/dev/sdd" successfully created
[root@myadcls ~]#
[root@myadcls ~]# pvcreate /dev/sdb /dev/sdc /dev/sdd
Physical volume "/dev/sdb" successfully created
Physical volume "/dev/sdc" successfully created
Physical volume "/dev/sdd" successfully created
[root@myadcls ~]# vgcreate vgtest /sdb /dev/sdc /dev/sdd //创建vgtest名字的卷组
Volume group "vgtest" successfully created
[root@myadcls ~
[root@myadcls ~]# lvcreate -i 3 -I 4 -L 1000M -n lvtest1 vgtest
Rounding size (250 extents) up to stripe boundary size (252 extents)
Logical volume "lvtest1" created


//创建lv, -i参数为采用条带模式的映射方式创建逻辑卷,该参数的值用于指定所创建的逻辑卷将映射在几个PV上。
-I参数使用条带模式时采用的快大小,单位为KB,其值必须是:2N(N>=2),

-L参数指定创建逻辑卷的大小,单位为K,M,G,T表示KB,MB.GB TB等。
-n参数用来指定所创建的逻辑卷的名称,该名称可以根据需要随便定义。

在使用-i的时候,一定要确认所指定的pv是没有完全被分配给任何逻辑卷的,否则将创建失败,其次若这些PV的大小不等,那么创建的逻辑卷只能取最小值。

下面用剩余的空间来创建第二个逻辑卷,通过vgdisplay命令可以查看到卷组的剩余空间如下:

[root@myadcls ~]# vgdisplay
--- Volume group ---
VG Name vgtest
System ID
Format lvm2
Metadata Areas 3
Metadata Sequence No 2
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 1
Open LV 0
Max PV 0
Cur PV 3
Act PV 3
VG Size 23.99 GB
PE Size 4.00 MB
Total PE 6141
Alloc PE / Size 252 / 1008.00 MB
Free PE / Size 5889 / 23.00 GB
VG UUID 0GGQBE-kBOl-QD22-6eWx-J3eW-fGB1-a9ME8F

可以判处free为5889 PE
把空余的pe空间划分给另一个逻辑卷。

[root@myadcls ~]# lvcreate -l 5889 -n lvtest2 vgtest
Logical volume "lvtest2" created
// -l参数指定逻辑卷的LE的数量,默认为4MB, 所以大小为4m x 5889=23556MB

接下来创建文件系统:

在逻辑卷上创建文件系统和在分区上创建文件系统方法是一样的,例如,在逻辑卷上创建ext3日志文件系统,命令如下

[root@myadcls ~]# lvcreate -l 5889 -n lvtest2 vgtest
Logical volume "lvtest2" created
[root@myadcls ~]# mkfs.ext3 /dev/vgtest/lvtest1
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
129024 inodes, 258048 blocks
12902 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=264241152
8 block groups
32768 blocks per group, 32768 fragments per group
16128 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

以上就是Linux下创建逻辑卷的整个步骤
LVM的维护
在LVM日常维护当中,通常要给逻辑卷扩容,添加新的物理卷等操作等。

1.激活卷组,如果不激活不能被访问的,不过默认是激活的,手动激活如下命令:

[root@myadcls ~]# vgchange -a y vgtest//参数解释 -a 用于设置指定的卷组是否可用,参数y表示激活卷组,若设置成n则表示暂停卷组使用。

2 logical volume(s) in volume group "vgtest" now active


2.为卷组增加新的物理卷,当卷组空间不足时候,可以加入新的物理卷来扩大卷组的容量,这时候可以用去vgextend命令来实现,如下:
[root@myadcls ~] vgextend vgtest /dev/sde
Volume
group "vgtest" successfully extended
其中“/dev/sde”是增加的物理卷,前提要pvcreate来初始化

3.从卷组中移除物理卷
要从一个卷组中移除一个物理卷,首先要确认移除的物理卷中没有被任何逻辑卷正在使用,通过pvdisplay命令来查看.
[root@myadcls ~]# pvdisplay /dev/sde
--- Physical volume ---
PV Name /dev/sde
VG Name vgtest
PV Size 8.00 GB / not usable 0
Allocatable yes (but full)
PE Size (KByte) 4096
Total PE 2047
Free PE 0
Allocated PE 2047
PV UUID NrrGyd-y0j1-06cD-ZA5l-ipxV-LvvP-YeIB9q

4.如果某个物理卷正在被逻辑卷在使用,就需要将物理卷的数据移动到其它地方,然后移除。移除物理卷的命令为vgreduce vgtest /dev/sde

5.在物理卷间的转移数据
当发现逻辑卷下的某个磁盘有问题,或者其它需求转移其中的物理卷的数据时候(如更换大硬盘或更快的物理设备),那么可通过pvmove来实现物理卷之间转移数据,例如,将物理卷/dev/sdd上的数据移动到/dev/sde具体步骤如下:

pvmove /dev/sdd /dev/sde
其中/dev/sde的大小移动要大于或等于/dev/sdd,其次在使用pvmove前需要modprobe dm-mirror 命令来加载dm-mirror模块,因为pvmove在转移数据时候需要用到这个模块,而默认系统部加载这个模块的。

6.扩展逻辑卷
在前面提到过,lvm提供了方便的调整逻辑卷大小的功能,扩展逻辑卷的大小事lvextend命令,例如将lvtest2的空间调整为1600m
lvextend -L 1600M /dev/vgtest/lvtest2

也可以在原来的基础增加相应的大小,如下:
lvextend -L +40M /dev/vgtest/lvtest2

逻辑卷扩展之后并不会马上生效,需要使用resize2fs命令重新加载逻辑卷的大小,该命令只针对ext2/ext3的文件系统(若是reiserfs的文件系统,则用resize_reiserfs命令),如果该逻辑卷正在使用中,就应该先将该逻辑卷卸载后在执行,resize2fs命令操作如下:

umount /dev/vgtest/lvtest2
resize2fs /dev/vgtest/lvtest2

mount /dev/vgtest/lvtest2 /mnt/lvtest2/

以上这些操作可以通过ext2online命令来直接实现,这样就不用做卸载逻辑卷等操作了,如下:

ext2online /dev/vgtest/lvtest2

7.删除逻辑卷
删除逻辑卷前首先需要将其卸载,其命令为lvremove如下:

lvremove /dev/vgtest/lvtest2
y即可卸载成功

8.移除卷组
在移除卷组之前首先要确认该卷组中已经没有任何逻辑卷了,或者可以用vgchange手动将卷组停止工作,移除卷组操作如下:

vgremove vgtest

9.删除物理卷

在删除物理卷前,必须确认该物理卷中已经在卷组中移除了,删除物理卷的命令如下:
pvremove /dev/sde

LVM还可以提供snapshot快照功能,其中快照能够快速的备份当前逻辑卷中的数据,从而大大减轻了备份数据的负担,只是目前来说技术还是不成熟。

本文出自 “有志者事竟成!” 博客,请务必保留此出处http://zh888.blog.51cto.com/1684752/357151


软RAID(mdadm)配置与维护
1.fdsik 分区
按n 分区
按t键改分区信息为fd
新建分区
/dev/sdc1
/dev/sdd1
/dev/sde1
/dev/sdf1
例举如下:
Disk /dev/sdc: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 652 5237158+ fd Linux raid autodetect
2.使part设备生效
#partprobe
3.用mdadm 创建/dev/md0

 


# mdadm -C /dev/md0 -a yes -l 5 -n 3 -x 1 /dev/sd{c,d,e,f}1

复制代码

mdadm: array /dev/md0 started.
mdadm 各参数解释:
-C 是Create(创建)
-l 是RAID级别 (此例为RAID5)
-n 是所用硬盘数量 (此例为3个,分别为/dev/sd{c,d,e}1
-x 是热备(spare)盘数 (此例为1个 /dev/sdf1
/dev/sd{c,d,e,f}1 为device(设备名)此例为/dev/sd(c,d,e,f}1,"sdc1,sdd1,sde1"为RAID5盘三个,“sdf1”为热备(spare)盘
4.用mdadm 显示与检查/dev/md0分区情况
 


#mdadm --detail /dev/md0

复制代码

/dev/md0:
Version : 0.90
Creation Time : Fri Jul 8 04:00:27 2011
Raid Level : raid5
Array Size : 10474112 (9.99 GiB 10.73 GB)
Used Dev Size : 5237056 (4.99 GiB 5.36 GB)
Raid Devices : 3
Total Devices : 4
Preferred Minor : 0
Persistence : Superblock is persistent
Update Time : Fri Jul 8 04:00:27 2011
State : clean, degraded, recovering
Active Devices : 2
Working Devices : 4
Failed Devices : 0
Spare Devices : 2
Layout : left-symmetric
Chunk Size : 64K
Rebuild Status : 71% complete
UUID : ac0b6e5b:904397f1:d8d86aac:277f8585
Events : 0.1
Number Major Minor RaidDevice State
0 8 33 0 active sync /dev/sdc1
1 8 49 1 active sync /dev/sdd1
4 8 65 2 spare rebuilding /dev/sde1
3 8 81 - spare /dev/sdf1
5.格式化/dev/md0 RAID5 分区
 


#mke2fs -j /dev/md0

复制代码

mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1310720 inodes, 2618528 blocks
130926 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
6.创建mdadm.conf文件以使机器重启动生效可以正常使用/dev/md0

 


#mdadm -D -s > /etc/mdadm.conf

复制代码


# cat /etc/mdadm.conf
ARRAY /dev/md0 level=raid5 num-devices=3 metadata=0.90 spares=1 UUID=ac0b6e5b:904397f1:d8d86aac:277f8585
II.测试RAID 5 功能与管理RAID5
a.首先测试spare热备功能
#mkdir /r5
#mount /dev/md0 /r5
#cd /r5
#seq 1000000 > test.txt
seq 写1-1000000数到 test.txt 下
1.强力set /dev/md0里的一个分区为faulty

 


#mdadm /dev/md0 -f /dev/sdd1

复制代码

#mdadm --detail /dev/md0

Rebuild Status : 53% complete
UUID : ac0b6e5b:904397f1:d8d86aac:277f8585
Events : 0.4
Number Major Minor RaidDevice State
0 8 33 0 active sync /dev/sdc1
3 8 81 1 spare rebuilding /dev/sdf1
2 8 65 2 active sync /dev/sde1
4 8 49 - faulty spare /dev/sdd1
注意:查看时一定要看“3 8 81 1 spare rebuilding /dev/sdf1”
这一行,为热备(spare)盘sdf1顶替sdd1上面为同步中“spare rebuilding”
看这个分区/dev/sdf1完成后(在做换盘操作)如State:active sync 这是正常状态。
2.删除标记为faulty 分区/dev/sdd1

 


#mdadm /dev/md0 -r /dev/sdd1

复制代码

mdadm: hot removed /dev/sdd1
#mdadm --detail /dev/md0
Layout : left-symmetric
Chunk Size : 64K
UUID : ac0b6e5b:904397f1:d8d86aac:277f8585
Events : 0.8
Number Major Minor RaidDevice State
0 8 33 0 active sync /dev/sdc1
1 8 81 1 active sync /dev/sdf1
2 8 65 2 active sync /dev/sde1
3.删除后加入分区
a.还是用这个刚刚删除的“以有问题的/dev/sdd1"分区
b.用fdisk 分区删除原用并重新分区为空的分区
c.用fdisk 按t 标示分区为fd
分好如下:
Disk /dev/sdd1: 5362 MB, 5362850304 bytes
255 heads, 63 sectors/track, 651 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdd1p1 1 651 5229126 fd Linux raid autodetect
d. 把/dev/sdd1 加入到/dev/md0中去


 


# mdadm /dev/md0 -a /dev/sdd1

复制代码

mdadm: added /dev/sdd1
# mdadm --detail /dev/md0
UUID : ac0b6e5b:904397f1:d8d86aac:277f8585
Events : 0.8
Number Major Minor RaidDevice State
0 8 33 0 active sync /dev/sdc1
1 8 81 1 active sync /dev/sdf1
2 8 65 2 active sync /dev/sde1
3 8 49 - spare /dev/sdd1
4.关于其他RAID 如-l 0 (RAID0) -l 1 的配置基本与 -l 5(RAID5)没多少区别
a.RAID0 意义不大,要是两个硬盘还只有起到了加速IO的作用无数据安全可言,-n 只能是2
b.RAID1 写入IO可能要弱些但安全有一定的保障(容量减半)-n 也是2 其他我也没有测试。
c.注意:一定不要用一个物理硬盘的几个分区作为RAID的子盘,这样做根本起不到加速IO与加固硬盘内容安全的目的,只会加I/O的负载,切记!
5.这个mdadm 的运用,我个人的看法,只感觉是个折中的方案,有米的话还是硬RAID方案(安全高效)。
注:以上在RHEL5.5与centos5.5 测试通过
 


所需工具、文件
Windows 7安装镜像;
我下载的是7600.16385.090713-1255_x64fre_client_zh-cn_Retail_Ultimate-GRMCULXFRER_CN_DVD.iso,3.1G。


 

 

 

Grub4Dos
用于引导Windows安装,后来听说Grub2也行,还要更方便一些,但我没可能再装一遍,以下还是以grub4dos为例;
EasyBCD
用于在Windows安装完成后找回启动Ubuntu的菜单.

备份MBR
$ sudo dd if=/dev/sda of=/backup/mbr.img bs=512 count=1
 
至关重要。Ubuntu的安装过程会保留Windows启动项,但Windows的安装过程却很霸道,安装后需导入MBR才能找回Ubuntu启动项。
Windows下无法访问Ubuntu里的文件,所以需要把这个备份文件复制到Windows文件系统下,或则先用U盘备份。
 
挂载Windows 7 ISO
$ sudo mount /iso/7600.16385.090713-1255_x64fre_client_zh-cn_Retail_Ultimate-GRMCULXFRER_CN_DVD.iso /mnt -o loop
即把Windows 7 ISO挂载到/mnt,打开这个目录,把里边的所有文件复制到一个NTFS分区的根目录下——不能是将用于安装Windows 7的分区,亦即,需要预先准备两个Windows分区。
 
我这里因为原本就是Windows与Ubuntu并存,Windows下有C、D、E盘,C盘准备用来安装Windows 7,以上安装文件就复制到了E盘根目录下。
 
添加启动菜单
打开载下来的Grub4dos.zip,把其中的grub.exe解压出来。
修改/boot/grub/menu.lst,添加如下几行
 
title grub4dos
root (hd0,3)
kernel /home/grub.exe
boot
 
第二行的0,3需根据实际情况修改,可查看menu.lst里原有的部分,找到Ubuntu的选项复制成一样的即可。
如我原有启动项第一项是:
 
title Ubuntu 9.10, kernel 2.6.31-16-generic
root (hd0,3)
 
第三行的/home/grub.exe需修改成刚解压出的grub.exe所在路径。
 
重启安装
重启,在操作系统选单里选择grub4dos,屏幕一闪再度进入操作系统选单,按c进入命令行grub>,依次输入以下指令:
 
grub>find --set-root /bootmgr
grub>chainloader /bootmgr
grub>boot
 
随即进入Windows 7安装引导界面,一路装下去即可。
 
恢复MBR
Windows安装完成后,多系统选单不见了,此时需要恢复MBR。我安装前在网上找到的几篇文章里有指明,可以在Windows下以如下指令恢复:
echo c:\"linux.lnx"=linux >> boot.ini
遗憾的是Windows 7里好像根本就没有boot.ini,试了一下,此法无效。
 
无奈只好用下了一份easyBCD,安装之后运行,添加LINUX启动项。C盘下会生成c:\nst\nst_linux.mbr文件,删除之,把此前备份的mbr.img复制到这个位置,重命名为nst_linux.mbr。
 
重启在多系统选单选择linux选项,即可看见原来的Ubuntu多系统选单。进入Ubuntu之后,再彻底还原MBR。
$ sudo dd if=/backup/mbr.img of=/dev/sda bs=446 count=1

 

grub4dos 下载
 

grub4dos-0.4.4-2009-01-11-src.zip 12-Jan-2009 06:16 1.4M

grub4dos-0.4.4-2009-01-11.zip 12-Jan-2009 06:19 807k

 


 

本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2010-05/26118.htm

linux备份真是太方便了,其实我们常用的tar就是很好的增量备份软件

使用 tar -g 参数进行增量备份实验

完整备份:

#建立测试路径与档案
mkdir test
touch test/{a,b,c};
在test下生成三个文件

#执行完整备份
tar -g snapshot -zcf backup_full.tar.gz test

#查看 tarball 内容
tar ztf backup_full.tar.gz
test/
test/a
test/b
test/c

增量备份:

#新增一个档案
touch test/d

#执行第一次的增量备份 (注意 tarball 档名)
tar -g snapshot -zcf backup_incremental_1.tar.gz test

#查看 tarball 内容
tar ztf backup_incremental_1.tar.gz
test/
test/d

#新增一个档案, 并异动一个档案内容
touch test/e
echo 123 > test/a

#执行第二次的增量备份 (注意 tarball 档名)
tar -g snapshot -zcf backup_incremental_2.tar.gz test

#查看 tarball 内容
tar ztf backup_incremental_2.tar.gz
test/
test/a
test/e

还原备份资料:

#清空测试资料
rm -rf test

#开始进行资料还原
tar zxf backup_full.tar.gz
tar zxf backup_incremental_1.tar.gz
tar zxf backup_incremental_2.tar.gz

#查看测试资料
ls test
a b c d e

使用 tar -u 参数进行增量备份

第一次备份:

#建立测试路径与档案
mkdir test
touch test/a test/b test/c

#备份资料
tar zcf backup.tar.gz test

#查看 tarball 内容
tar ztf backup.tar.gz
test/
test/a
test/b
test/c

增量备份:

#新增一个档案, 并异动一个档案内容
touch test/d
echo 123 > test/a

#执行增量备份 (-u 参数只能执行於未压缩的 tarball)
gunzip backup.tar.gz
tar uf backup.tar test
gzip backup.tar

#查看 tarball 内容
tar ztf backup.tar.gz
test/
test/a
test/b
test/c
test/
test/a
test/d

还原备份资料:

#清除测试资料
rm -rf test

#解包 tarball
tar zxf backup.tar.gz

#查看测试资料
ls test
a b c d


Powered by Typecho. Trapecho theme by 咳嗽di小鱼.