vm-ubuntu-fe安装过程

vm-ubuntu-fe安装过程

记录时间:2011-03-20

虚拟系统配置

  • CPU:1
  • 内存:512MB
  • 硬盘:系统:2GB
  • 服务:Apache2 + WordPress

提供服务

添加vm-ubuntu-fe虚拟机

在vmhost-ubuntu-vbox上初始化及设置虚拟机

mount /dev/sdb1 /mnt/backup/
su - vbox
VBoxManage createvm --name vm-ubuntu-fe --register
VBoxManage modifyvm vm-ubuntu-fe --cpus 1 --memory 512 --vram 8 --acpi on --boot1 dvd --boot2 disk --audio alsa --audiocontroller ac97 --usb on --usbehci on --nic1 bridged --bridgeadapter1 eth0 --vrde on --vrdevideochannel on --vrdevideochannelquality 75
VBoxManage sharedfolder add vm-ubuntu-fe --name vbox-shared --hostpath /opt/vbox-shared --automount
VBoxManage createhd --filename /opt/vbox/vm-ubuntu-fe/vm-ubuntu-fe-system.vdi --size 2000 --variant fixed
VBoxManage storagectl vm-ubuntu-fe --name "SATA Controller" --add sata
VBoxManage storageattach vm-ubuntu-fe --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium /opt/vbox/vm-ubuntu-fe/vm-ubuntu-fe-system.vdi
VBoxManage storageattach vm-ubuntu-fe --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium /mnt/backup/setup/system/ubuntu-10.04.2-server-amd64.iso
VBoxManage showvminfo vm-ubuntu-fe
VBoxHeadless -s vm-ubuntu-fe

远程VRDP安装

使用Windows上的远程管理工具

  • mstsc <vmhost-ubuntu-vbox-ip>:3389
  • 选项:640*400, 16bit
  • Installer boot menu
    • Language: English
    • <F6>: noacpi=on, nomodeset=on
    • Install Ubuntu Server 10.04 (Rescue mode)
  • Ubuntu installer main menu
    • Choose language: English
    • Location: other, Europe, Germany
    • Detect keyboard layout: yes, + y <ENTER> => de:nodeadkeys
  • Configure the network
    • DHCP: Auto
    • hostname: vm-ubuntu-fe
  • Partition disks
  • Install the base system
  • Set up users and passwords
    • Fullname: admin 2cn.de
    • Username: r
    • Password: <password>
    • Encrypt your home directory: No
  • Configure the package manager
  • Select and install software: No automatic updates
  • Software selection
  • Configuring grub-pc
    • Install the GRUB boot loader to the MBR: Yes
  • Restart

开启代理,更新系统,安装常用软件,删除不需要的软件包

sudo su
export http_proxy=http://www-cache.uni-mannheim.de:3128
apt-get update
apt-get dist-upgrade
apt-get autoremove
apt-get install rcconf
apt-get install python-software-properties
add-apt-repository "deb http://archive.canonical.com/ lucid partner"
apt-get remove ubuntu-docs
apt-get remove mysql-common
apt-get remove samba-common
apt-get clean
apt-get autoclean
apt-get autoremove
cat /etc/issue
vi /etc/hosts
127.0.0.1 vm-ubuntu-fe
10.20.18.104 vmhost-ubuntu-vbox

为r和root用户设置top

添加nagios远程监测

apt-get install nagios-nrpe-server
vi /etc/nagios/nrpe.cfg

修改/添加

allowed_hosts=vmhost-ubuntu-vbox
command[check_all_disks]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -e
/etc/init.d/nagios-nrpe-server restart

避免意外删除文件等错误

vi /etc/bash.bashrc

在vi里添加以下几行:

confirm() {
echo -n "Please confirm $*? [N/y] "
read -N 1 REPLY
echo
if test "$REPLY" = "y" -o "$REPLY" = "Y"; then
"$@"
else
echo "Cancelled by user"
fi
}
alias rm="rm -i"
alias cp="cp -i"
alias mv="mv -i"
alias halt="confirm halt"
alias reboot="confirm reboot"
alias shutdown="confirm shutdown"

SSH设置

用PAM限制SSH用户

vi /etc/pam.d/sshd

在vi里写入

auth required pam_listfile.so item=user sense=allow file=/etc/ssh/ssh.allow onerr=fail

添加允许SSH的用户

vi /etc/ssh/ssh.allow

在vi里写入

r

10分钟后自动关闭空闲的SSH链接

vi /etc/ssh/sshd_config

添加以下几行:

ClientAliveInterval 300
ClientAliveCountMax 2
UseDNS no

安装VirtualBox Additions增强功能

在vmhost-ubuntu-vbox上:

su - vbox
VBoxManage storageattach vm-ubuntu-fe --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium /usr/share/virtualbox/VBoxGuestAdditions.iso

在vm-ubuntu-fe上:

sudo su
mkdir /media/cdrom
mount /dev/cdrom1 /media/cdrom
apt-get install dkms
/media/cdrom/VBoxLinuxAdditions.run --nox11
# 忽略没有视窗的错误:Installing the Window System drivers ...fail!
addgroup r vboxrf

安装apache2

apt-get install apache2
vi /etc/apache2/apache2.conf

添加/修改行:

ServerName localhost
Timeout 60
vi /etc/apache2/conf.d/security

添加/修改行:

# Disable access, directory indexing and .htaccess files by default
<Directory />
Options -Indexes
AllowOverride None
Order Deny,Allow
Deny from all
</Directory>
# Disable system information be included in the HTTP responses
ServerTokens Prod
# Disable system information to be included in server-generated pages
ServerSignature Off
# Disable HTTP TRACE requests
TraceEnable Off
groupadd log
usermod -a -G log www-data
usermod -a -G log r
mkdir /opt/logs
mkdir /opt/logs/apache2
rm -R /var/log/apache2
ln -s /opt/logs/apache2 /var/log/apache2
chown -R www-data.log /opt/logs
chmod -R g+w /opt/logs
chmod -R o-r /opt/logs
chmod -R o-x /opt/logs

安装WordPress

