Backup and recover your boot sector
2008年11月14日 21:36 | Comments(0) | Category:Linux | Tags:linux system backup grub
You can can use rsync for remote backups and tar or dd for local backups to backup your file system, however, there aren't as many options for backuping the boot sector. But, having a backup of your boot sector is equally important in the events of system crash. Fortunately, dd tool does this work perfectly.
Grub and Lilo, or any other boot loader, generally installed ot the boot sector of your boot disc. After you have installed or modified your boot sector and verified that whether it works, back it up by writting it to a file on your hard driver:
for IDE driver:
for SCSI driver:
or you can write it to a floppy disk directly:
Make sure that you use the right source and destination, if you mistakely write the a file or the floppy to your boot driver when you make a backup, you'll damage your boot sector and won't enable to boot.
Now, if there has any error on your boot sector, you can restore rapidly from these images backuped previously by reversing the "if" and "of" destination:
if it stored on a floppy disk, use following command:
relatively, if the driver is a SCSI disk, substitute sda for hda.
Gentoo中文UTF-8设置及美化
2008年11月05日 19:34 | Comments(2) | Category:Linux | Tags:gentoo linux fvwm 中文
原帖在这里,为简化期间,只贴出简略的步骤和配置文件。
一、安装基本系统
依照Gentoo的安装手册进行安装,安装手册的地址点击这里。我选择的是AMD64。这里要非常感谢gentoo中文文档组的成员。由于我的硬盘没有光驱,所以在安装的时候需要从老的linux系统启动,然后使用chroot命令切换到新的系统下。下面使我的硬盘使用情况:
/dev/hda --- 原来老的linux系统(因为硬盘摔了一下,经常丢东西,所以要重装系统)。
/dev/hdc --- 目前要安装的linux所在硬盘。
/dev/sda --- 我的SATA硬盘,安装的是MS XP系统。
这是我的/etc/make.conf和/etc/locale.gen文件
代码:
# Please consult /etc/make.conf.example for a more detailed example
CFLAGS="-march=athlon64 -O3 -pipe -ftracer -funit-at-a-time -fforce-addr -fpeel-loops -funswitch-loops"
CHOST="x86_64-pc-linux-gnu"
LDFLAGS="-Wl,-O1 -Wl,--enable-new-dtags -Wl,--sort-common -Wl,--strip-all"
CXXFLAGS="${CFLAGS} -fvisibility-inlines-hidden"
CBUILD="x86_64-pc-linux-gnu"
MAKEOPTS="-j2"
ACCEPT_KEYWORDS="amd64"
GENTOO_MIRRORS="http://61.135.158.199 ftp://ftp.sjtu.edu.cn/sites/gentoo ftp://gg3.net/pub/linux/gentoo"
SYNC="rsync://61.135.158.199/gentoo-portage"
#
# USE
USE="-midi -ipv6 -doc svga linguas_zh_CN fbcon 3dnow aac font-server bash-completion amd64 X lcms mmx sse gtk gtk2 -gnome nls -qt -kde alsa -cups cjk -dvd -dvdr -debug aalib jpeg wmf mng svg png mpeg truetype opengl stroke -xinerama -joysticks readline lm_sensors quicktime xv xvid bzip2 acc ftp python xml libcaca xvmc nvidia unicode -no-old-linux tiff symlink encode gif sdl imlib chardet mp3 wma real srt msn qq preview-latex fontconfig xpm a52 -emacs -xemacs -latex ggi gd pdf plotutils -berkdb"
#
# Other
AUTOCLEAN=yes
LINGUAS="zh_CN"
LANG="zh_CN"
#DISDIR=
#FEATURES="ccache confcache"
CCACHE_SIZE="2G"
CCACHE_DIR="/var/tmp/cache"
VIDEO_CARDS="nvidia"
ALSA_CARDS="intel8x0"
#PORTDIR_OVERLAY=/usr/local/portage
source /usr/portage/local/layman/make.conf
INPUT_DEVICES="mouse keyboard"
en_US ISO-8859-1
en_US.UTF-8 UTF-8
zh_CN GB2312
zh_CN.GBK GBK
zh_CN.GB18030 GB18030
zh_CN.UTF-8 UTF-8
zh_HK BIG5-HKSCS
zh_HK.UTF-8 UTF-8
zh_TW BIG5
zh_TW.UTF-8 UTF-8
调整/boot/grub/grub.conf文件
timeout 30
#splashimage=(hd0,0)/boot/grub/self1.xpm.gz
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
# /dev/hda的老linux系统
title Gentoo Linux (HDA)
root (hd0,0)
kernel /kernel-2.6.16-gentoo-r7 root=/dev/hda6 video=vesafb:1024x768@75,mtrr,ywrap vga=0x318 splash=silent,fadein,theme:sexy CONSOLE=/dev/tty1
initrd /fbsplash-penn
# 新安装的Gentoo系统。
title Gentoo Linux (HDC)
root (hd1,0)
kernel /kernel-2.6.23-gentoo-r3 root=/dev/hdc6 video=vesafb:1024x768@75,mtrr,ywrap vga=0x318
#这里为XP的启动提供通道
title Window XP
map (hd0) (hd2)
map (hd2) (hd0)
rootnoverify (hd2,0)
makeactive
chainloader +1
使用emerge安装的字体:
/usr/share/font/local目录下.
我拷贝的字体有:SimSun-Bold.ttf,SimSun-BoldItalic.ttf,SimSun-Italic.ttf,mingliu.ttc,msyh.ttf,msyhbd.ttf,tahoma.ttf,tahomabd.ttf等。
2. 设置x核心字体
# ttmkfdir
# cp fonts.scale fonts.dir
FontPath "/usr/share/fonts/local/"
FontPath "/usr/share/fonts/ttf-bitstream-vera/"
FontPath "/usr/share/fonts/wqy-bitmapfont"
FontPath "/usr/share/fonts/wqy-zenhei/"
应为/usr/share/fonts是xft自动搜索目录,所以不需要另外设置,只需要修改好fontconfig文件即可。下面是草兄的配置,放到/etc/fonts/local.conf,不建议直接编辑/etc/font.conf文件
<fontconfig>
<alias>
<family>serif</family>
<prefer>
<family>Bitstream Vera Serif</family>
<family>Microsoft Yahei</family>
<family>DejaVu Serif</family>
<family>AR PL ShanHeiSun Uni</family>
<family>WenQuanYi Bitmap Song</family>
<family>AR PL ZenKai Uni</family>
</prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer>
<family>Bitstream Vera Sans</family>
<family>Microsoft Yahei</family>
<family>DejaVu Sans</family>
<family>AR PL ShanHeiSun Uni</family>
<family>WenQuanYi Bitmap Song</family>
<family>AR PL ZenKai Uni</family>
</prefer>
</alias>
<alias>
<family>monospace</family>
<prefer>
<family>Bitstream Vera Sans Mono</family>
<family>Microsoft Yahei</family>
<family>DejaVu Sans Mono</family>
<family>AR PL ShanHeiSun Uni</family>
<family>WenQuanYi Bitmap Song</family>
<family>AR PL ZenKai Uni</family>
</prefer>
</alias>
<match target="font" >
<edit name="rgba" mode="assign">
<const>none</const>
</edit>
<edit mode="assign" name="antialias" >
<bool>true</bool>
</edit>
<edit mode="assign" name="autohint" >
<bool>false</bool>
</edit>
<edit name="hinting">
<bool>true</bool>
</edit>
<edit name="hintstyle" mode="assign" >
<const>hintmedium</const>
</edit>
</match>
<match target="font" >
<test name="family" compare="contains" >
<string>Song</string>
<string>Sun</string>
<string>Kai</string>
<string>Ming</string>
</test>
<test name="weight" compare="less_eq">
<int>100</int>
</test>
<test compare="more_eq" target="pattern" name="weight" >
<int>180</int>
</test>
<edit mode="assign" name="embolden" >
<bool>true</bool>
</edit>
</match>
<match target="font" >
<test name="family" compare="contains" >
<string>Song</string>
<string>Sun</string>
<string>Kai</string>
<string>Ming</string>
</test>
<edit name="globaladvance">
<bool>false</bool>
</edit>
<edit name="spacing">
<int>0</int>
</edit>
<edit name="hinting">
<bool>true</bool>
</edit>
<edit name="autohint">
<bool>false</bool>
</edit>
<edit name="antialias" mode="assign">
<bool>true</bool>
</edit>
<test name="pixelsize" compare="less_eq">
<int>18</int>
</test>
<edit name="antialias" mode="assign" >
<bool>false</bool>
</edit>
</match>
<match target="font" >
<test name="family" compare="contains" >
<string>Microsoft Yahei</string>
</test>
<edit name="globaladvance">
<bool>false</bool>
</edit>
<edit name="spacing">
<int>0</int>
</edit>
</match>
</fontconfig>
4. 用户字体设置及编码
设置字体,我使用gtk,所以只设置了gtkrc文件,.gtkrc-2.0文件
{
font_name = "Verdana, Microsoft YaHei 12"
}
widget_class "*" style "user-font"
gtk-theme-name="MacOS-X"
gtk-icon-theme-name="MacOS-X"
#
# Setup locale
export GDK_USE_XFT=1
export C=zh_CN.utf8
export LC_CTYPE=zh_CN.utf8
#export LC_ALL=zh_CN.utf8
# Setup scim IM
LANG=zh_CN.utf8 scim -d
export XMODIFIERS="@im"="SCIM"
export GTK_IM_MODULE="scim"
export QT_IM_MODULE="scim"
exec fvwm 2>.fvwm.log
如果使用xdm登录,需要修改.Xclients
代码:
#
# Setup locale
export GDK_USE_XFT=1
#
export LC_CTYPE=zh_CN.utf8
# if you want to zh_CN, open the 2 optionals
#export LC_ALL=zh_CN
#LC_ALL includes all of following 6 options
#export LC_TIME=zh_CN
#export LC_NUMERIC=zh_CN
export LC_NOMETAEY=zh_CN.utf8
export LC_MESSAGES=zh_CN.utf8
export LC_COLLATE=zh_CN.utf8
export C=zh_CN.utf8
#
# Setup fcitx IM
#export XMODIFIERS="@im=fcitx"
#export XIM=fcitx
#export XIM_PROGRAM=fcitx
#exec fcitx &
#
# Setup scim IM
LANG=zh_CN.utf8 scim -d
export XMODIFIERS="@im"="SCIM"
export GTK_IM_MODULE="scim"
export QT_IM_MODULE="scim"
#exec conky &
exec fvwm 2>.fvwm.log
#exec starte16
进入fvwm后,发现原来gb2312文件中中文都是乱码,所以需要进行编码转换,编码转换使用iconv程序,没有这个程序的需要emerge
由于iconv默认输入到终端,所以要需要文件重定向。-f (from) -t (to)
设置好后就可以显示中文了。
完毕。
效果图: