一个echo的填空题,大家做做,看你是否是老鸟,引出重定向问题。
来自:
http://linux.chinaunix.net/bbs/viewthread.php?tid=1159718&extra=&page=1
请各位先动脑想答案,别一下子就上机做答案,那样就没意思了。题目很简单,就是echo和cat。请大家读操作填空吧:
[lk@localhost ~]$ touch file1 file2
[lk@localhost ~]$ echo 1 > file1
[lk@localhost ~]$ echo 2 > file2
[lk@localhost ~]$ echo file1 file2
____第一题_____
[lk@localhost ~]$ echo 3 > file1 file2
[lk@localhost ~]$ cat file1
____第二题_____
[lk@localhost ~]$ cat file2
____第三题_____
答案刮奖区,选中刮开。:)
第一题:file1 file2
第二题:3 file2 //echo 3 > file1 file2 等效于 echo 3 file2 > file1 吧,所以应该没输出。
第三题:2
这里我碰到个问题,开始脑子浆糊没想到。
echo 2 > file2 和 echo 2> file2 是不一样的.
其实说破很简单。
echo 2 > file2 是把2定向到file2.
echo 2> file2 是把错误重订定向到file2,所以file2是空的。
2010年7月28日星期三
2010年7月23日星期五
irssi配合bitlbee,终端上msn,gtalk
irssi配合bitlbee,终端上msn,gtalk
今天想从rpmforge源安装有冲突,急用就先用源代码来安装。
从源代码安装:
./configure --prefix=/ --bindir=/bin --ssl=openssl
make install-etc
配置bitlee可以和xinetd配合,在/etc/xinetd.d下加个bitlbee的配置文件,为启用状态。
service bitlbee
{
type = UNLISTED
socket_type = stream
protocol = tcp
wait = no
user = frank
group = bitlbee
server = /bin/bitlbee
port = 6667
disable = no
}
chkconfig xinetd on
service xinetd restart
irssi中
server localhost
连接
进入后使用 Alt+2到bitlbee频道
加账号
<msn>
account add msn username@hotmail.com userpassword
<gtalk>
account add jabber username@gmail.com userpassword talk.google.com:5223:ssl
account list 查看
account on 0 登陆第一个帐号
IRC的模式聊天。
今天想从rpmforge源安装有冲突,急用就先用源代码来安装。
从源代码安装:
./configure --prefix=/ --bindir=/bin --ssl=openssl
make install-etc
配置bitlee可以和xinetd配合,在/etc/xinetd.d下加个bitlbee的配置文件,为启用状态。
service bitlbee
{
type = UNLISTED
socket_type = stream
protocol = tcp
wait = no
user = frank
group = bitlbee
server = /bin/bitlbee
port = 6667
disable = no
}
chkconfig xinetd on
service xinetd restart
irssi中
server localhost
连接
进入后使用 Alt+2到bitlbee频道
加账号
<msn>
account add msn username@hotmail.com userpassword
<gtalk>
account add jabber username@gmail.com userpassword talk.google.com:5223:ssl
account list 查看
account on 0 登陆第一个帐号
IRC的模式聊天。
2009年10月21日星期三
elinks handle ed2k for mldonkey by lua [让elinks 支持点击电驴连接就下载]
elinks handle ed2k for mldonkey by lua
OS:CentOS 5.3
需求来源:
此机器很大部分时间还是台电驴BT下载机。
有时候远程putty想加些mldonkey任务,一般可以通过mldonkey的 telnet console添加, 但是需要整理出ed2k的地址,然后dllink添加。特别是多个链接的时候特别麻烦。
如果可以直接在putty浏览网页时添加就最好不过了,console浏览器一般lnyx,elinks等等。
看了下下文 elinks和mldonkey工作的很好。
http://mldonkey.sourceforge.net/Browser_Integration
首先需要确定elinks的Lua脚本支持是否编译进去了(elinks 0.11目前只支持lua 5.0, 使用yum没办法,我用源代码编译的)。
[frank@CentOS5 mldonkeydown]$ elinks --version
ELinks 0.11.6.GIT (built on May 20 2009 13:06:33)
Features:
Standard, IPv6, gzip, bzip2, Periodic Saving, Timer, Cascading Style Sheets,
Protocol (File, FTP, HTTP, URI rewrite, User protocols), SSL (OpenSSL),
MIME (Option system, Mailcap, Mimetypes files), LED indicators, Bookmarks,
Cookies, Form History, Global History, Scripting (Lua), Goto URL History,
Search History
接下去就是关键的用户hooks.lua编写(位于~/.elinks/hooks.lua).
wiki上的脚本语法有问题,
花了两天看了些资料终于work拉。修改了下脚本使其支持ed2k的几种方式。
hooks.lua
1 function url_encode(text)
2 text = string.gsub(text, " ", "%%20")
3 -- text = string.gsub(text, "%:", "%%3A")
4 text = string.gsub(text, "%/", "%%2F")
5 text = string.gsub(text, "%||", "%%7C")
6 text = string.gsub(text, "%!", "%%21")
7 -- text = string.gsub(text, "%?", "%%AA")
8 text = string.gsub(text, "%&", "%%26")
9 return string.gsub(text, "%#", "%%23")
10 end
11
12 function follow_url_hook (url)
13 -- Detecting ed2k links
14 if string.find(url,"ed2k.-file|.-|%d-|%x-|/.*") then
15 -- ed2k link with h=XXX hash infor
16 text = url_encode(string.gsub(url, "(.-)ed2k.-file|(.-)|(%d-)|(%x-)|/.*", "dllink ed2k://|file|%2|%3|%4|/"))
17 return "http://127.0.0.1:40080/submit?q="..text
18 elseif string.find(url,"ed2k.-file|.-|%d-|%x-|.-|/.*") then
19 -- ed2k link without hash infor
20 text = url_encode(string.gsub(url, "(.-)ed2k.-file|(.-)|(%d-)|(%x-)|(.-)|/.*", "dllink ed2k://|file|%2|%3|%4|%5|/"))
21 return "http://127.0.0.1:40080/submit?q="..text
22 end
23 -- Return url without changes.
24 return url
25 end
看了下面这些资料:
Programming in Lua
lua reference
Beginning Lua Programming
http://en.wikipedia.org/wiki/Ed2k_link
OS:CentOS 5.3
需求来源:
此机器很大部分时间还是台电驴BT下载机。
有时候远程putty想加些mldonkey任务,一般可以通过mldonkey的 telnet console添加, 但是需要整理出ed2k的地址,然后dllink添加。特别是多个链接的时候特别麻烦。
如果可以直接在putty浏览网页时添加就最好不过了,console浏览器一般lnyx,elinks等等。
看了下下文 elinks和mldonkey工作的很好。
http://mldonkey.sourceforge.net/Browser_Integration
首先需要确定elinks的Lua脚本支持是否编译进去了(elinks 0.11目前只支持lua 5.0, 使用yum没办法,我用源代码编译的)。
[frank@CentOS5 mldonkeydown]$ elinks --version
ELinks 0.11.6.GIT (built on May 20 2009 13:06:33)
Features:
Standard, IPv6, gzip, bzip2, Periodic Saving, Timer, Cascading Style Sheets,
Protocol (File, FTP, HTTP, URI rewrite, User protocols), SSL (OpenSSL),
MIME (Option system, Mailcap, Mimetypes files), LED indicators, Bookmarks,
Cookies, Form History, Global History, Scripting (Lua), Goto URL History,
Search History
接下去就是关键的用户hooks.lua编写(位于~/.elinks/hooks.lua).
wiki上的脚本语法有问题,
花了两天看了些资料终于work拉。修改了下脚本使其支持ed2k的几种方式。
hooks.lua
1 function url_encode(text)
2 text = string.gsub(text, " ", "%%20")
3 -- text = string.gsub(text, "%:", "%%3A")
4 text = string.gsub(text, "%/", "%%2F")
5 text = string.gsub(text, "%||", "%%7C")
6 text = string.gsub(text, "%!", "%%21")
7 -- text = string.gsub(text, "%?", "%%AA")
8 text = string.gsub(text, "%&", "%%26")
9 return string.gsub(text, "%#", "%%23")
10 end
11
12 function follow_url_hook (url)
13 -- Detecting ed2k links
14 if string.find(url,"ed2k.-file|.-|%d-|%x-|/.*") then
15 -- ed2k link with h=XXX hash infor
16 text = url_encode(string.gsub(url, "(.-)ed2k.-file|(.-)|(%d-)|(%x-)|/.*", "dllink ed2k://|file|%2|%3|%4|/"))
17 return "http://127.0.0.1:40080/submit?q="..text
18 elseif string.find(url,"ed2k.-file|.-|%d-|%x-|.-|/.*") then
19 -- ed2k link without hash infor
20 text = url_encode(string.gsub(url, "(.-)ed2k.-file|(.-)|(%d-)|(%x-)|(.-)|/.*", "dllink ed2k://|file|%2|%3|%4|%5|/"))
21 return "http://127.0.0.1:40080/submit?q="..text
22 end
23 -- Return url without changes.
24 return url
25 end
看了下面这些资料:
Programming in Lua
lua reference
Beginning Lua Programming
http://en.wikipedia.org/wiki/Ed2k_link
CentOS Manager How to 管理手册
CentOS Manager How to 管理手册
(for 内网用户)
1. network网络管理
2. user管理
3. oracle管理
4. download下载管理
5. security安全管理
6. Linksys路由器管理
7. anymore?
TIPS:
在每次改动配置文件前,比较好的习惯是copy个备份,cp configfile.conf configfile.conf.backupYYYYMMDD
network网络管理
查看哪些程序开了TCP监听端口:
netstat -ntlp
有哪些TCP网络连接:
netstat -ntp | grep ESTABLISHED
防火墙管理配置:
默认情况下所有的端口都是block的,
1、图形界面,先设置好DISPLAY或者Putty的X11 Forward,然后执行system-config-security
2、字符图形界面,system-config-security-tui
3、iptables命令管理。
这里设置的开放端口一般只是让LAN内网的机器能够访问,不会直接让外网访问并带来安全隐患。 [外网端口参见Linksys路由器管理]
user管理
添加用户并使其能通过ssh登陆:
1.useradd usertodadd
2.passwd usertodadd
3./etc/ssh/sshd_config
# Attention!!!!!! you should change /etc/security/sshd.conf for pam_access.so module
AllowUsers frank ljq frankzhu oracle usertodadd
4./etc/security/sshd.conf
# only LAN access
+: oracle : 192.168.1.0/24
# FULL access
-:ALL EXCEPT frank frankzhu ljq oracle usertodadd:ALL
5.restart sshd service "service sshd restart"
oracle管理
1.oracle账号被限制只能内网IP登陆,外网不能直接登陆。
2.ORACLE_HOME /opt/oracle 下。
下载管理 ★
bt//目前使用mldoneky的 BitTorrent plugin来下载。
添加任务:
把BT种子放到 /opt/download/torrent中就可以自动下载。
下载任务查看
m 命令
电驴 mldonkey管理
[frank@CentOS ~]$ alias m
alias m='pgrep mlnet >/dev/null 2>&1 && echo vd downloading | nc localhost 10023 | awk '\''/\[D/{print "\033[0;32m"$7"\t\033[4; 31m"$8"%\033[0m\t",$14"KB/s"} /Down:/'\'''
m 命令可以查下载进度
[frank@CentOS ~]$ m
Down: 47.4 KB/s ( 8 + 48580 ) | Up: 12.9 KB/s ( 5 + 13180 ) | Shared: 3/75.0M | Downloaded: 59.5M | Uploaded: 11.9M
王森地.-.[喜庆锣鼓].专辑.(mp3).rar 62.3% -KB/s
[黄飞鸿之二男儿当自强].Wong.Fei.Hung.Ji.Yi.Naam.Yi.Do....mkv 6.2% 55.4KB/s
管理方式1,telnet服务器管理
[frank@CentOS ~]$ telnet localhost 10023
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
Welcome to MLDonkey 3.0.0
Welcome on mldonkey command-line
Use ? for help
MLdonkey command-line:
>
管理方式2, web方式管理
http://192.168.1.222:10080/
添加任务:
windows中:
推荐
firefox+MLdonkey Protocol Handler Add-ons
其他看下面文档
Browser Integration - MLDonkey
mldonkey.sourceforge.net/Browser_Integration
在外网的时添加任务:
1.mldonkey telnet服务器使用dllink命令添加任务
[root@CentOS ~]# telnet localhost 10023
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
Welcome to MLDonkey 3.0.0
Welcome on mldonkey command-line
Use ? for help
> ? dllink
dllink : download ed2k, sig2dat, torrent or other link
dllink
where can be ed2k, sig2dat, torrent or fasttrack
2.使用elinks+lua向mldonkey telnet服务器提交请求 【推荐】
elinks <电驴链接ed2k>
[frank@CentOS ~]# elinks http://www.verycd.com/topics/2769748/
这时候就可以看到网页内容了,找到ed2k链接地址,可以鼠标滚动,page down下翻,直接点击链接就可以添加任务:
如何退出程序?
先按q,回车确定退出
security安全管理
此机器对外开放端口:
21 ftp [tcp]
22 ssh [tcp]
20000~20050 [tcp && udp]
ftp使用明文传输密码,一般情况下不用,传输效率比sftp应该好些。
ssh比较安全,提供了对此机器的很多访问: ssh远程控制, sftp文件传输,ssh tunnel (ssh 隧道)
20000~20050 [tcp && udp] 比较杂:
mldonkey的对外端口
ftp passive 模式的监听端口。/etc/vsftpd/vsftpd.conf
由于这些对外的端口外网黑客很喜欢扫描,一般先扫描端口,然后尝试暴力破解ftp,ssh。所以机器对安全方面做了配置。
1. ftp 关闭匿名登陆,fail2ban检查登陆尝试,同一个IP失败几次后iptables block掉IP
2. ssh root不能直接登陆,只能是AllowUsers 中可以,同时在/etc/security/sshd.conf 限制登陆ID的IP来源。fail2ban检查登陆尝试,同一个IP失败几次后iptables block掉IP
Linksys路由器管理
路由器为CISCO Linksys WRT54G V1.0 ,刷 DD-WRT v 24 (一个嵌入Linux)。
所以可以在上面做些配置:
1.配置每个IP的连接数
2.可以查看每个IP的实时流量,需要Enable CFlow和 MacFlow
3.配置每个IP的流量和速度限制
4.QoS
5.DD-WRT的无线功能非常突出,模式很多,可以是一般AP,WDS桥接,repeator信号增强,混合模式
Any more:
httpd/apach
tomcat
mysql
PXE install环境配置 (dhcpd+tftp+nfs)
(for 内网用户)
1. network网络管理
2. user管理
3. oracle管理
4. download下载管理
5. security安全管理
6. Linksys路由器管理
7. anymore?
TIPS:
在每次改动配置文件前,比较好的习惯是copy个备份,cp configfile.conf configfile.conf.backupYYYYMMDD
network网络管理
查看哪些程序开了TCP监听端口:
netstat -ntlp
有哪些TCP网络连接:
netstat -ntp | grep ESTABLISHED
防火墙管理配置:
默认情况下所有的端口都是block的,
1、图形界面,先设置好DISPLAY或者Putty的X11 Forward,然后执行system-config-security
2、字符图形界面,system-config-security-tui
3、iptables命令管理。
这里设置的开放端口一般只是让LAN内网的机器能够访问,不会直接让外网访问并带来安全隐患。 [外网端口参见Linksys路由器管理]
user管理
添加用户并使其能通过ssh登陆:
1.useradd usertodadd
2.passwd usertodadd
3./etc/ssh/sshd_config
# Attention!!!!!! you should change /etc/security/sshd.conf for pam_access.so module
AllowUsers frank ljq frankzhu oracle usertodadd
4./etc/security/sshd.conf
# only LAN access
+: oracle : 192.168.1.0/24
# FULL access
-:ALL EXCEPT frank frankzhu ljq oracle usertodadd:ALL
5.restart sshd service "service sshd restart"
oracle管理
1.oracle账号被限制只能内网IP登陆,外网不能直接登陆。
2.ORACLE_HOME /opt/oracle 下。
下载管理 ★
bt//目前使用mldoneky的 BitTorrent plugin来下载。
添加任务:
把BT种子放到 /opt/download/torrent中就可以自动下载。
下载任务查看
m 命令
电驴 mldonkey管理
[frank@CentOS ~]$ alias m
alias m='pgrep mlnet >/dev/null 2>&1 && echo vd downloading | nc localhost 10023 | awk '\''/\[D/{print "\033[0;32m"$7"\t\033[4; 31m"$8"%\033[0m\t",$14"KB/s"} /Down:/'\'''
m 命令可以查下载进度
[frank@CentOS ~]$ m
Down: 47.4 KB/s ( 8 + 48580 ) | Up: 12.9 KB/s ( 5 + 13180 ) | Shared: 3/75.0M | Downloaded: 59.5M | Uploaded: 11.9M
王森地.-.[喜庆锣鼓].专辑.(mp3).rar 62.3% -KB/s
[黄飞鸿之二男儿当自强].Wong.Fei.Hung.Ji.Yi.Naam.Yi.Do....mkv 6.2% 55.4KB/s
管理方式1,telnet服务器管理
[frank@CentOS ~]$ telnet localhost 10023
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
Welcome to MLDonkey 3.0.0
Welcome on mldonkey command-line
Use ? for help
MLdonkey command-line:
>
管理方式2, web方式管理
http://192.168.1.222:10080/
添加任务:
windows中:
推荐
firefox+MLdonkey Protocol Handler Add-ons
其他看下面文档
Browser Integration - MLDonkey
mldonkey.sourceforge.net/Browser_Integration
在外网的时添加任务:
1.mldonkey telnet服务器使用dllink命令添加任务
[root@CentOS ~]# telnet localhost 10023
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
Welcome to MLDonkey 3.0.0
Welcome on mldonkey command-line
Use ? for help
> ? dllink
dllink : download ed2k, sig2dat, torrent or other link
dllink
where can be ed2k, sig2dat, torrent or fasttrack
2.使用elinks+lua向mldonkey telnet服务器提交请求 【推荐】
elinks <电驴链接ed2k>
[frank@CentOS ~]# elinks http://www.verycd.com/topics/2769748/
这时候就可以看到网页内容了,找到ed2k链接地址,可以鼠标滚动,page down下翻,直接点击链接就可以添加任务:
如何退出程序?
先按q,回车确定退出
security安全管理
此机器对外开放端口:
21 ftp [tcp]
22 ssh [tcp]
20000~20050 [tcp && udp]
ftp使用明文传输密码,一般情况下不用,传输效率比sftp应该好些。
ssh比较安全,提供了对此机器的很多访问: ssh远程控制, sftp文件传输,ssh tunnel (ssh 隧道)
20000~20050 [tcp && udp] 比较杂:
mldonkey的对外端口
ftp passive 模式的监听端口。/etc/vsftpd/vsftpd.conf
由于这些对外的端口外网黑客很喜欢扫描,一般先扫描端口,然后尝试暴力破解ftp,ssh。所以机器对安全方面做了配置。
1. ftp 关闭匿名登陆,fail2ban检查登陆尝试,同一个IP失败几次后iptables block掉IP
2. ssh root不能直接登陆,只能是AllowUsers 中可以,同时在/etc/security/sshd.conf 限制登陆ID的IP来源。fail2ban检查登陆尝试,同一个IP失败几次后iptables block掉IP
Linksys路由器管理
路由器为CISCO Linksys WRT54G V1.0 ,刷 DD-WRT v 24 (一个嵌入Linux)。
所以可以在上面做些配置:
1.配置每个IP的连接数
2.可以查看每个IP的实时流量,需要Enable CFlow和 MacFlow
3.配置每个IP的流量和速度限制
4.QoS
5.DD-WRT的无线功能非常突出,模式很多,可以是一般AP,WDS桥接,repeator信号增强,混合模式
Any more:
httpd/apach
tomcat
mysql
PXE install环境配置 (dhcpd+tftp+nfs)
两硬盘,Linux系统“迁移”及LVM调整
目的:
我的Linux分区不够用了,Linux一直在下电驴。我的另外一个硬盘是windows格式的。我想格掉并把分区分给Linux用。
机器:
台机:无显示器,两IDE硬盘,平时用SSH维护,网络挂时用串口做终端维护。
本本:网络和串口访问台机Linux。
台机开始分区情况:
[root@CentOS5 ~]# fdisk -l
Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 651 5229126 b W95 FAT32
/dev/hda2 652 14593 111989115 f W95 Ext'd (LBA)
/dev/hda5 652 13972 107000901 b W95 FAT32
/dev/hda6 13973 14593 4988151 7 HPFS/NTFS
Disk /dev/hdb: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 * 1 13 104391 83 Linux
/dev/hdb2 14 7476 59946547+ 8e Linux LVM
[root@CentOS5 ~]# lvm pvs
PV VG Fmt Attr PSize PFree
/dev/hdb2 VolGroup00 lvm2 a- 57.16G 0
[root@CentOS5 ~]# lvm lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol_opt VolGroup00 -wi-ao 50.16G
LogVol_root VolGroup00 -wi-ao 5.84G
LogVol_swap VolGroup00 -wi-ao 1.16G
CentOS的GRUB装在/hdb1, /hda1上装了个windows 2K. 目前BIOS设置了第一硬盘启动。使用widows 2K的OS loader 来启动grub再启动CentOS。如果改成第二硬盘启动可以直接启动GRUB。
现在我具体想做的步骤:
1.格掉hda成一个/boot分区和一个Linux LVM,比如 hda2成物理LVM Volume Group (vg00).
2.把老Linux系统迁移到新的硬盘。Swap也放到新的硬盘。
A.包括把老的boot分区数据拷贝到新的boot分区
B.在新的vg00中建立新的Logic Volume (lv_root),把老的根分区数据拷进来。
3.当新lv_root分区的系统可以启动的时候,把原来老硬盘空间回收,分配到新的vg中。
具体操作步骤:
正式开始,umount不用的分区。
[root@CentOS5 opt]# fdisk /dev/hda
The number of cylinders for this disk is set to 14593.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 651 5229126 b W95 FAT32
/dev/hda2 652 14593 111989115 f W95 Ext'd (LBA)
/dev/hda5 652 13972 107000901 b W95 FAT32
/dev/hda6 13973 14593 4988151 7 HPFS/NTFS
先delete所有原来分区。
Command (m for help): p
Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
建立两个分区,一个100M,激活为可启动。剩下的用来建PV。
Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 14593 117113850 83 Linux
格式化100M的分区。挂载并拷贝boot内容。
[root@CentOS5 opt]# mkfs.ext3 /dev/hda1
[root@CentOS5 opt]# mkdir /mnt/hda1boot
[root@CentOS5 opt]# mount /dev/hda1 /mnt/hda1boot/
[root@CentOS5 ~]# cp -a /boot/* /mnt/hda1boot/
安装grub到第一硬盘,安装到MBR。
(我在虚拟机中测试时想用grub-install /dev/hda,有出错信息,所以这里用来下面的方法)
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd0)
Checking if "/boot/grub/stage1" exists... no
Checking if "/grub/stage1" exists... yes
Checking if "/grub/stage2" exists... yes
Checking if "/grub/e2fs_stage1_5" exists... yes
Running "embed /grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.
succeeded
Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded
Done.
下面准备好LVM。
[root@CentOS5 ~]# pvcreate /dev/hda2
Physical volume "/dev/hda2" successfully created
[root@CentOS5 ~]# pvscan
PV /dev/hdb2 VG VolGroup00 lvm2 [57.16 GB / 0 free]
PV /dev/hda2 lvm2 [111.69 GB]
Total: 2 [168.84 GB] / in use: 1 [57.16 GB] / in no VG: 1 [111.69 GB]
[root@CentOS5 ~]# vgcreate vg00 /dev/hda2
Volume group "vg00" successfully created
[root@CentOS5 ~]# lvcreate -n lv_root -L 6000M vg00
[root@CentOS5 ~]# lvscan
ACTIVE '/dev/VolGroup00/LogVol_root' [5.84 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol_opt' [50.16 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol_swap' [1.16 GB] inherit
ACTIVE '/dev/vg00/lv_root' [5.86 GB] inherit
[root@CentOS5 ~]# mkdir /mnt/lvroot
[root@CentOS5 ~]# mount /dev/vg00/lv_root /mnt/lvroot
开始拷贝/分区下文件和目录:
[root@CentOS5 ~]# cp -a /bin /mnt/lvroot/
[root@CentOS5 ~]# cp -a /etc /mnt/lvroot/
[root@CentOS5 ~]# cp -a /exports /mnt/lvroot/
[root@CentOS5 ~]# cp -a /home /mnt/lvroot/
[root@CentOS5 ~]# cp -a /lib /mnt/lvroot/
[root@CentOS5 ~]# cp -a /net /mnt/lvroot/
[root@CentOS5 ~]# cp -a /root /mnt/lvroot/
[root@CentOS5 ~]# cp -a /sbin /mnt/lvroot/
[root@CentOS5 ~]# cp -a /srv /mnt/lvroot/
[root@CentOS5 ~]# cp -a /tftpboot /mnt/lvroot/
[root@CentOS5 ~]# cp -a /usr /mnt/lvroot/
[root@CentOS5 ~]# cp -a /var /mnt/lvroot/
建立些不拷的目录,同时保证权限一致:
[root@CentOS5 /]# mkdir /mnt/lvroot/boot
[root@CentOS5 /]# mkdir /mnt/lvroot/media
[root@CentOS5 /]# mkdir /mnt/lvroot/misc
[root@CentOS5 /]# mkdir /mnt/lvroot/opt
[root@CentOS5 /]# mkdir /mnt/lvroot/mnt
[root@CentOS5 /]# mkdir /mnt/lvroot/proc
[root@CentOS5 /]# chmod -w /mnt/lvroot/proc/
[root@CentOS5 /]# mkdir /mnt/lvroot/selinux
[root@CentOS5 /]# mkdir /mnt/lvroot/sys
[root@CentOS5 ~]# mkdir /mnt/lvroot/tmp
[root@CentOS5 ~]# chmod 777 /mnt/lvroot/tmp
[root@CentOS5 ~]# chmod +t /mnt/lvroot/tmp
建立swap分区。
[root@CentOS5 /]# lvcreate -n lv_swap -L 1200M vg00
[root@CentOS5 /]# mkswap /dev/vg00/lv_swap
开始修改grub和fstab。
/mnt/hda1boot/grub/menu.lst文件中的root和kernel参数中的root=/dev/vg00/lv_root。
1 /dev/vg00/lv_root / ext3 defaults 1 1
2 #LABEL=/boot /boot ext3 defaults 1 2
3 /dev/hda1 /boot ext3 defaults 1 2
4 tmpfs /dev/shm tmpfs defaults 0 0
5 devpts /dev/pts devpts gid=5,mode=620 0 0
6 sysfs /sys sysfs defaults 0 0
7 proc /proc proc defaults 0 0
8 /dev/vg00/lv_swap swap swap defaults 0 0
9
10 #/dev/VolGroup00/LogVol_opt /opt ext3 defaults 1 2
检查下etc下虽开机启动的脚本。
比如我要把rc.d中oracle相关的去掉。
rc.local中的也去掉。
+++++++++++++++++++一切检查就绪,准备重启+++++++++++++++++++++++++++++++==
接上串口线,我的台机没有显示器。:)
哈哈可以的,看到了新的grub菜单。
然后....
Scanning logical volumes
Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2
Found volume group "vg00" using metadata type lvm2
Activating logical volumes
3 logical volume(s) in volume group "VolGroup00" now active
Trying to resume from /dev/VolGroup00/LogVol_swap
No suspend signature on swap, not resuming.
Creating root device.
Mounting root filesystem.
mount: could notKernel panic - not syncing: Attempted to kill init!
find filesystem '/dev/root'
Se
我奇怪的是为什么我grub的kernel root参数设置了新的分区了啊,为什么系统还是从老的volume group "VolGroup00"启动?
问题解决方法:
参考文章:
http://linux.chinaunix.net/bbs/archiver/tid-1030789.html
开始按他的做了,还是不可以。
觉得奇怪它怎么只去active VolGroup00的呢?
后来仔细看了解压的initrd中的init,原来是那里写了启动哪个Volume Group。 手动修改启动vg00.swap root等也对应修改,打包initrd。
后来看了下initrd,如果系统已经启动了,要生成个新的initrd很简单的。
备份原来的initrd,然后用mkinitrd就可以生成个新的了。
(1)生成个现在使用的kernel的initrd。
/sbin/mkinitrd /boot/initrd-`uname -r`.img `uname -r`
(2)生成xen内核的initrd。
/sbin/mkinitrd /root/initrd-2.6.18-92.1.22.el5xen.img 2.6.18-92.1.22.el5xen
当然不是随便的initrd都可以生成的,你需要有对应的kernel modules。
mkinitrd会查看/etc/fstab文件,这也就是老的initrd只回去挂载老的Volume Group的原因。
总结:
这种方法迁移系统基本没什么损失,没有软件需要重装,我/opt的oracle拷贝回来后就可以启动了。
主要是分区数据基本没变化。LVM很好用。
参考文章:
1.LVM howto:http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/pdf/LVM-HOWTO.pdf
2.initrd Fix 参考文章:http://linux.chinaunix.net/bbs/archiver/tid-1030789.html
3.Linux 初始 RAM 磁盘(initrd)概述:http://www.ibm.com/developerworks/cn/linux/l-initrd.html
后记,后来在一次演示fdisk时错误的把60G的分区格了,但是还没有重启。内核还是使用老的分区表。这个时候可以通过上面的记录来重新fdisk。照理重启应该是OK的。
我使用了另外的方法:
从以前到操作记录找到原来到分区分法:
原来:
Disk /dev/hdb: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 * 1 13 104391 83 Linux
/dev/hdb2 14 7476 59946547+ 8e Linux LVM
现在:
Disk /dev/hdb: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 2433 19543041 83 Linux
这个应该就只是MBR数据被改了吧, 能不能通过dd命令或其他方法来恢复?
或者我再fdisk /dev/hdb 一下,分成和原来一样到,然后不格式化,可行么?
方法1.
改后,因为操作系统已经移动到/dev/hda磁盘,所以没激活成boot分区。
Disk /dev/hdb: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 13 104391 83 Linux
/dev/hdb2 14 7476 59946547+ 8e Linux LVM
fdisk w 命令后到结果。
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. //这个哪里看的到吗,在/proc还是?
The new table will be used at the next reboot.
Syncing disks.
目前到分区和原来一样了,这样应该也是算重建了分区表吧? 还不敢重启,期待有经验到确认。
20090716 update:在使用方法2后,我直接重启来测试这个方法的可行性,结果应该OK的, 然后继续LVM操作。
重启后:
Disk /dev/hdb: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 13 104391 83 Linux
/dev/hdb2 14 7476 59946547+ 8e Linux LVM
LVM显示:
[root@CentOS~]# pvdisplay
--- Physical volume ---
PV Name /dev/hda2
VG Name vg00
PV Size 111.69 GB / not usable 1018.00 KB
Allocatable yes
PE Size (KByte) 4096
Total PE 28592
Free PE 2831
Allocated PE 25761
PV UUID KCAZwV-ycFK-zP5m-A0eS-yuIm-Cotd-P22gjF
--- Physical volume ---
PV Name /dev/hdb2
VG Name vg00
PV Size 57.17 GB / not usable 1.55 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 14635
Free PE 14635
Allocated PE 0
PV UUID 1Ga7wF-a6Gr-yug2-BwVX-gDIp-1epr-IpHndY
方法2,缩小LV,重新LVM分区操作。
参考文章
http://lfs.linuxsir.org/main/?q=node/42
[root@CentOS ~]# mke2fs -n /dev/vg00/lv_opt
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
19365888 inodes, 38706176 blocks
1935308 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
1182 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, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
4096
1G=1024M=1024*1024*1024 b
块大小是4096(4kb) 当前有786432个blocks 现在打算减小一个G的空间。
1G占用的blocks一共是262144个,所以减少后的blocks应该是524288个。
60G = 262144*60
减少后的blocks 38706176-262144*60==22977536
umount /home
resize2fs /dev/vg00/lv_opt 22977536
lvreduce -L-60G /dev/vg00/lv_opt
mount /home
[root@CentOS ~]# resize2fs /dev/vg00/lv_opt 22977536
resize2fs 1.39 (29-May-2006)
Please run 'e2fsck -f /dev/vg00/lv_opt' first.
[root@CentOS ~]# e2fsck -f /dev/vg00/lv_opt
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vg00/lv_opt: 32122/19365888 files (6.1% non-contiguous), 19459972/38706176 blocks
[root@CentOS ~]# resize2fs /dev/vg00/lv_opt 22977536
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/vg00/lv_opt to 22977536 (4k) blocks.
The filesystem on /dev/vg00/lv_opt is now 22977536 blocks long.
[root@CentOS ~]# lvreduce -L-60G /dev/vg00/lv_opt
WARNING: Reducing active logical volume to 87.65 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_opt? [y/n]: y
Reducing logical volume lv_opt to 87.65 GB
Logical volume lv_opt successfully resized
[root@CentOS opt]# pvs
PV VG Fmt Attr PSize PFree
/dev/hda2 vg00 lvm2 a- 111.69G 17.00G
/dev/hdb2 vg00 lvm2 a- 57.17G 51.22G
[root@CentOS opt]# pvmove /dev/hdb2
/dev/hdb2: Moved: 4.9%
/dev/hdb2: Moved: 9.5%
/dev/hdb2: Moved: 14.1%
/dev/hdb2: Moved: 18.5%
/dev/hdb2: Moved: 22.9%
/dev/hdb2: Moved: 27.5%
/dev/hdb2: Moved: 31.9%
/dev/hdb2: Moved: 36.4%
/dev/hdb2: Moved: 40.9%
/dev/hdb2: Moved: 45.4%
/dev/hdb2: Moved: 49.8%
/dev/hdb2: Moved: 54.2%
/dev/hdb2: Moved: 58.7%
/dev/hdb2: Moved: 63.1%
/dev/hdb2: Moved: 67.6%
/dev/hdb2: Moved: 72.1%
/dev/hdb2: Moved: 76.6%
/dev/hdb2: Moved: 81.1%
/dev/hdb2: Moved: 85.7%
/dev/hdb2: Moved: 90.1%
/dev/hdb2: Moved: 94.7%
/dev/hdb2: Moved: 99.3%
/dev/hdb2: Moved: 100.0%
[root@CentOS opt]# pvs
PV VG Fmt Attr PSize PFree
/dev/hda2 vg00 lvm2 a- 111.69G 11.06G
/dev/hdb2 vg00 lvm2 a- 57.17G 57.17G
这步后reboot测试方法1,结果OK
[root@CentOS log]# pvdisplay /dev/hdb2
--- Physical volume ---
PV Name /dev/hdb2
VG Name vg00
PV Size 57.17 GB / not usable 1.55 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 14635
Free PE 14635
Allocated PE 0
PV UUID 1Ga7wF-a6Gr-yug2-BwVX-gDIp-1epr-IpHndY
确认PE都没用,Total PE == Free PE
[root@CentOS log]# vgreduce vg00 /dev/hdb2
Removed "/dev/hdb2" from volume group "vg00"
[root@CentOS log]# pvs
PV VG Fmt Attr PSize PFree
/dev/hda2 vg00 lvm2 a- 111.69G 11.06G
/dev/hdb2 lvm2 -- 57.17G 57.17G
[root@CentOS log]# pvremove /dev/hdb2
Labels on physical volume "/dev/hdb2" successfully wiped
[root@CentOS log]# pvs
PV VG Fmt Attr PSize PFree
/dev/hda2 vg00 lvm2 a- 111.69G 11.06G
fdisk把/dev/hdb这块硬盘分成一个区,分区格式LVM
Disk /dev/hdb: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 7476 60050938+ 8e Linux LVM
这次得小心操作啊
[root@CentOS log]# pvscan
PV /dev/hda2 VG vg00 lvm2 [111.69 GB / 11.06 GB free]
PV /dev/hdb1 lvm2 [57.27 GB]
Total: 2 [168.96 GB] / in use: 1 [111.69 GB] / in no VG: 1 [57.27 GB]
[root@CentOS log]# pvcreate /dev/hdb1
Physical volume "/dev/hdb1" successfully created
[root@CentOS log]# pvscan
PV /dev/hda2 VG vg00 lvm2 [111.69 GB / 11.06 GB free]
PV /dev/hdb1 VG vg00 lvm2 [57.27 GB / 57.27 GB free]
Total: 2 [168.95 GB] / in use: 2 [168.95 GB] / in no VG: 0 [0 ]
[root@CentOS log]# vgs
VG #PV #LV #SN Attr VSize VFree
vg00 2 3 0 wz--n- 168.95G 68.32G
OK,操作结束,空余空间又可以分配给/opt了。
[root@CentOS ~]# lvextend -L +50G /dev/vg00/lv_opt
Extending logical volume lv_opt to 137.65 GB
Logical volume lv_opt successfully resized
[root@CentOS ~]# lvscan
ACTIVE '/dev/vg00/lv_root' [11.80 GB] inherit
ACTIVE '/dev/vg00/lv_swap' [1.17 GB] inherit
ACTIVE '/dev/vg00/lv_opt' [137.65 GB] inherit
但这个时候如果mount空间用df看到还是没加的。
[root@CentOS ~]# resize2fs /dev/vg00/lv_opt
resize2fs 1.39 (29-May-2006)
Please run 'e2fsck -f /dev/vg00/lv_opt' first.
[root@CentOS ~]# e2fsck -f /dev/vg00/lv_opt
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vg00/lv_opt: 32122/11501568 files (6.1% non-contiguous), 19212227/22977536 blocks
[root@CentOS ~]# resize2fs /dev/vg00/lv_opt
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/vg00/lv_opt to 36084736 (4k) blocks.
The filesystem on /dev/vg00/lv_opt is now 36084736 blocks long.
[root@CentOS ~]# mount /opt/
[root@CentOS ~]# df -m
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/mapper/vg00-lv_root
11898 4936 6359 44% /
/dev/hda1 99 20 75 21% /boot
tmpfs 328 0 328 0% /dev/shm
/dev/mapper/vg00-lv_opt
138743 73642 62282 55% /opt
这次误操作的损失:
因为来不及借移动硬盘,上面的很多数据被我删光。主要是些视频教程,还有已经装好的oracle,Webpshere,xenos.
虽然这些都可以再下过来装上,不过时间浪费了不少。
我的Linux分区不够用了,Linux一直在下电驴。我的另外一个硬盘是windows格式的。我想格掉并把分区分给Linux用。
机器:
台机:无显示器,两IDE硬盘,平时用SSH维护,网络挂时用串口做终端维护。
本本:网络和串口访问台机Linux。
台机开始分区情况:
[root@CentOS5 ~]# fdisk -l
Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 651 5229126 b W95 FAT32
/dev/hda2 652 14593 111989115 f W95 Ext'd (LBA)
/dev/hda5 652 13972 107000901 b W95 FAT32
/dev/hda6 13973 14593 4988151 7 HPFS/NTFS
Disk /dev/hdb: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 * 1 13 104391 83 Linux
/dev/hdb2 14 7476 59946547+ 8e Linux LVM
[root@CentOS5 ~]# lvm pvs
PV VG Fmt Attr PSize PFree
/dev/hdb2 VolGroup00 lvm2 a- 57.16G 0
[root@CentOS5 ~]# lvm lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
LogVol_opt VolGroup00 -wi-ao 50.16G
LogVol_root VolGroup00 -wi-ao 5.84G
LogVol_swap VolGroup00 -wi-ao 1.16G
CentOS的GRUB装在/hdb1, /hda1上装了个windows 2K. 目前BIOS设置了第一硬盘启动。使用widows 2K的OS loader 来启动grub再启动CentOS。如果改成第二硬盘启动可以直接启动GRUB。
现在我具体想做的步骤:
1.格掉hda成一个/boot分区和一个Linux LVM,比如 hda2成物理LVM Volume Group (vg00).
2.把老Linux系统迁移到新的硬盘。Swap也放到新的硬盘。
A.包括把老的boot分区数据拷贝到新的boot分区
B.在新的vg00中建立新的Logic Volume (lv_root),把老的根分区数据拷进来。
3.当新lv_root分区的系统可以启动的时候,把原来老硬盘空间回收,分配到新的vg中。
具体操作步骤:
正式开始,umount不用的分区。
[root@CentOS5 opt]# fdisk /dev/hda
The number of cylinders for this disk is set to 14593.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 651 5229126 b W95 FAT32
/dev/hda2 652 14593 111989115 f W95 Ext'd (LBA)
/dev/hda5 652 13972 107000901 b W95 FAT32
/dev/hda6 13973 14593 4988151 7 HPFS/NTFS
先delete所有原来分区。
Command (m for help): p
Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
建立两个分区,一个100M,激活为可启动。剩下的用来建PV。
Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 14593 117113850 83 Linux
格式化100M的分区。挂载并拷贝boot内容。
[root@CentOS5 opt]# mkfs.ext3 /dev/hda1
[root@CentOS5 opt]# mkdir /mnt/hda1boot
[root@CentOS5 opt]# mount /dev/hda1 /mnt/hda1boot/
[root@CentOS5 ~]# cp -a /boot/* /mnt/hda1boot/
安装grub到第一硬盘,安装到MBR。
(我在虚拟机中测试时想用grub-install /dev/hda,有出错信息,所以这里用来下面的方法)
grub> root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
grub> setup (hd0)
Checking if "/boot/grub/stage1" exists... no
Checking if "/grub/stage1" exists... yes
Checking if "/grub/stage2" exists... yes
Checking if "/grub/e2fs_stage1_5" exists... yes
Running "embed /grub/e2fs_stage1_5 (hd0)"... 15 sectors are embedded.
succeeded
Running "install /grub/stage1 (hd0) (hd0)1+15 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded
Done.
下面准备好LVM。
[root@CentOS5 ~]# pvcreate /dev/hda2
Physical volume "/dev/hda2" successfully created
[root@CentOS5 ~]# pvscan
PV /dev/hdb2 VG VolGroup00 lvm2 [57.16 GB / 0 free]
PV /dev/hda2 lvm2 [111.69 GB]
Total: 2 [168.84 GB] / in use: 1 [57.16 GB] / in no VG: 1 [111.69 GB]
[root@CentOS5 ~]# vgcreate vg00 /dev/hda2
Volume group "vg00" successfully created
[root@CentOS5 ~]# lvcreate -n lv_root -L 6000M vg00
[root@CentOS5 ~]# lvscan
ACTIVE '/dev/VolGroup00/LogVol_root' [5.84 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol_opt' [50.16 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol_swap' [1.16 GB] inherit
ACTIVE '/dev/vg00/lv_root' [5.86 GB] inherit
[root@CentOS5 ~]# mkdir /mnt/lvroot
[root@CentOS5 ~]# mount /dev/vg00/lv_root /mnt/lvroot
开始拷贝/分区下文件和目录:
[root@CentOS5 ~]# cp -a /bin /mnt/lvroot/
[root@CentOS5 ~]# cp -a /etc /mnt/lvroot/
[root@CentOS5 ~]# cp -a /exports /mnt/lvroot/
[root@CentOS5 ~]# cp -a /home /mnt/lvroot/
[root@CentOS5 ~]# cp -a /lib /mnt/lvroot/
[root@CentOS5 ~]# cp -a /net /mnt/lvroot/
[root@CentOS5 ~]# cp -a /root /mnt/lvroot/
[root@CentOS5 ~]# cp -a /sbin /mnt/lvroot/
[root@CentOS5 ~]# cp -a /srv /mnt/lvroot/
[root@CentOS5 ~]# cp -a /tftpboot /mnt/lvroot/
[root@CentOS5 ~]# cp -a /usr /mnt/lvroot/
[root@CentOS5 ~]# cp -a /var /mnt/lvroot/
建立些不拷的目录,同时保证权限一致:
[root@CentOS5 /]# mkdir /mnt/lvroot/boot
[root@CentOS5 /]# mkdir /mnt/lvroot/media
[root@CentOS5 /]# mkdir /mnt/lvroot/misc
[root@CentOS5 /]# mkdir /mnt/lvroot/opt
[root@CentOS5 /]# mkdir /mnt/lvroot/mnt
[root@CentOS5 /]# mkdir /mnt/lvroot/proc
[root@CentOS5 /]# chmod -w /mnt/lvroot/proc/
[root@CentOS5 /]# mkdir /mnt/lvroot/selinux
[root@CentOS5 /]# mkdir /mnt/lvroot/sys
[root@CentOS5 ~]# mkdir /mnt/lvroot/tmp
[root@CentOS5 ~]# chmod 777 /mnt/lvroot/tmp
[root@CentOS5 ~]# chmod +t /mnt/lvroot/tmp
建立swap分区。
[root@CentOS5 /]# lvcreate -n lv_swap -L 1200M vg00
[root@CentOS5 /]# mkswap /dev/vg00/lv_swap
开始修改grub和fstab。
/mnt/hda1boot/grub/menu.lst文件中的root和kernel参数中的root=/dev/vg00/lv_root。
1 /dev/vg00/lv_root / ext3 defaults 1 1
2 #LABEL=/boot /boot ext3 defaults 1 2
3 /dev/hda1 /boot ext3 defaults 1 2
4 tmpfs /dev/shm tmpfs defaults 0 0
5 devpts /dev/pts devpts gid=5,mode=620 0 0
6 sysfs /sys sysfs defaults 0 0
7 proc /proc proc defaults 0 0
8 /dev/vg00/lv_swap swap swap defaults 0 0
9
10 #/dev/VolGroup00/LogVol_opt /opt ext3 defaults 1 2
检查下etc下虽开机启动的脚本。
比如我要把rc.d中oracle相关的去掉。
rc.local中的也去掉。
+++++++++++++++++++一切检查就绪,准备重启+++++++++++++++++++++++++++++++==
接上串口线,我的台机没有显示器。:)
哈哈可以的,看到了新的grub菜单。
然后....
Scanning logical volumes
Reading all physical volumes. This may take a while...
Found volume group "VolGroup00" using metadata type lvm2
Found volume group "vg00" using metadata type lvm2
Activating logical volumes
3 logical volume(s) in volume group "VolGroup00" now active
Trying to resume from /dev/VolGroup00/LogVol_swap
No suspend signature on swap, not resuming.
Creating root device.
Mounting root filesystem.
mount: could notKernel panic - not syncing: Attempted to kill init!
find filesystem '/dev/root'
Se
我奇怪的是为什么我grub的kernel root参数设置了新的分区了啊,为什么系统还是从老的volume group "VolGroup00"启动?
问题解决方法:
参考文章:
http://linux.chinaunix.net/bbs/archiver/tid-1030789.html
开始按他的做了,还是不可以。
觉得奇怪它怎么只去active VolGroup00的呢?
后来仔细看了解压的initrd中的init,原来是那里写了启动哪个Volume Group。 手动修改启动vg00.swap root等也对应修改,打包initrd。
后来看了下initrd,如果系统已经启动了,要生成个新的initrd很简单的。
备份原来的initrd,然后用mkinitrd就可以生成个新的了。
(1)生成个现在使用的kernel的initrd。
/sbin/mkinitrd /boot/initrd-`uname -r`.img `uname -r`
(2)生成xen内核的initrd。
/sbin/mkinitrd /root/initrd-2.6.18-92.1.22.el5xen.img 2.6.18-92.1.22.el5xen
当然不是随便的initrd都可以生成的,你需要有对应的kernel modules。
mkinitrd会查看/etc/fstab文件,这也就是老的initrd只回去挂载老的Volume Group的原因。
总结:
这种方法迁移系统基本没什么损失,没有软件需要重装,我/opt的oracle拷贝回来后就可以启动了。
主要是分区数据基本没变化。LVM很好用。
参考文章:
1.LVM howto:http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/pdf/LVM-HOWTO.pdf
2.initrd Fix 参考文章:http://linux.chinaunix.net/bbs/archiver/tid-1030789.html
3.Linux 初始 RAM 磁盘(initrd)概述:http://www.ibm.com/developerworks/cn/linux/l-initrd.html
后记,后来在一次演示fdisk时错误的把60G的分区格了,但是还没有重启。内核还是使用老的分区表。这个时候可以通过上面的记录来重新fdisk。照理重启应该是OK的。
我使用了另外的方法:
从以前到操作记录找到原来到分区分法:
原来:
Disk /dev/hdb: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 * 1 13 104391 83 Linux
/dev/hdb2 14 7476 59946547+ 8e Linux LVM
现在:
Disk /dev/hdb: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 2433 19543041 83 Linux
这个应该就只是MBR数据被改了吧, 能不能通过dd命令或其他方法来恢复?
或者我再fdisk /dev/hdb 一下,分成和原来一样到,然后不格式化,可行么?
方法1.
改后,因为操作系统已经移动到/dev/hda磁盘,所以没激活成boot分区。
Disk /dev/hdb: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 13 104391 83 Linux
/dev/hdb2 14 7476 59946547+ 8e Linux LVM
fdisk w 命令后到结果。
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. //这个哪里看的到吗,在/proc还是?
The new table will be used at the next reboot.
Syncing disks.
目前到分区和原来一样了,这样应该也是算重建了分区表吧? 还不敢重启,期待有经验到确认。
20090716 update:在使用方法2后,我直接重启来测试这个方法的可行性,结果应该OK的, 然后继续LVM操作。
重启后:
Disk /dev/hdb: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 13 104391 83 Linux
/dev/hdb2 14 7476 59946547+ 8e Linux LVM
LVM显示:
[root@CentOS~]# pvdisplay
--- Physical volume ---
PV Name /dev/hda2
VG Name vg00
PV Size 111.69 GB / not usable 1018.00 KB
Allocatable yes
PE Size (KByte) 4096
Total PE 28592
Free PE 2831
Allocated PE 25761
PV UUID KCAZwV-ycFK-zP5m-A0eS-yuIm-Cotd-P22gjF
--- Physical volume ---
PV Name /dev/hdb2
VG Name vg00
PV Size 57.17 GB / not usable 1.55 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 14635
Free PE 14635
Allocated PE 0
PV UUID 1Ga7wF-a6Gr-yug2-BwVX-gDIp-1epr-IpHndY
方法2,缩小LV,重新LVM分区操作。
参考文章
http://lfs.linuxsir.org/main/?q=node/42
[root@CentOS ~]# mke2fs -n /dev/vg00/lv_opt
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
19365888 inodes, 38706176 blocks
1935308 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
1182 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, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872
4096
1G=1024M=1024*1024*1024 b
块大小是4096(4kb) 当前有786432个blocks 现在打算减小一个G的空间。
1G占用的blocks一共是262144个,所以减少后的blocks应该是524288个。
60G = 262144*60
减少后的blocks 38706176-262144*60==22977536
umount /home
resize2fs /dev/vg00/lv_opt 22977536
lvreduce -L-60G /dev/vg00/lv_opt
mount /home
[root@CentOS ~]# resize2fs /dev/vg00/lv_opt 22977536
resize2fs 1.39 (29-May-2006)
Please run 'e2fsck -f /dev/vg00/lv_opt' first.
[root@CentOS ~]# e2fsck -f /dev/vg00/lv_opt
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vg00/lv_opt: 32122/19365888 files (6.1% non-contiguous), 19459972/38706176 blocks
[root@CentOS ~]# resize2fs /dev/vg00/lv_opt 22977536
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/vg00/lv_opt to 22977536 (4k) blocks.
The filesystem on /dev/vg00/lv_opt is now 22977536 blocks long.
[root@CentOS ~]# lvreduce -L-60G /dev/vg00/lv_opt
WARNING: Reducing active logical volume to 87.65 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv_opt? [y/n]: y
Reducing logical volume lv_opt to 87.65 GB
Logical volume lv_opt successfully resized
[root@CentOS opt]# pvs
PV VG Fmt Attr PSize PFree
/dev/hda2 vg00 lvm2 a- 111.69G 17.00G
/dev/hdb2 vg00 lvm2 a- 57.17G 51.22G
[root@CentOS opt]# pvmove /dev/hdb2
/dev/hdb2: Moved: 4.9%
/dev/hdb2: Moved: 9.5%
/dev/hdb2: Moved: 14.1%
/dev/hdb2: Moved: 18.5%
/dev/hdb2: Moved: 22.9%
/dev/hdb2: Moved: 27.5%
/dev/hdb2: Moved: 31.9%
/dev/hdb2: Moved: 36.4%
/dev/hdb2: Moved: 40.9%
/dev/hdb2: Moved: 45.4%
/dev/hdb2: Moved: 49.8%
/dev/hdb2: Moved: 54.2%
/dev/hdb2: Moved: 58.7%
/dev/hdb2: Moved: 63.1%
/dev/hdb2: Moved: 67.6%
/dev/hdb2: Moved: 72.1%
/dev/hdb2: Moved: 76.6%
/dev/hdb2: Moved: 81.1%
/dev/hdb2: Moved: 85.7%
/dev/hdb2: Moved: 90.1%
/dev/hdb2: Moved: 94.7%
/dev/hdb2: Moved: 99.3%
/dev/hdb2: Moved: 100.0%
[root@CentOS opt]# pvs
PV VG Fmt Attr PSize PFree
/dev/hda2 vg00 lvm2 a- 111.69G 11.06G
/dev/hdb2 vg00 lvm2 a- 57.17G 57.17G
这步后reboot测试方法1,结果OK
[root@CentOS log]# pvdisplay /dev/hdb2
--- Physical volume ---
PV Name /dev/hdb2
VG Name vg00
PV Size 57.17 GB / not usable 1.55 MB
Allocatable yes
PE Size (KByte) 4096
Total PE 14635
Free PE 14635
Allocated PE 0
PV UUID 1Ga7wF-a6Gr-yug2-BwVX-gDIp-1epr-IpHndY
确认PE都没用,Total PE == Free PE
[root@CentOS log]# vgreduce vg00 /dev/hdb2
Removed "/dev/hdb2" from volume group "vg00"
[root@CentOS log]# pvs
PV VG Fmt Attr PSize PFree
/dev/hda2 vg00 lvm2 a- 111.69G 11.06G
/dev/hdb2 lvm2 -- 57.17G 57.17G
[root@CentOS log]# pvremove /dev/hdb2
Labels on physical volume "/dev/hdb2" successfully wiped
[root@CentOS log]# pvs
PV VG Fmt Attr PSize PFree
/dev/hda2 vg00 lvm2 a- 111.69G 11.06G
fdisk把/dev/hdb这块硬盘分成一个区,分区格式LVM
Disk /dev/hdb: 61.4 GB, 61492838400 bytes
255 heads, 63 sectors/track, 7476 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdb1 1 7476 60050938+ 8e Linux LVM
这次得小心操作啊
[root@CentOS log]# pvscan
PV /dev/hda2 VG vg00 lvm2 [111.69 GB / 11.06 GB free]
PV /dev/hdb1 lvm2 [57.27 GB]
Total: 2 [168.96 GB] / in use: 1 [111.69 GB] / in no VG: 1 [57.27 GB]
[root@CentOS log]# pvcreate /dev/hdb1
Physical volume "/dev/hdb1" successfully created
[root@CentOS log]# pvscan
PV /dev/hda2 VG vg00 lvm2 [111.69 GB / 11.06 GB free]
PV /dev/hdb1 VG vg00 lvm2 [57.27 GB / 57.27 GB free]
Total: 2 [168.95 GB] / in use: 2 [168.95 GB] / in no VG: 0 [0 ]
[root@CentOS log]# vgs
VG #PV #LV #SN Attr VSize VFree
vg00 2 3 0 wz--n- 168.95G 68.32G
OK,操作结束,空余空间又可以分配给/opt了。
[root@CentOS ~]# lvextend -L +50G /dev/vg00/lv_opt
Extending logical volume lv_opt to 137.65 GB
Logical volume lv_opt successfully resized
[root@CentOS ~]# lvscan
ACTIVE '/dev/vg00/lv_root' [11.80 GB] inherit
ACTIVE '/dev/vg00/lv_swap' [1.17 GB] inherit
ACTIVE '/dev/vg00/lv_opt' [137.65 GB] inherit
但这个时候如果mount空间用df看到还是没加的。
[root@CentOS ~]# resize2fs /dev/vg00/lv_opt
resize2fs 1.39 (29-May-2006)
Please run 'e2fsck -f /dev/vg00/lv_opt' first.
[root@CentOS ~]# e2fsck -f /dev/vg00/lv_opt
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vg00/lv_opt: 32122/11501568 files (6.1% non-contiguous), 19212227/22977536 blocks
[root@CentOS ~]# resize2fs /dev/vg00/lv_opt
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/vg00/lv_opt to 36084736 (4k) blocks.
The filesystem on /dev/vg00/lv_opt is now 36084736 blocks long.
[root@CentOS ~]# mount /opt/
[root@CentOS ~]# df -m
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/mapper/vg00-lv_root
11898 4936 6359 44% /
/dev/hda1 99 20 75 21% /boot
tmpfs 328 0 328 0% /dev/shm
/dev/mapper/vg00-lv_opt
138743 73642 62282 55% /opt
这次误操作的损失:
因为来不及借移动硬盘,上面的很多数据被我删光。主要是些视频教程,还有已经装好的oracle,Webpshere,xenos.
虽然这些都可以再下过来装上,不过时间浪费了不少。
芝麻开门,芝麻关门 Port knocking 简介
芝麻开门,芝麻关门 Port knocking 简介
草稿20091013
需求来源:
家里的Linux主机平时对internet开放着ssh。
经常有人尝试来暴力破解,曾改过ssh的port,好多了,不过这只是模糊安全。也装了fail2ban来限制攻击者的IP,但是攻击者频繁换IP的话fail2ban也没辙。
这次找到了新的方式:Port Knocking,原理很简单,不过挺有创意的。
Port Knocking 简介
为了开放ssh,一般我们让iptables允许ssh进入,不管来自哪里的ip。其实我们只需要为要登录的IP开iptables就可以了(白名单),封锁其他地址对ssh的访问。
可是很多时候不同的外网访问,我们是动态IP,需要让iptables对动态的IP开放SSH如何来实现呢,下面就介绍Port knocking(端口试探/端口碰撞):
Port knocking类似于一次地下组织秘密接头,一种最基本的方式:发送一定序列的UDP、TCP数据包。当运行在主机上的daemon程序捕捉到数据包以后,如果这个序列正确,则开启相应的端口,或者防火墙允许客户端通过。
一次简单的“敲门”流程
1.sshd开放中默认22端口,但是目前防火墙iptables还未允许我的IP通过。
2.Port knocking服务端初始化接头暗号(先敲端口7000再敲8000,TCP协议)和对应操作(对了就对此IP开通ssh的访问)
3.客户端对服务器不同端口进行knock(先7000再8000),发送SYN连接请求。
4.这些端口的连接对上了服务器端就会做些预定义操作为此IP开SSH端口。
5.这时我客户端就可以去连ssh的22端口了。
上面的接头暗号可以是TCP,UDP甚至是ICMP。
借用http://www.portknocking.org/view/about的图示,比较生动形象:
1.默认情况下客户端对服务器的应用由于防火墙不能访问
2.客户端敲正确的端口序列
3.服务器端Port Knocking(PK)程序打开防火墙端口
4.客户端可以访问了
Port Knocking 技术原理
Port knocking会在数据链路层(TODO,verify it?)监听所有的网络数据,类似嗅探程序,所以在不开端口,防火墙不允许此端口都可以接受到一定状态的数据包(如TCP SYN,为TCP三次握手第一个报文),当符合规则的报文出现时,规则开始记录,接下去的报文为正确下一个序列继续,错误就清空。当满足一次正确序列时就可以认为是一次event,触发一个action。
Port Knocking 优缺点
优点:
Port knocking 没监听端口,而且也不需要防火墙先开放这些Knock端口,可以隐藏你开放的服务,别人没法知道你是否使用了Port Knocking。
信息是由一定的端口访问顺序来传输的,而不是网络报文内容,所以不容易被报文嗅探工具截获。
阻止0day攻击。当服务器bug还没补丁前,Port Knocking可以做为一层防护。
Port Knocking增加了一层保护,即使在PK和防火墙都失效的情况下,ssh本身的安全验证机制也能很好的保护系统。
缺点:
如果port knocking Daemon挂了话相当于你家的门坏了,有钥匙也进不了。这个称为单点故障,即此服务停止的话整个系统不能工作。不过新的实现一般都检测daemon是否正常。
不是很方便,连ssh前需要先knock下,要使用专门软件,当然很多能发送连接请求的程序都可以的,客户端要对这个端口序列的保密工作,
Port Knocking不能用于Web,Mail。
Port knocking 实践
好,现在是实践下的时候了,search了下yum,发现有个叫knockd软件包(port knocking的实现其实很多的,这里有个列表: http://www.portknocking.org/view/implementations)。
1.ssh管理,根据鸟哥的文章做了下面的配置:
主要思想:
敲对了开端口,敲开门后cmd_timeout超时后再关闭。因为SSH只要在这个时间连接后防火墙关闭SSH端口对已有连接不会有影响。
/etc/knockd.conf
[options]
UseSyslog
[opencloseSSH]
sequence = 44440:udp,44442:udp,44441:udp
seq_timeout = 30
tcpflags = syn,ack
start_command = /sbin/iptables -I INPUT -s %IP% -p tcp --dport ssh -j ACCEPT
cmd_timeout = 300
stop_command = /sbin/iptables -D INPUT -s %IP% -p tcp --dport ssh -j ACCEPT
iptable未开放SSH
[root@CentOS1 ~]# iptables -nL INPUT
Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
启动port knocking daemon,这里开了调试和Verbose选项。
[root@CentOS1 ~]# knockd -D -v
config: new section: 'options'
config: usesyslog
config: new section: 'opencloseSSH'
config: opencloseSSH: sequence: 44440:udp,44442:udp,44441:udp
config: opencloseSSH: seq_timeout: 30
config: tcp flag: SYN
config: tcp flag: ACK
config: opencloseSSH: start_command: /sbin/iptables -I INPUT -s %IP% -p tcp --dport ssh -j ACCEPT
config: opencloseSSH: cmd_timeout: 300
config: opencloseSSH: stop_command: /sbin/iptables -D INPUT -s %IP% -p tcp --dport ssh -j ACCEPT
ethernet interface detected
Local IP: 192.168.1.111
listening on eth0...
客户端来敲下,使用了windows下的程序:
knock的Win32客户端程序:
http://www.zeroflux.org/proj/knock/files/knock-win32.zip
C:\>knock.exe -v 192.168.1.111 44440:udp 44442:udp 44441:udp
hitting udp 192.168.1.111:44440
hitting udp 192.168.1.111:44442
hitting udp 192.168.1.111:44441
服务器端监视到了正确的端口序列,触发动作,OPEN SESAME(芝麻开门!) 开放了SSH端口。
2009-09-12 00:27:25: udp: 192.168.1.110:54204 -> 192.168.1.111:44440 60 bytes
192.168.1.110: opencloseSSH: Stage 1
2009-09-12 00:27:25: udp: 192.168.1.110:54205 -> 192.168.1.111:44442 60 bytes
192.168.1.110: opencloseSSH: Stage 2
2009-09-12 00:27:25: udp: 192.168.1.110:54206 -> 192.168.1.111:44441 60 bytes
192.168.1.110: opencloseSSH: Stage 3
192.168.1.110: opencloseSSH: OPEN SESAME
opencloseSSH: running command: /sbin/iptables -I INPUT -s 192.168.1.110 -p tcp --dport ssh -j ACCEPT
iptables中已经加了允许条目。
[root@CentOS1 ~]# iptables -nL INPUT
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 192.168.1.110 0.0.0.0/0 tcp dpt:22
RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
这个时候我的ssh客户端就可以登录了。
超过门敲开后的时间自动关闭。很安全的自动门吧。
192.168.1.110: opencloseSSH: command timeout
opencloseSSH: running command: /sbin/iptables -D INPUT -s 192.168.1.110 -p tcp --dport ssh -j ACCEPT
2.ftp管理:
ftp这个古老的协议虽然不安全,但是传输效率无疑是比较高的。
这里vsftpd命令端口监听在默认的21端口,数据传输使用passive模式,开放在5000~50010,初始情况下iptables不允许对21的访问。
建立两个port knocking序列,一个开,一个关。
/etc/knockd.conf
[options]
UseSyslog
[openFTPControl]
sequence = 55540:tcp,55542:tcp,55541:tcp
seq_timeout = 30
tcpflags = syn
command = /sbin/iptables -I INPUT -s %IP% -p tcp --dport ftp -j ACCEPT
[closeFTPControl]
sequence = 55541:tcp,55542:tcp,55540:tcp
seq_timeout = 30
tcpflags = syn
command = /sbin/iptables -D INPUT -s %IP% -p tcp --dport ftp -j ACCEPT
Port knock服务器启动:
[root@CentOS1 ~]# knockd -D -v
config: new section: 'options'
config: usesyslog
config: new section: 'openFTPControl'
config: openFTPControl: sequence: 55540:tcp,55542:tcp,55541:tcp
config: openFTPControl: seq_timeout: 30
config: tcp flag: SYN
config: openFTPControl: start_command: /sbin/iptables -I INPUT -s %IP% -p tcp --dport ftp -j ACCEPT
config: new section: 'closeFTPControl'
config: closeFTPControl: sequence: 55541:tcp,55542:tcp,55540:tcp
config: closeFTPControl: seq_timeout: 30
config: tcp flag: SYN
config: closeFTPControl: start_command: /sbin/iptables -D INPUT -s %IP% -p tcp --dport ftp -j ACCEPT
ethernet interface detected
Local IP: 192.168.1.111
listening on eth0...
客户端knock下
C:\>knock -v 192.168.1.111 55540:tcp 55542:tcp 55541:tcp
hitting tcp 192.168.1.111:55540
hitting tcp 192.168.1.111:55542
hitting tcp 192.168.1.111:55541
服务器收到正确序列,执行动作,打开ftp端口。
2009-09-12 22:42:22: tcp: 192.168.1.110:51808 -> 192.168.1.111:55540 66 bytes
192.168.1.110: openFTPControl: Stage 1
2009-09-12 22:42:22: tcp: 192.168.1.110:51809 -> 192.168.1.111:55542 66 bytes
192.168.1.110: openFTPControl: Stage 2
2009-09-12 22:42:22: tcp: 192.168.1.110:51810 -> 192.168.1.111:55541 66 bytes
192.168.1.110: openFTPControl: Stage 3
192.168.1.110: openFTPControl: OPEN SESAME
openFTPControl: running command: /sbin/iptables -I INPUT -s 192.168.1.110 -p tcp --dport ftp -j ACCEPT
这个时候客户端可以ftp登录,通过原来开放的数据传输端口传文件。
使用完毕,通过另一个knock序列关闭ftp端口
C:\>knock -v 192.168.1.111 55541:tcp 55542:tcp 55540:tcp
hitting tcp 192.168.1.111:55541
hitting tcp 192.168.1.111:55542
hitting tcp 192.168.1.111:55540
服务器端关闭ftp端口。
removing successful knock attempt (192.168.1.110)
192.168.1.110: closeFTPControl: Stage 1
2009-09-12 22:49:08: tcp: 192.168.1.110:51917 -> 192.168.1.111:55542 66 bytes
192.168.1.110: closeFTPControl: Stage 2
2009-09-12 22:49:08: tcp: 192.168.1.110:51918 -> 192.168.1.111:55540 66 bytes
192.168.1.110: closeFTPControl: Stage 3
192.168.1.110: closeFTPControl: OPEN SESAME
closeFTPControl: running command: /sbin/iptables -D INPUT -s 192.168.1.110 -p tcp --dport ftp -j ACCEPT
家庭实际使用中,一般会有路由器,典型的网络拓扑:
knock服务器是运行在最好直接运行在路由器上,比如我刷dd-wrt的linksys WRT54G就可以。
参见: http://www.dd-wrt.com/wiki/index.php/Knockd
另一种适合大家的方法是在路由器做NAT,knock服务器程序运行在内网Linux中。
以ssh为例,我们就需要为外网能knock到CentOS1(IP:192.168.1.111),成功后能访问ssh,需在路由器中设定NAT(Port forwarding)。
当然你自己内网访问就不需要每次连接前knock下这么麻烦了,在防火墙规则里加条允许内网的ssh和ftp的连接。
iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 21 -j ACCEPT
iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 22 -j ACCEPT
可以将knockd配置成initd service的方式以方便开机启动,这个就交给大家自己实现了。
最后附上看到的一篇小诗[http://www.yuandao.com/dispbbs.a ... ID=32624&page=7]:
《敲门》
第一次敲门
是敲不开的
除非是大贤大德
乘愿重来的菩萨
第一次进不了门
倒有可能被怪物
跟踪恐吓
甚至抓起来
第二次再来敲门
说明已经通过考验
我会大开柴门
迎你进来
2009-1-5
文中提到的有些信息就不细讲了,请参考:
1) 一般sshd 安全配置:
http://www.foogazi.com/2006/11/29/modify-ssh-to-maximize-security/
2) fail2ban使用
http://www.fail2ban.org/wiki/index.php/Main_Page
3) portknocking介绍
http://www.portknocking.org/view/about
4) 本文使用的Port knocking实现
http://www.zeroflux.org/projects/knock
5) 鸟哥图文并茂的介绍:
http://linux.vbird.org/linux_security/knockd.php
草稿20091013
需求来源:
家里的Linux主机平时对internet开放着ssh。
经常有人尝试来暴力破解,曾改过ssh的port,好多了,不过这只是模糊安全。也装了fail2ban来限制攻击者的IP,但是攻击者频繁换IP的话fail2ban也没辙。
这次找到了新的方式:Port Knocking,原理很简单,不过挺有创意的。
Port Knocking 简介
为了开放ssh,一般我们让iptables允许ssh进入,不管来自哪里的ip。其实我们只需要为要登录的IP开iptables就可以了(白名单),封锁其他地址对ssh的访问。
可是很多时候不同的外网访问,我们是动态IP,需要让iptables对动态的IP开放SSH如何来实现呢,下面就介绍Port knocking(端口试探/端口碰撞):
Port knocking类似于一次地下组织秘密接头,一种最基本的方式:发送一定序列的UDP、TCP数据包。当运行在主机上的daemon程序捕捉到数据包以后,如果这个序列正确,则开启相应的端口,或者防火墙允许客户端通过。
一次简单的“敲门”流程
1.sshd开放中默认22端口,但是目前防火墙iptables还未允许我的IP通过。
2.Port knocking服务端初始化接头暗号(先敲端口7000再敲8000,TCP协议)和对应操作(对了就对此IP开通ssh的访问)
3.客户端对服务器不同端口进行knock(先7000再8000),发送SYN连接请求。
4.这些端口的连接对上了服务器端就会做些预定义操作为此IP开SSH端口。
5.这时我客户端就可以去连ssh的22端口了。
上面的接头暗号可以是TCP,UDP甚至是ICMP。
借用http://www.portknocking.org/view/about的图示,比较生动形象:
1.默认情况下客户端对服务器的应用由于防火墙不能访问
2.客户端敲正确的端口序列
3.服务器端Port Knocking(PK)程序打开防火墙端口
4.客户端可以访问了
Port Knocking 技术原理
Port knocking会在数据链路层(TODO,verify it?)监听所有的网络数据,类似嗅探程序,所以在不开端口,防火墙不允许此端口都可以接受到一定状态的数据包(如TCP SYN,为TCP三次握手第一个报文),当符合规则的报文出现时,规则开始记录,接下去的报文为正确下一个序列继续,错误就清空。当满足一次正确序列时就可以认为是一次event,触发一个action。
Port Knocking 优缺点
优点:
Port knocking 没监听端口,而且也不需要防火墙先开放这些Knock端口,可以隐藏你开放的服务,别人没法知道你是否使用了Port Knocking。
信息是由一定的端口访问顺序来传输的,而不是网络报文内容,所以不容易被报文嗅探工具截获。
阻止0day攻击。当服务器bug还没补丁前,Port Knocking可以做为一层防护。
Port Knocking增加了一层保护,即使在PK和防火墙都失效的情况下,ssh本身的安全验证机制也能很好的保护系统。
缺点:
如果port knocking Daemon挂了话相当于你家的门坏了,有钥匙也进不了。这个称为单点故障,即此服务停止的话整个系统不能工作。不过新的实现一般都检测daemon是否正常。
不是很方便,连ssh前需要先knock下,要使用专门软件,当然很多能发送连接请求的程序都可以的,客户端要对这个端口序列的保密工作,
Port Knocking不能用于Web,Mail。
Port knocking 实践
好,现在是实践下的时候了,search了下yum,发现有个叫knockd软件包(port knocking的实现其实很多的,这里有个列表: http://www.portknocking.org/view/implementations)。
1.ssh管理,根据鸟哥的文章做了下面的配置:
主要思想:
敲对了开端口,敲开门后cmd_timeout超时后再关闭。因为SSH只要在这个时间连接后防火墙关闭SSH端口对已有连接不会有影响。
/etc/knockd.conf
[options]
UseSyslog
[opencloseSSH]
sequence = 44440:udp,44442:udp,44441:udp
seq_timeout = 30
tcpflags = syn,ack
start_command = /sbin/iptables -I INPUT -s %IP% -p tcp --dport ssh -j ACCEPT
cmd_timeout = 300
stop_command = /sbin/iptables -D INPUT -s %IP% -p tcp --dport ssh -j ACCEPT
iptable未开放SSH
[root@CentOS1 ~]# iptables -nL INPUT
Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
启动port knocking daemon,这里开了调试和Verbose选项。
[root@CentOS1 ~]# knockd -D -v
config: new section: 'options'
config: usesyslog
config: new section: 'opencloseSSH'
config: opencloseSSH: sequence: 44440:udp,44442:udp,44441:udp
config: opencloseSSH: seq_timeout: 30
config: tcp flag: SYN
config: tcp flag: ACK
config: opencloseSSH: start_command: /sbin/iptables -I INPUT -s %IP% -p tcp --dport ssh -j ACCEPT
config: opencloseSSH: cmd_timeout: 300
config: opencloseSSH: stop_command: /sbin/iptables -D INPUT -s %IP% -p tcp --dport ssh -j ACCEPT
ethernet interface detected
Local IP: 192.168.1.111
listening on eth0...
客户端来敲下,使用了windows下的程序:
knock的Win32客户端程序:
http://www.zeroflux.org/proj/knock/files/knock-win32.zip
C:\>knock.exe -v 192.168.1.111 44440:udp 44442:udp 44441:udp
hitting udp 192.168.1.111:44440
hitting udp 192.168.1.111:44442
hitting udp 192.168.1.111:44441
服务器端监视到了正确的端口序列,触发动作,OPEN SESAME(芝麻开门!) 开放了SSH端口。
2009-09-12 00:27:25: udp: 192.168.1.110:54204 -> 192.168.1.111:44440 60 bytes
192.168.1.110: opencloseSSH: Stage 1
2009-09-12 00:27:25: udp: 192.168.1.110:54205 -> 192.168.1.111:44442 60 bytes
192.168.1.110: opencloseSSH: Stage 2
2009-09-12 00:27:25: udp: 192.168.1.110:54206 -> 192.168.1.111:44441 60 bytes
192.168.1.110: opencloseSSH: Stage 3
192.168.1.110: opencloseSSH: OPEN SESAME
opencloseSSH: running command: /sbin/iptables -I INPUT -s 192.168.1.110 -p tcp --dport ssh -j ACCEPT
iptables中已经加了允许条目。
[root@CentOS1 ~]# iptables -nL INPUT
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT tcp -- 192.168.1.110 0.0.0.0/0 tcp dpt:22
RH-Firewall-1-INPUT all -- 0.0.0.0/0 0.0.0.0/0
这个时候我的ssh客户端就可以登录了。
超过门敲开后的时间自动关闭。很安全的自动门吧。
192.168.1.110: opencloseSSH: command timeout
opencloseSSH: running command: /sbin/iptables -D INPUT -s 192.168.1.110 -p tcp --dport ssh -j ACCEPT
2.ftp管理:
ftp这个古老的协议虽然不安全,但是传输效率无疑是比较高的。
这里vsftpd命令端口监听在默认的21端口,数据传输使用passive模式,开放在5000~50010,初始情况下iptables不允许对21的访问。
建立两个port knocking序列,一个开,一个关。
/etc/knockd.conf
[options]
UseSyslog
[openFTPControl]
sequence = 55540:tcp,55542:tcp,55541:tcp
seq_timeout = 30
tcpflags = syn
command = /sbin/iptables -I INPUT -s %IP% -p tcp --dport ftp -j ACCEPT
[closeFTPControl]
sequence = 55541:tcp,55542:tcp,55540:tcp
seq_timeout = 30
tcpflags = syn
command = /sbin/iptables -D INPUT -s %IP% -p tcp --dport ftp -j ACCEPT
Port knock服务器启动:
[root@CentOS1 ~]# knockd -D -v
config: new section: 'options'
config: usesyslog
config: new section: 'openFTPControl'
config: openFTPControl: sequence: 55540:tcp,55542:tcp,55541:tcp
config: openFTPControl: seq_timeout: 30
config: tcp flag: SYN
config: openFTPControl: start_command: /sbin/iptables -I INPUT -s %IP% -p tcp --dport ftp -j ACCEPT
config: new section: 'closeFTPControl'
config: closeFTPControl: sequence: 55541:tcp,55542:tcp,55540:tcp
config: closeFTPControl: seq_timeout: 30
config: tcp flag: SYN
config: closeFTPControl: start_command: /sbin/iptables -D INPUT -s %IP% -p tcp --dport ftp -j ACCEPT
ethernet interface detected
Local IP: 192.168.1.111
listening on eth0...
客户端knock下
C:\>knock -v 192.168.1.111 55540:tcp 55542:tcp 55541:tcp
hitting tcp 192.168.1.111:55540
hitting tcp 192.168.1.111:55542
hitting tcp 192.168.1.111:55541
服务器收到正确序列,执行动作,打开ftp端口。
2009-09-12 22:42:22: tcp: 192.168.1.110:51808 -> 192.168.1.111:55540 66 bytes
192.168.1.110: openFTPControl: Stage 1
2009-09-12 22:42:22: tcp: 192.168.1.110:51809 -> 192.168.1.111:55542 66 bytes
192.168.1.110: openFTPControl: Stage 2
2009-09-12 22:42:22: tcp: 192.168.1.110:51810 -> 192.168.1.111:55541 66 bytes
192.168.1.110: openFTPControl: Stage 3
192.168.1.110: openFTPControl: OPEN SESAME
openFTPControl: running command: /sbin/iptables -I INPUT -s 192.168.1.110 -p tcp --dport ftp -j ACCEPT
这个时候客户端可以ftp登录,通过原来开放的数据传输端口传文件。
使用完毕,通过另一个knock序列关闭ftp端口
C:\>knock -v 192.168.1.111 55541:tcp 55542:tcp 55540:tcp
hitting tcp 192.168.1.111:55541
hitting tcp 192.168.1.111:55542
hitting tcp 192.168.1.111:55540
服务器端关闭ftp端口。
removing successful knock attempt (192.168.1.110)
192.168.1.110: closeFTPControl: Stage 1
2009-09-12 22:49:08: tcp: 192.168.1.110:51917 -> 192.168.1.111:55542 66 bytes
192.168.1.110: closeFTPControl: Stage 2
2009-09-12 22:49:08: tcp: 192.168.1.110:51918 -> 192.168.1.111:55540 66 bytes
192.168.1.110: closeFTPControl: Stage 3
192.168.1.110: closeFTPControl: OPEN SESAME
closeFTPControl: running command: /sbin/iptables -D INPUT -s 192.168.1.110 -p tcp --dport ftp -j ACCEPT
家庭实际使用中,一般会有路由器,典型的网络拓扑:
knock服务器是运行在最好直接运行在路由器上,比如我刷dd-wrt的linksys WRT54G就可以。
参见: http://www.dd-wrt.com/wiki/index.php/Knockd
另一种适合大家的方法是在路由器做NAT,knock服务器程序运行在内网Linux中。
以ssh为例,我们就需要为外网能knock到CentOS1(IP:192.168.1.111),成功后能访问ssh,需在路由器中设定NAT(Port forwarding)。
当然你自己内网访问就不需要每次连接前knock下这么麻烦了,在防火墙规则里加条允许内网的ssh和ftp的连接。
iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 21 -j ACCEPT
iptables -I INPUT -s 192.168.1.0/24 -p tcp --dport 22 -j ACCEPT
可以将knockd配置成initd service的方式以方便开机启动,这个就交给大家自己实现了。
最后附上看到的一篇小诗[http://www.yuandao.com/dispbbs.a ... ID=32624&page=7]:
《敲门》
第一次敲门
是敲不开的
除非是大贤大德
乘愿重来的菩萨
第一次进不了门
倒有可能被怪物
跟踪恐吓
甚至抓起来
第二次再来敲门
说明已经通过考验
我会大开柴门
迎你进来
2009-1-5
文中提到的有些信息就不细讲了,请参考:
1) 一般sshd 安全配置:
http://www.foogazi.com/2006/11/29/modify-ssh-to-maximize-security/
2) fail2ban使用
http://www.fail2ban.org/wiki/index.php/Main_Page
3) portknocking介绍
http://www.portknocking.org/view/about
4) 本文使用的Port knocking实现
http://www.zeroflux.org/projects/knock
5) 鸟哥图文并茂的介绍:
http://linux.vbird.org/linux_security/knockd.php
Linux Serial console Linux串口终端配置
目的: 台机已经装好Linux,显示器有问题,平时一般都SSH控制,当Linux网络挂的时候,想通过串口来管理。
硬件:台机自带两个串口(上面的是COM1)[under Windows] or ttyS0[under Linux)),笔记本T61p没有串口,买了个USB转串口(具体见下图)。同时需要串口交叉线一根(NULL modem Cable),母对母(公的是针),都是凹口那种。
目标机器:安装的CentOS 5.2 Linux 内核2.6.18-92.1.22.el5和2.6.18-92.1.22.el5xen
客户端: Windows XP SP3 IBM OEM. 安装USB转串口驱动。
需要把输出定向到串口,一般有下面几处:
1.
BIOS中的设置
2.
GRUB设置
3.
/etc/inittab 设置
4.
/etc/securetty 设置
BIOS中的设置
BIOS设置的作用我没尝试过,如果是可以连BIOS设置都可以定向到串口,那个强大了。也不知道如何去掉机器需要连键盘的限制。没拿出显示器所以没看我台机的BIOS,不过这个功能一般只有服务器级别的机器有。【注1】台机一般没有串口重定向功能。
GRUB设置
这里的配置是为了把grub菜单定向到串口,这样你就可以在串口操作grub,选择启动项,使用single mode等等。
同时也要给kernel参数加上console选项。
[root@CentOS5 ~]# cat /boot/grub/menu.lst
# 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,0)
# kernel /vmlinuz-version ro root=/dev/vg00/lv_root
# initrd /initrd-version.img
#boot=/dev/hdb1
serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1
terminal --timeout=10 serial console
default=2
timeout=20
#splashimage=(hd0,0)/grub/splash.xpm.gz =>这些在console下会工作不正常,注释掉。
#hiddenmenu
title CentOS (2.6.18-92.1.22.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-92.1.22.el5 ro root=/dev/vg00/lv_root rhgb quiet
initrd /initrd-2.6.18-92.1.22.el5.img
title CentOS Serial[ttyS0] - Console (2.6.18-92.1.22.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-92.1.22.el5 ro root=/dev/vg00/lv_root console=ttyS0,9600 console=tty0
initrd /initrd-2.6.18-92.1.22.el5.img
title CentOS Console - serial[ttyS0] (2.6.18-92.1.22.el5) [get more output in serial console]
root (hd0,0)
kernel /vmlinuz-2.6.18-92.1.22.el5 ro root=/dev/vg00/lv_root console=tty0 console=ttyS0,9600
initrd /initrd-2.6.18-92.1.22.el5.img
title CentOS Xen (2.6.18-92.1.22.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-92.1.22.el5
module /vmlinuz-2.6.18-92.1.22.el5xen ro root=/dev/vg00/lv_root rhgb quiet xencons=off
module /initrd-2.6.18-92.1.22.el5xen.img
title CentOS Xen Serial[ttyS0] - Console (2.6.18-92.1.22.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-92.1.22.el5
module /vmlinuz-2.6.18-92.1.22.el5xen ro root=/dev/vg00/lv_root xencons=off console=ttyS0,9600 console=tty0
module /initrd-2.6.18-92.1.22.el5xen.img
title CentOS Xen Console - serial[ttyS0] (2.6.18-92.1.22.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-92.1.22.el5
module /vmlinuz-2.6.18-92.1.22.el5xen ro root=/dev/vg00/lv_root xencons=off console=tty0 console=ttyS0,9600
module /initrd-2.6.18-92.1.22.el5xen.img
title Other
rootnoverify (hd0,0)
chainloader +1
后面的console有顺序关系,详见下文【注2】,我常用串口所以console=tty0 console=ttyS0,9600这个顺序的输出信息比较多。
因为我的机器有xen的内核,xen默认情况下会把串口做为xencons,所以这里设置xencons=off.
When multiple consoles are listed output is sent to all consoles and input is taken from the last listed console. The last console is the one Linux uses as the /dev/console device.
/etc/inittab 设置
系统系统后,需要在串口上监听请求,所以要有个类似服务器的程序(agetty, mgetty etc)。
/etc/inittab中添加
s0:2345:respawn:/sbin/agetty -L -f /etc/issue.serial 9600 ttyS0 vt100
#s1:2345:respawn:/sbin/agetty -L -f /etc/issue.serial 9600 ttyS1 vt100
#S0:2345:respawn:/sbin/mgetty -r -x 9 ttyS0 ==> mgetty 用来调试比较好,log也丰富。
What is a getty?
A getty is is a program that opens a tty port, prompts for a login name, and runs the /bin/login command. It is normally invoked by init.
所以其他程序就不能再来占用ttyS0了,串口是独占模式的吧。
vt100:
vt100 is the terminal emulation. You can use others, but VT100 is the most common or "standard". Another widely used termial type is VT102.
OK都可以了,可以重启server了。这里如果想测试下串口线,推荐先在Linux启动下mgetty,因为他的debug信息和log比较丰富,适合排错和测试。
#mgetty –r –x 9 ttyS0
Log在/var/log/mgetty*中。
/etc/securetty设置
因为一般我们都是使用root登陆串口来维护,所以需要设置root可以在COM1和COM2登陆。
在/etc/securetty中添加:
ttyS0
ttyS1
Windows客户端连接可以用超级终端或者Putty。
注意启动server的时候,putty就应该去连接串口了,这样才可以看到所有信息。
Press any key to continue.
Grub menu
Booting.
本来正常情况下,接下去kernel的boot信息应该也会打到串口的。但是没有,确定是Xen内核的关系。【注3】好像有人已经碰到这个问题了。
系统启动起来后,过了init,agetty就起来了,这个时候就可以通过串口登陆了。(在/etc/securetty中需要添加ttyS0)
后记:
在做这次实验的时候开始心里很没底,因为串口从来没搞过。虽然编程时涉及过串口编程,但到我这边已经只是网络编程了。买了一个USB转串口接口,两个串口交叉线。我想要NULL modem线,店主不知道(额…), 开始不工作时一度怀疑线有问题。
还有就是开始不理解串口工作原理,我知道串口是字符设备,有啥数据得当时就去读。曾经我连了串口并开了Putty去连,界面上没输出。1)因为当时就是没数据。 2)是有时候终端需要按键来激活(比如按几下回车)。
还有就是可能终端设置问题。这块我现在还不太清楚。因为终端设置涉及到有些键盘操作,比如删除。我好几次发现Backspace键没反应而重启过好几次机器。后来发现我的终端设置需要先<= = 左箭头左移然后 delete。
我的主板说明书上接口图:
【注1】:
http://www.linux.org/docs/ldp/howto/Remote-Serial-Console-HOWTO/rhl-biosserial.html
C.2. Configure the BIOS to use the serial port
Many servers allow the BIOS to be configured from the serial port, especially on systems designed for rack mounting. At the moment few machines designed to be used as desktop systems allow the BIOS to be accessed from the serial port.
【注2】:
http://tldp.org/HOWTO/Remote-Serial-Console-HOWTO/configure-kernel.html
Chapter 5. Configure Linux kernel
The Linux kernel is configured to select the console by passing it the console parameter. The console parameter can be given repeatedly, but the parameter can only be given once for each console technology. So console=tty0 console=lp0 console=ttyS0 is acceptable but console=ttyS0 console=ttyS1 will not work.
When multiple consoles are listed output is sent to all consoles and input is taken from the last listed console. The last console is the one Linux uses as the /dev/console device.
【注3】:
https://vb.serverknecht.de/showthread.php?t=129174
硬件:台机自带两个串口(上面的是COM1)[under Windows] or ttyS0[under Linux)),笔记本T61p没有串口,买了个USB转串口(具体见下图)。同时需要串口交叉线一根(NULL modem Cable),母对母(公的是针),都是凹口那种。
目标机器:安装的CentOS 5.2 Linux 内核2.6.18-92.1.22.el5和2.6.18-92.1.22.el5xen
客户端: Windows XP SP3 IBM OEM. 安装USB转串口驱动。
需要把输出定向到串口,一般有下面几处:
1.
BIOS中的设置
2.
GRUB设置
3.
/etc/inittab 设置
4.
/etc/securetty 设置
BIOS中的设置
BIOS设置的作用我没尝试过,如果是可以连BIOS设置都可以定向到串口,那个强大了。也不知道如何去掉机器需要连键盘的限制。没拿出显示器所以没看我台机的BIOS,不过这个功能一般只有服务器级别的机器有。【注1】台机一般没有串口重定向功能。
GRUB设置
这里的配置是为了把grub菜单定向到串口,这样你就可以在串口操作grub,选择启动项,使用single mode等等。
同时也要给kernel参数加上console选项。
[root@CentOS5 ~]# cat /boot/grub/menu.lst
# 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,0)
# kernel /vmlinuz-version ro root=/dev/vg00/lv_root
# initrd /initrd-version.img
#boot=/dev/hdb1
serial --unit=0 --speed=9600 --word=8 --parity=no --stop=1
terminal --timeout=10 serial console
default=2
timeout=20
#splashimage=(hd0,0)/grub/splash.xpm.gz =>这些在console下会工作不正常,注释掉。
#hiddenmenu
title CentOS (2.6.18-92.1.22.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-92.1.22.el5 ro root=/dev/vg00/lv_root rhgb quiet
initrd /initrd-2.6.18-92.1.22.el5.img
title CentOS Serial[ttyS0] - Console (2.6.18-92.1.22.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-92.1.22.el5 ro root=/dev/vg00/lv_root console=ttyS0,9600 console=tty0
initrd /initrd-2.6.18-92.1.22.el5.img
title CentOS Console - serial[ttyS0] (2.6.18-92.1.22.el5) [get more output in serial console]
root (hd0,0)
kernel /vmlinuz-2.6.18-92.1.22.el5 ro root=/dev/vg00/lv_root console=tty0 console=ttyS0,9600
initrd /initrd-2.6.18-92.1.22.el5.img
title CentOS Xen (2.6.18-92.1.22.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-92.1.22.el5
module /vmlinuz-2.6.18-92.1.22.el5xen ro root=/dev/vg00/lv_root rhgb quiet xencons=off
module /initrd-2.6.18-92.1.22.el5xen.img
title CentOS Xen Serial[ttyS0] - Console (2.6.18-92.1.22.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-92.1.22.el5
module /vmlinuz-2.6.18-92.1.22.el5xen ro root=/dev/vg00/lv_root xencons=off console=ttyS0,9600 console=tty0
module /initrd-2.6.18-92.1.22.el5xen.img
title CentOS Xen Console - serial[ttyS0] (2.6.18-92.1.22.el5xen)
root (hd0,0)
kernel /xen.gz-2.6.18-92.1.22.el5
module /vmlinuz-2.6.18-92.1.22.el5xen ro root=/dev/vg00/lv_root xencons=off console=tty0 console=ttyS0,9600
module /initrd-2.6.18-92.1.22.el5xen.img
title Other
rootnoverify (hd0,0)
chainloader +1
后面的console有顺序关系,详见下文【注2】,我常用串口所以console=tty0 console=ttyS0,9600这个顺序的输出信息比较多。
因为我的机器有xen的内核,xen默认情况下会把串口做为xencons,所以这里设置xencons=off.
When multiple consoles are listed output is sent to all consoles and input is taken from the last listed console. The last console is the one Linux uses as the /dev/console device.
/etc/inittab 设置
系统系统后,需要在串口上监听请求,所以要有个类似服务器的程序(agetty, mgetty etc)。
/etc/inittab中添加
s0:2345:respawn:/sbin/agetty -L -f /etc/issue.serial 9600 ttyS0 vt100
#s1:2345:respawn:/sbin/agetty -L -f /etc/issue.serial 9600 ttyS1 vt100
#S0:2345:respawn:/sbin/mgetty -r -x 9 ttyS0 ==> mgetty 用来调试比较好,log也丰富。
What is a getty?
A getty is is a program that opens a tty port, prompts for a login name, and runs the /bin/login command. It is normally invoked by init.
所以其他程序就不能再来占用ttyS0了,串口是独占模式的吧。
vt100:
vt100 is the terminal emulation. You can use others, but VT100 is the most common or "standard". Another widely used termial type is VT102.
OK都可以了,可以重启server了。这里如果想测试下串口线,推荐先在Linux启动下mgetty,因为他的debug信息和log比较丰富,适合排错和测试。
#mgetty –r –x 9 ttyS0
Log在/var/log/mgetty*中。
/etc/securetty设置
因为一般我们都是使用root登陆串口来维护,所以需要设置root可以在COM1和COM2登陆。
在/etc/securetty中添加:
ttyS0
ttyS1
Windows客户端连接可以用超级终端或者Putty。
注意启动server的时候,putty就应该去连接串口了,这样才可以看到所有信息。
Press any key to continue.
Grub menu
Booting.
本来正常情况下,接下去kernel的boot信息应该也会打到串口的。但是没有,确定是Xen内核的关系。【注3】好像有人已经碰到这个问题了。
系统启动起来后,过了init,agetty就起来了,这个时候就可以通过串口登陆了。(在/etc/securetty中需要添加ttyS0)
后记:
在做这次实验的时候开始心里很没底,因为串口从来没搞过。虽然编程时涉及过串口编程,但到我这边已经只是网络编程了。买了一个USB转串口接口,两个串口交叉线。我想要NULL modem线,店主不知道(额…), 开始不工作时一度怀疑线有问题。
还有就是开始不理解串口工作原理,我知道串口是字符设备,有啥数据得当时就去读。曾经我连了串口并开了Putty去连,界面上没输出。1)因为当时就是没数据。 2)是有时候终端需要按键来激活(比如按几下回车)。
还有就是可能终端设置问题。这块我现在还不太清楚。因为终端设置涉及到有些键盘操作,比如删除。我好几次发现Backspace键没反应而重启过好几次机器。后来发现我的终端设置需要先<= = 左箭头左移然后 delete。
我的主板说明书上接口图:
【注1】:
http://www.linux.org/docs/ldp/howto/Remote-Serial-Console-HOWTO/rhl-biosserial.html
C.2. Configure the BIOS to use the serial port
Many servers allow the BIOS to be configured from the serial port, especially on systems designed for rack mounting. At the moment few machines designed to be used as desktop systems allow the BIOS to be accessed from the serial port.
【注2】:
http://tldp.org/HOWTO/Remote-Serial-Console-HOWTO/configure-kernel.html
Chapter 5. Configure Linux kernel
The Linux kernel is configured to select the console by passing it the console parameter. The console parameter can be given repeatedly, but the parameter can only be given once for each console technology. So console=tty0 console=lp0 console=ttyS0 is acceptable but console=ttyS0 console=ttyS1 will not work.
When multiple consoles are listed output is sent to all consoles and input is taken from the last listed console. The last console is the one Linux uses as the /dev/console device.
【注3】:
https://vb.serverknecht.de/showthread.php?t=129174
2008年2月18日星期一
VMware使用物理硬盘来启动已安装的Linux系统
看了些文章: <<一种穷人利用vmware玩FreeBSD的方法>>
"1)要做很大工作量的东西,用真实机器开FreeBSD。
2)当要用windows做些东西的时候用vmware开FreeBSD。
但是这两种情况都是用同一份FreeBSD",这就是我想要的, 文中更提到 "注意一定要第一个硬盘" ,有点不解."因为,如果从真实的物理硬盘(phisical hardisk)启动,该物理磁盘必须是要接在主盘。"vmware手册还在翻. http://www.freebsdchina.org/foru%20...%20mp;highlight=vmware
<<虚拟与现实的完美结合>> 这篇文章的主要思想是不同的VMware虚拟机可以通过共享虚拟机硬盘文件,可以建立配置不同的虚拟机(比如网络不同) 和我要的效果有点不.
http://fanqiang.chinaunix.net/adm/net/2005-03-17/2941.shtml
觉的VMware的使用物理硬盘功能是个很好的方法。
特别对我现在的情况是很有帮助的。
我现在的状态(学习需要):
真实机器安装了windows xp 和 RHEL5+oracle+其他服务器.
同时又在windows下装VMware里面装了RHEL5+oracle+其他服务器:
为了开发和调试方便。 现在我就有了两份RHEL5+oracle+其他服务器. 又占空间又同步麻烦。
如果我能用vmware去启动我的物理RHEL, 同时又可以使用oracle等服务,那就很完美了。
现在是初步目的,wmware能启动RHEL.也不用启动X-window,跑level3就可以了。 因为物理机器很vmware硬件的不同,可能在启动中和使用中会碰到很多问题,不知道有没有人有这方面经验(可能对linux的掌握要求更多)。也许需要有个新的内核和另外一套配置。这样物理RHEL启动用一套,vmware来启动用另一套。
目的:
在虚拟机VMware中启动原来物理安装的Linux.系统描述:两块IDE硬盘,硬盘1分了3个区,C盘装了Windows XP, 硬盘2也分了几个区,其中1个是FAT32,放windows下数据的,剩下的装了个RHEL5.启动相关信息:RHEL5 分区比较简单, /boot没有特别分区, GRUB装在 /hdb1 (第二块硬盘第一主分区,这就是我开始的问题所在), 用dd命令( dd if=/dev/hdb1 of=/mnt/file/rhel5.lnx bs=512 count=1) rhel5.lnx 用windows os loader 引导(在boot.ini中添加).
下面是我的尝试:一开始vmware建立个虚拟机,在选硬盘是选择使用整个硬盘(硬盘2),启动vmware,屏幕卡在GRUB _ 一开始我以为是grub背景图得不到,去掉背景后还是不行.在看VMware手册时看到,vmware启动先去看MBR, 现在我把硬盘2给vmware用,在vmware看来,它有个硬盘,但是这个硬盘的MBR是空的. 为了测试是否就是它引起的,我重启进BIOS把硬盘2改为第一启动,硬盘1不启动.重启发现屏幕卡在GRUB _. 确定了问题所在. 接下去就看我怎么做吧.
下面是我的做法:不是很完美,但是目前我的目的已经达到了.根据VMware 文档描述, 使用物理硬盘是比较危险的,大家不清楚不要轻易尝试,要记得备份数据.为了避免不必要的问题. 我先把硬盘2里的FAT32分区在windows中删除(不会删数据),我的电脑右键-->管理-->磁盘管理 选中分区 右键"更改驱动器名和路径"再"删除".真实启动到RHEL5,grub-install /dev/hdb (将GRUB装到硬盘2 BMR,原来是装在/dev/hdb1).
修改/etc/inittab ,run level改为3,不启动X-window,因为原来的显卡驱动在vmware下肯定用不了.id:5:initdefault: 改为 id:3:initdefault:
添加一个入口在grub.conf (menu.lst). 原来:
title Red Hat Enterprise Linux Server (2.6.18-8.e15)
root (hd1,0)
kernel /boot/vmlinux-2.6.18-8.e15 ro root=LABEL=/1 rhgb quiet
initrd /boot/initrd-2.6.18-8.e15.img
添加( root (hd0,0) 因为VMware认为其硬盘是在主硬盘处的):
title Red Hat Enterprise Linux Server (2.6.18-8.e15) start in vmware
root (hd0,0)
kernel /boot/vmlinux-2.6.18-8.e15 ro root=LABEL=/1 rhgb quiet
initrd /boot/initrd-2.6.18-8.e15.img
确定/etc/fstab没有挂载其他硬盘分区.
重启, 修改BIOS,设置第一启动为硬盘2,重启出现GRUB菜单(不再卡在GRUB_),确认GRUB安装是正确的.
现在可以进入windows,新建虚拟机,选择使用整个硬盘2. 启动,出现grub菜单,选择 Red Hat Enterprise Linux Server (2.6.18-8.e15) start in vmware 就可以进入.
Ok. 这样就可以虚拟机内使用原来安装在硬盘2上的linux上了.
接下去要做的和目前的不足:
1.现在想要物理启动硬盘2上的linux就需要改BIOS设置了.
2.vmware下现在还不能启动X-window.
至少因为虚拟机下的显卡和真实显卡不一样,真实机器已装了nvidia的启动.需要X-window暂时解决方法可以在 Host OS中开X (比如Xmanager).
3.硬盘2的linux分了很多区,怎么办. fstab在真实和虚假间需要不同.暂时解决方法:手动挂载
4.根据别人的提示,网卡将会有两套。一个真实的一个vmware虚拟的。这应该也是个问题。
其实完美的解决方案就是在grub那里,如果不同titile的grub入口通过不同参数的指定可以调用不同Xorg配置,fstab配置等等. 改天再看看grub的参数.(如好像 grub 有个 init=/sbin/init 的参数,重新写一份init给vmware用,来使用vmware下的xorg和fstab 等等)
"1)要做很大工作量的东西,用真实机器开FreeBSD。
2)当要用windows做些东西的时候用vmware开FreeBSD。
但是这两种情况都是用同一份FreeBSD",这就是我想要的, 文中更提到 "注意一定要第一个硬盘" ,有点不解."因为,如果从真实的物理硬盘(phisical hardisk)启动,该物理磁盘必须是要接在主盘。"vmware手册还在翻. http://www.freebsdchina.org/foru%20...%20mp;highlight=vmware
<<虚拟与现实的完美结合>> 这篇文章的主要思想是不同的VMware虚拟机可以通过共享虚拟机硬盘文件,可以建立配置不同的虚拟机(比如网络不同) 和我要的效果有点不.
http://fanqiang.chinaunix.net/adm/net/2005-03-17/2941.shtml
觉的VMware的使用物理硬盘功能是个很好的方法。
特别对我现在的情况是很有帮助的。
我现在的状态(学习需要):
真实机器安装了windows xp 和 RHEL5+oracle+其他服务器.
同时又在windows下装VMware里面装了RHEL5+oracle+其他服务器:
为了开发和调试方便。 现在我就有了两份RHEL5+oracle+其他服务器. 又占空间又同步麻烦。
如果我能用vmware去启动我的物理RHEL, 同时又可以使用oracle等服务,那就很完美了。
现在是初步目的,wmware能启动RHEL.也不用启动X-window,跑level3就可以了。 因为物理机器很vmware硬件的不同,可能在启动中和使用中会碰到很多问题,不知道有没有人有这方面经验(可能对linux的掌握要求更多)。也许需要有个新的内核和另外一套配置。这样物理RHEL启动用一套,vmware来启动用另一套。
目的:
在虚拟机VMware中启动原来物理安装的Linux.系统描述:两块IDE硬盘,硬盘1分了3个区,C盘装了Windows XP, 硬盘2也分了几个区,其中1个是FAT32,放windows下数据的,剩下的装了个RHEL5.启动相关信息:RHEL5 分区比较简单, /boot没有特别分区, GRUB装在 /hdb1 (第二块硬盘第一主分区,这就是我开始的问题所在), 用dd命令( dd if=/dev/hdb1 of=/mnt/file/rhel5.lnx bs=512 count=1) rhel5.lnx 用windows os loader 引导(在boot.ini中添加).
下面是我的尝试:一开始vmware建立个虚拟机,在选硬盘是选择使用整个硬盘(硬盘2),启动vmware,屏幕卡在GRUB _ 一开始我以为是grub背景图得不到,去掉背景后还是不行.在看VMware手册时看到,vmware启动先去看MBR, 现在我把硬盘2给vmware用,在vmware看来,它有个硬盘,但是这个硬盘的MBR是空的. 为了测试是否就是它引起的,我重启进BIOS把硬盘2改为第一启动,硬盘1不启动.重启发现屏幕卡在GRUB _. 确定了问题所在. 接下去就看我怎么做吧.
下面是我的做法:不是很完美,但是目前我的目的已经达到了.根据VMware 文档描述, 使用物理硬盘是比较危险的,大家不清楚不要轻易尝试,要记得备份数据.为了避免不必要的问题. 我先把硬盘2里的FAT32分区在windows中删除(不会删数据),我的电脑右键-->管理-->磁盘管理 选中分区 右键"更改驱动器名和路径"再"删除".真实启动到RHEL5,grub-install /dev/hdb (将GRUB装到硬盘2 BMR,原来是装在/dev/hdb1).
修改/etc/inittab ,run level改为3,不启动X-window,因为原来的显卡驱动在vmware下肯定用不了.id:5:initdefault: 改为 id:3:initdefault:
添加一个入口在grub.conf (menu.lst). 原来:
title Red Hat Enterprise Linux Server (2.6.18-8.e15)
root (hd1,0)
kernel /boot/vmlinux-2.6.18-8.e15 ro root=LABEL=/1 rhgb quiet
initrd /boot/initrd-2.6.18-8.e15.img
添加( root (hd0,0) 因为VMware认为其硬盘是在主硬盘处的):
title Red Hat Enterprise Linux Server (2.6.18-8.e15) start in vmware
root (hd0,0)
kernel /boot/vmlinux-2.6.18-8.e15 ro root=LABEL=/1 rhgb quiet
initrd /boot/initrd-2.6.18-8.e15.img
确定/etc/fstab没有挂载其他硬盘分区.
重启, 修改BIOS,设置第一启动为硬盘2,重启出现GRUB菜单(不再卡在GRUB_),确认GRUB安装是正确的.
现在可以进入windows,新建虚拟机,选择使用整个硬盘2. 启动,出现grub菜单,选择 Red Hat Enterprise Linux Server (2.6.18-8.e15) start in vmware 就可以进入.
Ok. 这样就可以虚拟机内使用原来安装在硬盘2上的linux上了.
接下去要做的和目前的不足:
1.现在想要物理启动硬盘2上的linux就需要改BIOS设置了.
2.vmware下现在还不能启动X-window.
至少因为虚拟机下的显卡和真实显卡不一样,真实机器已装了nvidia的启动.需要X-window暂时解决方法可以在 Host OS中开X (比如Xmanager).
3.硬盘2的linux分了很多区,怎么办. fstab在真实和虚假间需要不同.暂时解决方法:手动挂载
4.根据别人的提示,网卡将会有两套。一个真实的一个vmware虚拟的。这应该也是个问题。
其实完美的解决方案就是在grub那里,如果不同titile的grub入口通过不同参数的指定可以调用不同Xorg配置,fstab配置等等. 改天再看看grub的参数.(如好像 grub 有个 init=/sbin/init 的参数,重新写一份init给vmware用,来使用vmware下的xorg和fstab 等等)
2007年12月27日星期四
(摘记)suse9.0在vmware5.0上安装刚开始就出现4分频
http://linux.chinaunix.net/bbs/thread-916977-1-1.html
Q:
suse9.0在vmware5.0上安装刚开始就出现4分频,安装一直无法进行下去,跪求,怎么解决?安装刚开始选择了“installation”后,就出现4分频,是什么问题呀?请教了
A:
1.vmware 安装的时候需要加参数 x11i=fbdev 安装,10以后就不用了。
2.不要用图形模式安装,按F2选 text.
3.这个问题我也遇到过,后来发现很简单,只要把你的windows颜色设置为中16位,不要设置32位,就不会再出现4分屏了。
Novel solution:
TIP: Can't Perform a GUI based Install
Environment VMware Workstation Version: 4.5.2 build-8848Host OS: Windows XPGuest OS: OES/SLES9sp2
Problem After selecting "Installation" from the initial Blue screen/menu the screen turns into a purple screen with either 2 or 4 duplicated consoles each with small green text that is hard to read. There is also an error message displayed that will not allow a GUI install.
Solution Here are some options:
Option 1 - Text-based Install Before selecting "Installation" from the blue boot menu, change to the mode to Text using F2. The install will start in Text mode. It is just like the GUI/YaST based install. Later you can install VMware Tools to get the GUI running locally in VMware.
Option 2 - GUI Install via VNC You can use "Boot Options" that will start VNC so you can run the GUI/YaST install portion of the install from either a VNC viewer or a browser. Later you can install VMware Tools to get the GUI running locally in VMware. To install via VNC:
Before selecting "Installation" from the Blue boot menu, add the following text to the "Boot Options": vnc=1 vncpassword=novell This will 1) enable vnc and 2) set the vncpassword to novell When the install is ready it will display the info you need to connect using VNC. e.g. Browser URL: "http://http://ip_address":5801
Misc Install Tips - If you select a "default" SLES 9 install, you should also install the gcc, gcc-devel, and kernel-source packages. These are needed for VMware Tools installation. - I recommend that you enable VNC remote administration so you can get to the GUI remotely. This may come in handy if you have problems with the X-server running locally in your VM.
Q:
suse9.0在vmware5.0上安装刚开始就出现4分频,安装一直无法进行下去,跪求,怎么解决?安装刚开始选择了“installation”后,就出现4分频,是什么问题呀?请教了
A:
1.vmware 安装的时候需要加参数 x11i=fbdev 安装,10以后就不用了。
2.不要用图形模式安装,按F2选 text.
3.这个问题我也遇到过,后来发现很简单,只要把你的windows颜色设置为中16位,不要设置32位,就不会再出现4分屏了。
Novel solution:
TIP: Can't Perform a GUI based Install
Environment VMware Workstation Version: 4.5.2 build-8848Host OS: Windows XPGuest OS: OES/SLES9sp2
Problem After selecting "Installation" from the initial Blue screen/menu the screen turns into a purple screen with either 2 or 4 duplicated consoles each with small green text that is hard to read. There is also an error message displayed that will not allow a GUI install.
Solution Here are some options:
Option 1 - Text-based Install Before selecting "Installation" from the blue boot menu, change to the mode to Text using F2. The install will start in Text mode. It is just like the GUI/YaST based install. Later you can install VMware Tools to get the GUI running locally in VMware.
Option 2 - GUI Install via VNC You can use "Boot Options" that will start VNC so you can run the GUI/YaST install portion of the install from either a VNC viewer or a browser. Later you can install VMware Tools to get the GUI running locally in VMware. To install via VNC:
Before selecting "Installation" from the Blue boot menu, add the following text to the "Boot Options": vnc=1 vncpassword=novell This will 1) enable vnc and 2) set the vncpassword to novell When the install is ready it will display the info you need to connect using VNC. e.g. Browser URL: "http://http://ip_address":5801
Misc Install Tips - If you select a "default" SLES 9 install, you should also install the gcc, gcc-devel, and kernel-source packages. These are needed for VMware Tools installation. - I recommend that you enable VNC remote administration so you can get to the GUI remotely. This may come in handy if you have problems with the X-server running locally in your VM.
订阅:
博文 (Atom)
回国科学上网姿势 软路由 通过apple私有Mac地址动态切换
回国科学上网姿势 软路由 通过apple私有Mac地址动态切换 断断续续的尝试了很多科学上网方式,自己搭VPS,家里路由器也升级了好几次,都是为了能装可以跑科学上网的固件,但是最大的问题是性能都一般,速度也不是很稳定。 最近软路由被提到较多,最吸引人的是可以达的速度非常高,可以看...
-
回国科学上网姿势 软路由 通过apple私有Mac地址动态切换 断断续续的尝试了很多科学上网方式,自己搭VPS,家里路由器也升级了好几次,都是为了能装可以跑科学上网的固件,但是最大的问题是性能都一般,速度也不是很稳定。 最近软路由被提到较多,最吸引人的是可以达的速度非常高,可以看...
-
CentOS Manager How to 管理手册 (for 内网用户) 1. network网络管理 2. user管理 3. oracle管理 4. download下载管理 5. security安全管理 6. Links...
-
elinks handle ed2k for mldonkey by lua OS:CentOS 5.3 需求来源: 此机器很大部分时间还是台电驴BT下载机。 有时候远程putty想加些mldonkey任务,一般可以通过mldonkey的 telnet console添加, 但是...