apt-get install mysql-server
apt-get install php5 phpmyadmin
adduser --system --shell /bin/sh --gecos 'wordpress admin' --group --disabled-password --home /opt/wordpress wpadmin
usermod -a -G log wpadmin
usermod -a -G wpadmin www-data
mkdir /opt/wordpress
cd /opt/wordpress
wget http://wordpress.org/latest.tar.gz
tar -zxvf latest.tar.gz
chown -R www-data.www-data wordpress
ln -s /opt/wordpress/wordpress /var/www/wordpress
mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER wpadmin;
SET PASSWORD FOR wpadmin = PASSWORD("<PASSWORD>");
GRANT ALL PRIVILEGES ON wordpress.* TO "wpadmin"@"localhost" IDENTIFIED BY "<PASSWORD>";
FLUSH PRIVILEGES;
EXIT
cp /opt/wordpress/wordpress/wp-config-sample.php /opt/wordpress/wordpress/wp-config.php
vi /opt/wordpress/wordpress/wp-config.php
define('DB_NAME', 'wordpress');
define('DB_USER', 'wpadmin');
define('DB_PASSWORD', '<PASSWORD>');
# https://api.wordpress.org/secret-key/1.1/salt/
<SALT>

设置固定IP

vi /etc/network/interfaces

删除以下dhcp的设置

auto eth0
iface eth0 inet dhcp

添加IP设置

auto  eth0
iface eth0 inet static
address 192.168.178.111
netmask 255.255.255.0
network 192.168.178.0
broadcast 192.168.178.255
gateway 192.168.178.1
vi /etc/resolv.conf
search vm.2cn.de
domain vm.2cn.de
nameserver 192.168.178.1
nameserver 134.155.96.53
vi /etc/hosts
127.0.0.1 vm-ubuntu-fe
127.0.0.1 vm-ubuntu-fe.vm.2cn.de
192.168.168.11 vmhost-ubuntu-vbox
192.168.168.11 vmhost-ubuntu-vbox.2cn.de
/etc/init.d/networking restart

卸载dhcp

apt-get remove dhcp-client3

TODOs

vm-winxp-work虚拟机安装

vm-winxp-work虚拟机安装

记录时间:2011-02-19

虚拟系统配置

  • CPU:1
  • 内存:512MB
  • 显卡:32MB
  • 硬盘:系统:2GB
  • 服务:Apache2 + WordPress

提供服务

  • 迅雷下载:HTTP, FTP, BT, eMule
  • Team Viewer远程控制

在vmhost-ubuntu-vbox上初始化及虚拟机配置

su - vbox
VBoxManage createvm --name vm-winxp-work --register
VBoxManage modifyvm vm-winxp-work --cpus 1 --memory 512 --vram 32 --acpi on --boot1 dvd --boot2 disk --audio alsa --audiocontroller ac97 --usb on --usbehci on --nic1 bridged --bridgeadapter1 eth0 --vrde on --vrdevideochannel on --vrdevideochannelquality 75
VBoxManage sharedfolder add vm-winxp-work --name vbox-shared --hostpath /opt/vbox-shared --automount
VBoxManage createhd --filename /opt/vbox/vm-winxp-work/vm-winxp-work-system.vdi --size 5000 --variant fixed
VBoxManage storagectl vm-winxp-work --name "IDE Controller" --add ide
VBoxManage storageattach vm-winxp-work --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium /opt/vbox/vm-winxp-work/vm-winxp-work-system.vdi
VBoxManage storageattach vm-winxp-work --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium /mnt/backup/setup/system/windows_xp_x86_sp3
.iso
VBoxManage showvminfo vm-winxp-work
VBoxHeadless -s vm-winxp-work

安装系统

  • 按光盘安装步骤正常安装
  • 控制面板 – 切换到经典模式 – 用户账户
    • 选择Administrator
    • 添加密码
    • 添加账户:r
    • 添加密码
    • 换r账户登录
  • 显示 – 屏保 – 墙纸 – 电源
  • 声音 – 静音
  • 系统属性 – 计算机名
  • 系统属性 – 高级 – 性能
  • 系统属性 – 远程 – 系统还原
  • 资源管理器 – 文件夹选项
  • 任务管理器
  • 安装360
  • 用360优化系统:软件 – 开启 – 服务 – 插件 – 系统更新
  • 安装搜狗拼音

加速NTFS

fsutil behavior set disable8dot3 1
fsutil behavior set disablelastaccess 1
fsutil behavior set mftzone 2

转化成SATA

su - vbox
VBoxManage storagectl vm-winxp-work --name "SATA Controller" --add sata
VBoxManage createhd --filename /opt/vbox/vm-winxp-work/vm-winxp-work-data.vdi --size 50000 --variant fixed
VBoxManage storageattach vm-ubuntu-build --storagectl "SATA Controller" --port 1 --device 0 --type hdd --medium /opt/vbox/vm-winxp-work/vm-winxp-work-data.vdi

在vm-winxp-work里安装Intel Matrix Storage Manager驱动 (ICH8M-E/M SATA AHCI)

su - vbox
vi /opt/vbox/vm-winxp-work/vm-winxp-work.vbox

删除IDE信息

VBoxManage storageattach vm-winxp-work --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium /opt/vbox/vm-winxp-work/vm-winxp-work-system.vdi

把vm-winxp-work-data.vdi盘格式化成NTFS(64KB)D盘

安装VirtualBox Additions增强功能

VBoxManage storageattach vm-winxp-work --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium /usr/share/virtualbox/VBoxGuestAdditions.iso

在vm-winxp-work通过DVD安装

(手动添加共享文件夹):在资源管理器里把vbox-shared映射到Z盘上

net use z: \\vboxsvr\vbox-shared /PERSISTENT:yes

删除IDE Controller

VBoxManage storagectl vm-winxp-work --name "IDE Controller" --remove

安装软件

  • 迅雷5绿色免安装版
  • WinRAR绿色版
  • 安装Liberkey
    • Small Suite: Firefox, Faststone Image Viewer, 7-Zip, MPC HomeCinema, HxD, Notepad++, Team Viewer, CCleaner, Defraggler, xp-antispy, Tweak-UI, QuickSys RegDefrag
      • 更新所有软件
      • 运行XP-Antispy(选择Suggested), Tweak-UI, CCleaner
  • 安装Teamviewer
  • 设置CCleaner v3.04.1348
    • 选择CCleaner里的所有选项
  • 安装Firefox插件
    • user agent switcher
    • http resource test
    • easylink

设置任务计划

  • 设置CCleaner
    • 设置任务计划为:每天02:00
    • 设置运行为:C:\WINDOWS\sdelete.exe -c c:/
  • 设置Defraggler
    • 设置任务计划为:每天03:00
    • 设置运行为:df.exe C: /large . 20

TODOs

  • 压缩下载完的文件并移到vbox-shared文件夹里
    for /d %X in (*) do “c:\Program Files\7-Zip\7z.exe” a “%X.7z” “%X\” -mx=9 -ms=on -md=32m -mfb=64 -m0=lzma

vm-ubuntu-build安装过程

vm-ubuntu-build安装过程

记录时间:2011-02-16

虚拟系统配置

  • CPU:1
  • 内存:1024MB
  • 硬盘:系统:2GB, 软件+数据: 50GB

提供服务

服务器 服务 软件 网址
Apache2 前端,http代理,ssl代理 Apache2 2.2.14 (ssl, proxy, proxy-http)
Apache2 软件配置管理 Subversion 2.3.0, Apache2 2.2.14 (dav), WebSVN 2.3.0 https://vm-ubuntu-build/svn/2cn.de,

https://vm-ubuntu-build/websvn 

Tomcat6 仓库管理 Sonatype Nexus 1.9.0.1 http://vm-ubuntu-build/nexus
Tomcat6 持续集成 Oracle Hudson 1.3.96 http://vm-ubuntu-build/hudson

在vmhost-ubuntu-vbox添加vm-ubuntu-build虚拟机

绑定优盘,配置,初始化,启动虚拟机

mount /dev/sdb1 /mnt/backup/
su - vbox
VBoxManage createvm --name vm-ubuntu-build --register
VBoxManage modifyvm vm-ubuntu-build --cpus 1 --memory 1024 --vram 8 --acpi on --boot1 dvd --boot2 disk --audio alsa --audiocontroller ac97 --usb on --usbehci on --nic1 bridged --bridgeadapter1 eth0 --vrde on --vrdevideochannel on --vrdevideochannelquality 75
VBoxManage sharedfolder add vm-ubuntu-build --name vbox-shared --hostpath /opt/vbox-shared --automount
VBoxManage createhd --filename /opt/vbox/vm-ubuntu-build/vm-ubuntu-build-system.vdi --size 2000 --variant fixed
VBoxManage storagectl vm-ubuntu-build --name "SATA Controller" --add sata
VBoxManage storageattach vm-ubuntu-build --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium /opt/vbox/vm-ubuntu-build/vm-ubuntu-build-system.vdi
VBoxManage storageattach vm-ubuntu-build --storagectl "SATA Controller" --port 1 --device 0 --type dvddrive --medium /mnt/backup/setup/system/ubuntu-10.04.2-server-amd64.iso
VBoxManage showvminfo vm-ubuntu-build
VBoxHeadless -s vm-ubuntu-build

远程VRDP安装

使用Windows上的远程管理工具

  • mstsc <vmhost-ubuntu-vbox-ip>:3389
  • 选项:640*400, 16bit

安装ubuntu,硬盘分区,安装OpenSSH

  • Installer boot menu
    • Language: English
    • <F6>: noacpi=on, nomodeset=on
    • Install Ubuntu Server 10.04 (Rescue mode)
  • Ubuntu installer main menu
    • Choose language: English
    • Location: other, Europe, Germany
    • Detect keyboard layout: yes, + y <ENTER> => de:nodeadkeys
  • Configure the network
    • DHCP: Auto
    • hostname: vm-ubuntu-build
  • Partition disks
  • Install the base system
  • Set up users and passwords
    • Fullname: admin vm-ubuntu-build
    • Username: r
    • Password: <password>
    • Encrypt your home directory: No
  • Configure the package manager
  • Select and install software: No automatic updates
  • Software selection
  • Configuring grub-pc
    • Install the GRUB boot loader to the MBR: Yes
  • Restart

开启代理,更新系统,安装常用软件,删除不需要的软件包

sudo su
export http_proxy=http://www-cache.uni-mannheim.de:3128
apt-get update
apt-get dist-upgrade
apt-get autoremove
apt-get install rcconf
apt-get install python-software-properties
add-apt-repository "deb http://archive.canonical.com/ lucid partner"
aptitude install sun-java6-jdk
apt-get remove ubuntu-docs
apt-get remove mysql-common
apt-get remove samba-common
apt-get clean
apt-get autoclean
apt-get autoremove
cat /etc/issue
vi /etc/hosts

在vi里添加设置

127.0.0.1 vm-ubuntu-build

为r和root用户配置top命令

top

添加nagios远程监测

apt-get install nagios-nrpe-server
vi /etc/nagios/nrpe.cfg

修改/添加

allowed_hosts=vmhost-ubuntu-vbox
command[check_all_disks]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -e
/etc/init.d/nagios-nrpe-server restart

避免意外删除文件等错误

vi /etc/bash.bashrc

在vi里添加以下几行:

confirm() {
echo -n "Please confirm $*? [N/y] "
read -N 1 REPLY
echo
if test "$REPLY" = "y" -o "$REPLY" = "Y"; then
"$@"
else
echo "Cancelled by user"
fi
}
alias rm="rm -i"
alias cp="cp -i"
alias mv="mv -i"
alias halt="confirm halt"
alias reboot="confirm reboot"
alias shutdown="confirm shutdown"

SSH设置

用PAM限制SSH用户

vi /etc/pam.d/sshd

在vi里写入

auth required pam_listfile.so item=user sense=allow file=/etc/ssh/ssh.allow onerr=fail

添加允许SSH的用户

vi /etc/ssh/ssh.allow

在vi里写入

r
vbox

设置10分钟后自动关闭空闲的SSH链接

vi /etc/ssh/sshd_config

添加以下几行:

ClientAliveInterval 300
ClientAliveCountMax 2
UseDNS no

为vm-ubuntu-build添加data盘

添加data盘(vmhost-ubuntu-vbox)

VBoxManage createhd --filename /opt/vbox/vm-ubuntu-build/vm-ubuntu-build-data.vdi --size 50000
VBoxManage storageattach vm-ubuntu-build --storagectl "SATA Controller" --port 1 --device 0 --type hdd --medium /opt/vbox/vm-ubuntu-build/vm-ubuntu-build-data.vdi
VBoxHeadless startvm vm-ubuntu-build

创建ext4分区

sudo su
parted -a optimal /dev/sdb
(parted) mklabel
(parted) mkpart primary ext4 1 100%
(parted) print
(parted) quit
mkfs.ext4 /dev/sdb1

添加到虚拟机的fstab里

ls -l /dev/disk/by-uuid
# uuid sdb1: e42e6040-0f94-4694-88cc-1a1d687cc48e
vi /etc/fstab
# add line: UUID=e42e6040-0f94-4694-88cc-1a1d687cc48e /opt ext4 defaults 0 0
mount -a

安装VirtualBox Additions增强功能

在vmhost-ubuntu-vbox上绑定VBoxGuestAdditions.iso:

su - vbox
VBoxManage storagectl vm-ubuntu-build --name "IDE Controller" --add ide
VBoxManage storageattach vm-ubuntu-build --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium /usr/share/virtualbox/VBoxGuestAdditions.iso

在vm-ubuntu-build上安装:

sudo su
mkdir /media/cdrom
mount /dev/cdrom1 /media/cdrom
apt-get install dkms
/media/cdrom/VBoxLinuxAdditions.run --nox11
# 忽略视窗错误:Installing the Window System drivers ...fail!
addgroup r vboxrf

(手动添加共享文件夹)

mkdir /media/vbox-shared
mount -t vboxsf vbox-shared /media/vbox-shared

删除IDE Controller

VBoxManage storagectl vm-ubuntu-build --name "IDE Controller" --remove

安装subversion

安装subversion

安装apache2,配置apache2

sudo su
apt-get install apache2
a2enmod proxy
a2enmod proxy_http
vi /etc/apache2/apache2.conf

添加/修改行:

ServerName localhost
Timeout 60
MaxKeepAliveRequests 10
StartServers 1
MinSpareServers 1
MaxSpareServers 1
MaxClients 10
vi /etc/apache2/conf.d/security

添加/修改行:

<Directory />
Options -Indexes
AllowOverride None
Order Deny,Allow
Deny from all
</Directory>
ServerTokens Prod
ServerSignature Off
TraceEnable Off

安装subversion

addgroup subversion
usermod -a -G subversion www-data
usermod -a -G subversion r
apt-get install subversion libapache2-svn
svnadmin create --fs-type fsfs /opt/svn/2cn.de
chown -R www-data.subversion /opt/svn
chmod -R 770 /opt/svn
htpasswd -c /etc/subversion/passwd kley

修改/etc/subversion/authz文件

[groups]
admins = kley
developers = kley
guests = kley
[/]
@admins = rw
@developers = r
[2cn.de:/]
@admins = rw
@developers = rw

修改/etc/apache2/mods-available/dav_svn.conf文件

<Location /svn>
DAV svn
SVNPath /opt/svn
AuthType Basic
AuthName "2cn.de repository"
AuthUserFile /etc/subversion/passwd
AuthzSVNAccessFile /etc/subversion/authz
Require valid-user
</Location>

配置记录文件

groupadd log
usermod -a -G log www-data
usermod -a -G log r
mkdir /opt/logs
mkdir /opt/logs/build
mkdir /opt/logs/apache2
mkdir /opt/logs/svn
rm -R /var/log/apache2
ln -s /opt/logs/apache2 /var/log/apache2
chown -R build.log /opt/logs
chmod -R g+w /opt/logs
chmod -R o-r /opt/logs
chmod -R o-x /opt/logs
vi /etc/logrotate.d/svn
/opt/logs/svn/*.log {
weekly
missingok
rotate 52
compress
delaycompress
notifempty
create 640 root adm
sharedscripts
postrotate
if [ -f "`. /etc/apache2/envvars ; echo ${APACHE_PID_FILE:-/var/run/apache2.pid}`" ]; then
/etc/init.d/apache2 reload > /dev/null
fi
endscript
}

配置ssl

a2enmod ssl

在/etc/apache2/ports.conf里加入以下行

<IfModule mod_ssl.c>
NameVirtualHost *:443
Listen 443
</IfModule>
apt-get install ssl-cert
mkdir /etc/apache2/ssl
chmod 600 /etc/apache2/ssl
vi /usr/share/ssl-cert/ssleay.cnf

修改default_bits值

default_bits = 8192
/usr/sbin/make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/vm-ubuntu-build_apache.pem

安装websvn

apt-get install websvn
# 选择apache2作为服务器
# svn文件夹:/opt/svn/2cn.de

清空/etc/apache2/mods-available/dav_svn.conf里的内容
添加到/etc/apache2/sites-available/websvn文件里

<VirtualHost *:443>
ServerAdmin webmaster@localhost
Alias /websvn /usr/share/websvn
<Directory /usr/share/websvn>
DirectoryIndex index.php
Options FollowSymLinks
Order allow,deny
Allow from all
AuthType Basic
AuthName "2cn.de WebSVN Subversion Repository"
Require valid-user
AuthUserFile /etc/subversion/passwd
<IfModule mod_php4.c>
php_flag magic_quotes_gpc Off
php_flag track_vars On
</IfModule>
</Directory>
<Location /svn/2cn.de>
Order allow,deny
Allow from all
DAV svn
SVNPath /opt/svn/2cn.de
AuthType Basic
AuthName "2cn.de repository"
AuthUserFile /etc/subversion/passwd
AuthzSVNAccessFile /etc/subversion/authz
Require valid-user
</Location>
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/vm-ubuntu-build_apache.pem
SSLProtocol all
SSLCipherSuite HIGH:MEDIUM
ErrorLog /opt/logs/svn/error.log
LogLevel error
CustomLog /opt/logs/svn/access.log combined
</VirtualHost>

清除/etc/websvn/apache.conf里的所有行
在/etc/websvn/svn_deb_conf.inc里更改2cn.de的标题

a2ensite websvn

SVN备份

创建备份文件夹,配置备份脚本

mkdir /opt/backup
mkdir /opt/build/scripts
vi /opt/build/scripts/svn_2cnde_full-backup.sh
#! /bin/sh
svnadmin dump /opt/svn/2cn.de > /tmp/svn_2cnde_full-backup.dump
rm -f /opt/backup/svn_2cnde_full-backup.dump
cp /tmp/svn_2cnde_full-backup.dump /opt/backup/svn_2cnde_full-backup.dump
chmod +x svn_2cnde_full-backup.sh
vi /opt/build/scripts/svn_2cnde_inc-backup.sh
#!/usr/bin/perl
use strict;
use warnings;
my $repo = '/opt/svn/2cn.de';
my $local_dir = '/tmp';
my $savedir = '/opt/backup';
my $last_saved_file = $savedir.'/last_saved.txt';
open(LAST_SAVED, '<', $last_saved_file);
my $last_saved = <LAST_SAVED>;
chomp $last_saved;
close(LAST_SAVED);
my $head = `svnlook youngest $repo`;
chomp $head;
if ($last_saved == $head) {
exit();
}
my $from = $last_saved + 1;
my $to = $head;
my $dumpfile = sprintf(
'/svn-%05u_%05u.svndump',
$from,
$to
);
my $local_dump_file = $local_dir.$dumpfile;
my $command = sprintf(
'svnadmin dump -q -r%u:%u --incremental %s > %s',
$from,
$to,
$repo,
$local_dump_file
);
system($command);
if (grep /^Revision-number: $to/, `grep --text ^Revision-number: $local_dump_file`) {
open(LAST_SAVED, '>', $last_saved_file);
print LAST_SAVED $to, "\n";
close(LAST_SAVED);
system('gzip '.$local_dump_file);
chdir($local_dir);
use File::Basename;
system('md5sum '.basename($local_dump_file).'.gz >> '.$savedir.'/MD5SUMS');
}
my $mv_command = sprintf(
'mv %s %s',
$local_dump_file.'.gz',
$savedir.$dumpfile.'.gz'
);
system($mv_command);
chmod +x /opt/build/scripts/svn_2cnde_inc-backup.sh
crontab -e
0 1 * * * /opt/build/scripts/svn_2cnde_inc-backup.sh
0 2 1 * * /opt/build/scripts/svn_2cnde_full-backup.sh

安装tomcat

apt-get install tomcat6 tomcat6-user
apt-get install libtcnative-1
apt-get install sun-java6-jdk
update-alternatives --config java
update-alternatives --config javac
# 选择/usr/lib/jvm/java-6-sun/jre/bin/java
apt-get remove openjdk-6-jdk
apt-get remove openjdk-6-jre
apt-get remove openjdk-6-jre-headless
apt-get remove openjdk-6-jre-lib
update-rc.d -f tomcat6 remove
adduser --system --shell /bin/sh --gecos 'build user' --group --disabled-password --home /opt/build build
cd /opt/build
su - -c "tomcat6-instance-create tomcat" build
usermod -a -G build tomcat6
usermod -a -G log tomcat6
usermod -a -G log build
usermod -a -G build r
rm -R /var/log/tomcat6
ln -s /opt/logs/build /var/log/tomcat6
ln -s /etc/tomcat6/policy.d /opt/build/tomcat/conf/policy.d
vi /etc/logrotate.d/build
/var/log/tomcat6/*.log {
copytruncate
daily
missingok
rotate 30
compress
delaycompress
missingok
size 10M
}
chown -R build.build /opt/build

修改/etc/default/tomcat6

TOMCAT6_USER=build
TOMCAT6_GROUP=build
JAVA_HOME=/usr/lib/jvm/java-6-sun
CATALINA_BASE=/opt/build/tomcat
JAVA_OPTS="${JAVA_OPTS} -server -DHUDSON_HOME=/opt/build/hudson-work -Djava.awt.headless=true -Xmx512M -Xms512M -XX:MaxPermSize=128m -XX:+UseParallelOldGC -XX:+DisableExplicitGC -XX:+UseCompressedOops -XX:+AggressiveOpts -XX:NewRatio=2 -XX:+UseCompressedStrings -XX:+UseStringCache -XX:+OptimizeStringConcat"
JAVA_OPTS="${JAVA_OPTS} -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8888 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false"
export LD_LIBRARY_PATH=/usr/lib:$LD_LIBRARY_PATH

修改/opt/build/tomcat/conf/server.xml

<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000"
URIEncoding="UTF-8" redirectPort="8443"
compression="off" acceptCount="10" maxKeepAliveRequests="10"
minSpareThreads="4" maxSpareThreads="4" maxThreads="4"/>

添加到/etc/tomcat6/policy.d/04webapps.policy里

grant codeBase "file:/opt/build/hudson-work/-" {
permission java.security.AllPermission;
permission java.io.FilePermission "/opt/build/hudson-work/-", "read,write,delete";
permission java.io.FilePermission "/opt/build/tomcat/webapps/hudson/-", "read,write,delete";
};
grant codeBase "file:/opt/build/tomcat/webapps/hudson/-" {
permission java.security.AllPermission;
permission java.io.FilePermission "/opt/build/hudson-work/-", "read,write,delete";
};
grant codeBase "file:/opt/build/sonatype-work/-" {
permission java.security.AllPermission;
permission java.io.FilePermission "/opt/build/sonatype-work/-", "read,write,delete";
permission java.io.FilePermission "/opt/build/tomcat/webapps/nexus/-", "read,write,delete";
};
grant codeBase "file:/opt/build/tomcat/webapps/nexus/-" {
permission java.security.AllPermission;
permission java.io.FilePermission "/opt/build/sonatype-work/-", "read,write,delete";
};
update-rc.d tomcat6 defaults
mkdir /opt/build/webapps
chown -R build.log /opt/logs
chown -R build.build /opt/build
chmod -R o-r /opt/build
chmod -R o-x /opt/build
chmod -R g+w /opt/build
chmod -R g+w /opt/logs
chmod -R o-r /opt/logs
chmod -R o-x /opt/logs

安装nexus

cd /opt/build/webapps
wget http://nexus.sonatype.org/downloads/nexus-webapp-1.9.0.1.war
ln -s /opt/build/webapps/nexus-webapp-1.9.0.1.war /opt/build/tomcat/webapps/nexus.war
su - build
mkdir /opt/build/.m2
vi /opt/build/.m2/settings.xml
<settings>
<mirrors>
<mirror>
<!--This sends everything else to /public -->
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url></url>
</mirror>
</mirrors>
<profiles>
<profile>
<id>nexus</id>
<!--Enable snapshots for the built in central repo to direct -->
<!--all requests to nexus via the mirror -->
<repositories>
<repository>
<id>central</id>
<url></url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url></url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<!--make the profile active all the time -->
<activeProfile>nexus</activeProfile>
</activeProfiles>
</settings>
  • 在浏览器里键入http://<vm-ubuntu-build>:8080/nexus
  • 登录admin账户:用户名:admin,密码:admin123
  • 在Security里修改admin和deployment用户的密码,邮件及其他信息
  • 创建索引:
    • 选择Repositories
    • 在Maven Central的Configuration里把Download Remote Indexes改为True, 在Mirrors里添加http://uk.maven.org/maven2
    • 在Google Code, Codehaus Snapshots和java.net的Configuration里把Download Remote Indexes改为True
  • nexus配置
    • SMTP Settings
      • SMTP Settings: mail.gmx.net:465, SSL/TLS, Normal Password

安装hudson

apt-get install maven2
apt-get install ant ant-optional junit
cd /opt/build/webapps
wget http://java.net/projects/hudson/downloads/download/war/hudson-1.396.war
ln -s /opt/build/webapps/hudson-1.396.war /opt/build/tomcat/webapps/hudson.war
vi /opt/build/tomcat/bin/setenv.sh
export HUDSON_HOME=/opt/build/hudson-work
export MAVEN_HOME=/usr/share/maven2
export ANT_HOME=/usr/share/ant
  • hudson设置
    • sign up => 创建*admin*用户
    • Manage Hudson => Configure System => # of executors = 1
    • Manage Hudson => Configure System => Enable Security
      • 取消*Allow users to sign up*
      • Security Realm => Hudson’s own user database
      • Authorization => Matrix-based security
      • 加入admin => 为admin加入所有权限
      • 取消Anonymous的所有权限
      • 取消Help make Hudson better by …

安装Apache2代理

a2enmod proxy
a2enmod proxy_http
vi /etc/apache2/sites-available/default

添入以下行:

<IfModule mod_proxy.c>
ProxyPreserveHost On
ProxyPass         /hudson  http://localhost:8080/hudson
ProxyPassReverse  /hudson  http://localhost:8080/hudson
<Proxy http://localhost:8080/hudson/*>
Order deny,allow
Allow from all
</Proxy>
<Location /hudson>
Order deny,allow
Allow from all
</Location>
ProxyPass        /nexus    http://localhost:8080/nexus
ProxyPassReverse /nexus    http://localhost:8080/nexus
<Proxy http://localhost:8080/nexus/*>
Order deny,allow
Allow from all
</Proxy>
<Location /nexus>
Order deny,allow
Allow from all
</Location>
</IfModule>

设置固定IP

vi /etc/network/interfaces

删除dhcp设置

auto eth0
iface eth0 inet dhcp

添加IP设置

auto  eth0
iface eth0 inet static
address 192.168.178.111
netmask 255.255.255.0
network 192.168.178.0
broadcast 192.168.178.255
gateway 192.168.178.1
vi /etc/resolv.conf
search vm.2cn.de
domain vm.2cn.de
nameserver 192.168.178.1
nameserver 134.155.96.53
vi /etc/hosts
127.0.0.1 vm-ubuntu-build
127.0.0.1 vm-ubuntu-build.vm.2cn.de
192.168.168.11 vmhost-ubuntu-vbox
192.168.168.11 vmhost-ubuntu-vbox.2cn.de
/etc/init.d/networking restart

卸载dhcp

apt-get remove dhcp-client3

TODOs

Java编程环境安装(win32)

Java编程环境安装(win32)

  • 注意:以下软件中必须使用相同的svn版本(如:TortoiseSVN, svn, Subversive)

Oracle JDK

Subversion Client

  • TortoiseSVN下载网站:http://tortoisesvn.net/downloads.html
    • 下载TortoiseSVN-1.6.12.20536-win32-svn-1.6.15.msi
    • 安装TortoiseSVN
  • SVN下载网站:
    • 安装SVN并把SVN的位置加入进PATH环境函数中

SpringSource Tool Suite (Eclipse)

STS-Eclipse设置

  • 添加以下插件
    • Help => Install new software => Eclipse Marketplace
    • Help => Eclipse Marketplace
      • Subclipse
    • FindBugs Eclipse Plugin
      • EclEmma Java Code Coverage
      • Checkstyle Plug-in
      • Jadclipse
    • dot4zest
      • (WikiText)
  • 设置
    • General => 选择*Show heap status*
    • General => Content Types => Text => Default encoding = UTF-8 => 点击 Update
    • General => Editors => Text Editors => Undo history size = 2000
    • General => Editors => Text Editors => 选择 Insert spaces for tabs
    • General => Editors => Text Editors => 选择 Show line numbers
    • General => Editors => Text Editors => Spelling => 关闭 Enable spell checking
    • General => Startup and Shutdown => 关闭 Atlassian Connector, Roo Integration, Mylyn Tasks, Mylyn Team
    • General => Workspace => 关闭 Build automatically
    • General => Workspace => Text file encoding => Other = UTF-8
    • General => Workspace => New text file line delimiter => Other = Unix
    • General => Workspace => Days to keep files = 28
    • General => Workspace => Maximum entries per file = 1500
    • General => Workspace => Maximum file size (MB) = 32
    • Ant => Editor => Formatter => 关闭 Use tab character instead of spaces
    • Ant => Editor => Formatter => Maximum line width (characters) = 160
    • Ant => Editor => Formatter => 选择 Wrap long element tags
    • Data Management => SQL Development => Execution Plan View Options => Export encoding = UTF-8
    • Install/Update => 选择 Show all versions of available software
    • Java => Code Style => Clean Up => 导入 %SCM%/etc/conf/eclipse/java_code-style_clean-up_profile.xml
    • Java => Code Style => Code Templates => 导入 %SCM%/etc/conf/eclipse/java_code-style_code-templates.xml
    • Java => Code Style => Formatter => 导入 %SCM%/etc/conf/eclipse/java_code-style_formatter_profile.xml
    • Java => Code Style => Organize Imports => 导入 %SCM%/etc/conf/eclipse/java_code-style_import-order.importorder
    • Java => Compiler => Errors/Warnings
      • Code style: 把除Non-externalized strings以外所有的选项设置为 Warning
      • Potential programming problems: 把所有的选项设置为 Warning
      • Name shadowing and conflicts: 把所有的选项设置为 Warning
    • Java => Compiler => Javadoc => 把所有的选项设置为 Warning
    • Java => Debug => Debugger timout = 30000
    • Java => Debug => Launch timout = 60000
    • Java => Editor => 选择 Light bulb for quick assists
    • Java => Editor => Save Actions => 启用 Perform the selected actions on save*并选择 *Organize imports
    • Java => Editor => Typing => 选择 Semicolons, Braces*和 *Escape text when pasting into a string literal
    • JavaScript => Code Style => 选择 Automatically add comments for new functions and types
    • JavaScript => Code Style => Clean Up => 导入 %SCM%/etc/conf/eclipse/javascript_code-style_clean-up_profile.xml
    • JavaScript => Code Style => Code Templates => 导入 %SCM%/etc/conf/eclipse/javascript_code-style_code-templates.xml
    • JavaScript => Code Style => Formatter => 导入 %SCM%/etc/conf/eclipse/javascript_code-style_formatter_profile.xml
    • JavaScript => Editor => 选择 Light bulb for quick assist
    • JavaScript => Editor => Typing => 选择 Semicolons, Braces*和 *Escape text when pasting into a string literal
    • JavaScript => Validator => Errors/Warinings => 启用 Enable JavaScript semantic validation
    • Maven => 选择 Debug Output, Download Artifact Sources, Download Artifact JavaDoc
    • Maven => Installations => 添加 %JAVA_DEV_ENV%\maven-<VERSION>
    • Maven => Installations => 设置 Global settings = %SCM%/etc/conf/eclipse/maven_global_settings.xml
    • Maven => POM Editor => 选择 Show advanced tabs in the POM Editor
    • Remote Systems => Files => 选择 Show hidden files
    • Run/Debug => Console
      • Fixed width console = 160
      • Console buffer size = 1000000
      • Displayed tab width = 4
    • Run/Debug => Launching
      • 取消 Remove terminated launches when a new launch is created
      • 选择 Always launch the previously launched application
    • Server => Launching => 取消 Automatically publish when starting servers
    • Spring => Dashboard => 取消 Show Dashboard On Startup
    • Spring => User Agent Analysis => 选择 Disable UAA
    • Tasks => Synchronization => 取消 Synchronize with repositories
    • Team => 选择 Show all synchronization information
    • Team => SVN => 选择 show revision comparisons
    • Java => FindBugs => analysis effort = maximum
    • Terminal
      • Terminal buffer lines = 1000000
      • Serial timeout = 30
      • Network timeout = 30
    • Web => CSS Files => Encoding = UTF-8
    • Web => CSS Files => Editor
      • Line width = 160
      • 选择 Indent using spaces
      • Indentation size = 4
    • Web => HTML Files => Encoding = UTF-8
    • Web => HTML Files => Editor
      • Line width = 160
      • 选择 Align final bracket
      • 选择 Indent using spaces
      • Indentation size = 4
    • Web => JSP Files => Encoding = UTF-8
    • XML => XML Files => Editor
      • Line width = 160
      • 取消 Join lines
      • 选择 Indent using spaces
      • Indentation size = 4
    • XML => XML Files => Validation => 选择 Enable markup validations

我的文件夹备份计划

我的文件夹备份计划

记录时间:2011-02-18

母备份脚本

  • 设定全局函数
  • 把之前的备份复制到指定的文件夹
  • 运行子备份计划
  • 文件名:backup-parent.bat
    • MY_HOME:我的文件夹所在地
ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

REM == configuration ==
ECHO Reading configuration ...
SET backup_scripts=%MY_HOME%\scripts\backups
SET old_target_dir=D:\backup\2cn.de_old
REM == global configuration ==
SET excluded_dirs=.svn,*.bak,target,.metadata,.settings
SET excluded_files=*.bak,*.log,.classpath,.project
REM SET target_dir=d:\backup
SET target_dir=D:\backup\2cn.de
REM SET packer_cmd=%ProgramFiles%\7-Zip\7z.exe
SET packer_cmd=%MY_HOME%\tools\LiberKey\Apps\7Zip\App\7-Zip\x86\7z.exe
SET packer_opts=-p=yun a  -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on
SET date_delimeter=.
SET temp_dir=%TEMP%\backup

REM == validation ==
ECHO Validating configuration  ...
IF NOT EXIST "%packer_cmd%" (
  ECHO No packer found in the location: %packer_cmd%
  GOTO end
)

REM == moving old backups ==
ECHO Moving old backups to OLD folder ...
IF EXIST "%target_dir%" (
  IF EXIST "%old_target_dir%" DEL /f /s /q "%old_target_dir%"\*.*
  MKDIR "%old_target_dir%"
  MOVE /y %target_dir%\*.* %old_target_dir%\
)

REM == running child backups ==
ECHO Running child backup scripts ...
FOR /f "delims=" %%A IN ('dir /s/b/a-d %backup_scripts%\*.bat') DO (
  SET current_backup=%%~A
  ECHO - running !current_backup! ...
  START "!DO NOT CLOSE! Running !current_backup! ... " /belownormal /wait !current_backup!
  ECHO - !current_backup! done
)
ECHO Done running child backups

:end
DATE /t
TIME /t

ENDLOCAL

子备份脚本

  • 检查环境设定
  • 复制备份文件到临时文件夹
  • 删除不需要备份的文件夹及文件
  • 压缩临时文件夹到指定位置
  • 删除临时文件夹
ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION


REM == configuration ==
ECHO Reading configuration ...
SET backup_name=
SET backup_dirs=
REM == project specific configuration (overwrites globals) ==
IF "%target_dir%"=="" SET target_dir=d:\backup\2cn.de
IF "%packer_cmd%"=="" SET packer_cmd=%MY_HOME%\tools\LiberKey\Apps\7Zip\App\7-Zip\x86\7z.exe
IF "%packer_opts%"=="" SET packer_opts=-p=yun a -tzip -r -mx5
IF "%date_delimeter%"=="" SET date_delimeter=.
IF "%temp_dir%"=="" SET temp_dir=%TEMP%\backup

REM == validation ==
ECHO Validating configuration  ...
ECHO backup_name=%backup_name%
ECHO bakcup_dirs=%backup_dirs"
ECHO target_dir=%target_dir%
ECHO packer_cmd=%packer_cmd%
ECHO packer_opts=%packer_opts%
ECHO date_delimeter=%date_delimeter%
ECHO temp_dir=%temp_dir%
IF NOT EXIST "%packer_cmd%" (
  ECHO No packer found in the location: %packer_cmd%
  GOTO end
)
FOR %%A IN (%backup_dirs%) DO (
  SET current_dir=%%~A
  IF NOT EXIST "!current_dir!" (
    ECHO Check backup_dirs configuration. Backup directory "!current_dir!" doesn't exist!
  )
)

REM == initialization ==
ECHO Initialializing ...
FOR /f "tokens=1,2,3 delims=%date_delimeter% " %%a IN ('date /t') DO (
  SET current_date=%%c%%b%%a
)
FOR /f "tokens=1,2 delims=: " %%a IN ('time /t') DO (
  SET current_time=%%a%%b
)
SET file_ts=%current_date%%current_time%


REM == preparation ==
ECHO Preparing temporary snapshot ...
IF NOT EXIST "%temp_dir%" MKDIR "%temp_dir%"
FOR %%A IN (%backup_dirs%) DO (
  SET current_dir=%%~A
  ECHO - copying !current_dir! ...
  SET dest_dir=%temp_dir%\!current_dir:~0,1!%%~pnxA
  XCOPY "!current_dir!" "!dest_dir!" /v /c /i /g /h /q /r /y /e
)

REM == assembly ==
ECHO  Packaging ...
SET target_output=%target_dir%\%backup_name%_%file_ts%.zip
ECHO Target output name is %target_output%
IF EXIST "%target_output%" DEL /f /q "%target_output%"
START "!DO NOT CLOSE! Compressing ... " /belownormal /wait "%packer_cmd%" %packer_opts% "%target_output%" "%temp_dir%\*"
ECHO Done compressing backed up files



REM == cleanup ==
ECHO Cleaning up ...
IF EXIST "%temp_dir%" RMDIR /s /q "%temp_dir%"

:end
TIME /t

ENDLOCAL 
 
EXIT 0

设置定时任务计划

  • 任务开始:开机后在电脑空闲30分钟的情况下启动备份计划

PPS无广告启动器

PPS无广告启动器

记录时间:2011-03-16

安装过程

  1. 正常安装PPStream
  2. 下载GreenPPS并解压缩到随意一个文件夹里
  3. 双击pps_noads_launcher

启动器原理

去除广告方法

去除PPS广告可采用不同的方法

  • 使用专门的DNS屏蔽广告网站
    • 例如使用dnsmasq网络名服务器软件
  • 修改hosts文件屏蔽广告网站
    • PPS会自动修改hosts文件。使用这个方法必须用360或者其他软件保护hosts文件,免遭它被PPS修改。
  • 使用Proxy屏蔽广告网站
    • 例如使用Apache Proxy+Rewrite或者Fiddler2 Rules
  • 修改PPS主程序
    • 例如跳过广告部分,去除Flash支持,模拟高级会员
    • 网上有个别绿色PPS版本下载。缺点是不能更新而且需要考虑安全性方面的问题。
  • 删除并锁定PPS广告文件夹。
    • 例如GreenPPS。
GreenPPS

GreenPPS的原理很简单。它本身只是由两行Batch脚本所组成:

@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION

REM == delete all pps ads directories ==
RMDIR /s /q "%APPDATA%\PPStream\banner"
ECHO banner >> "%APPDATA%\PPStream\banner"
RMDIR /s /q "%APPDATA%\PPStream\adsys"
ECHO adsys >> "%APPDATA%\PPStream\adsys"

REM == detect ppstream director ==
SET pps_dirs="%ProgramFiles%",C:\PPS.tv,D:\PPS.tv

FOR %%A IN (%pps_dirs%) DO (
  SET pps_cmd="%%~A\PPStream\PPStream.exe"
  IF EXIST "!pps_cmd!" (
    START "PPStream" /MAX /WAIT "!pps_cmd!" >> %APPDATA%\PPStream\adsys
    GOTO end
  )
)

:end

ENDLOCAL 
PAUSE
  1. 删除PPS广告文件夹
  2. 启动并PPS并锁定广告文件夹
运行先提条件

主要运行条件是PPS程序在不能创建广告文件夹的情况下仍可正常运行。(PPS到最新的版本为止都可以正常运行。)

系统备份

系统备份

记录时间:2011-03-01

Clonezilla备份盘

  1. 启动盘:partedmagic: pmagic-5.10.iso
  2. 启动后删除/bin/pigz的链接
    • rm /bin/pigz

备份分区

  1. 使用Clonezilla备份硬盘分区
    • 选择device-image
    • 选择local_dev
    • 按Enter键
    • 选择用作储存备份的分区:例如sdc1
    • 选择/作为储存备份的文件夹
    • 按Enter键
    • 选择Beginner
    • 选择saveparts
    • 存储文件名:例如win7-2011-02-28-img
    • 选择要备份的分区:例如sda3(win7)
    • 在注释里写入日期,系统以及分区号
    • 写入y确定,然后按Enter键
  2. 把备份文件夹归类:例如复制到G:\system\samsung_r540\win7-2011-02-28-img

还原分区

  1. 将需要还原的系统备份文件夹移到分区最外面:例如把win7备份文件夹复制到G:\win7-2011-02-28-img
  2. 启动Clonezilla
    • 选择device-image
    • 选择local_dev
    • 按Enter键
    • 选择用作储存备份的分区:例如sdc1
    • 选择/作为需要备份文件夹所在地
    • 选择win7备份文件夹还原分区
    • 写入两次y确定开始还原