Chinaunix首页 | 论坛 | 博客
  • 博客访问: 325369
  • 博文数量: 65
  • 博客积分: 1770
  • 博客等级: 上尉
  • 技术积分: 1125
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-13 14:31
文章分类

全部博文(65)

文章存档

2016年(1)

2014年(2)

2013年(5)

2012年(18)

2011年(39)

分类: LINUX

2011-10-15 14:44:13

备份MBR分区
MBR :Master Boot Record 主开机扇区记录
在x86的系统中,系统硬盘位于第0号磁道:0到511KB的块区为MBR,开机管理程序使用这块区域来存储第一阶段的开机引导程序。接着位于1到62号磁道做为第1.5阶段的开机引导程序,从第63号磁道开始才是操作系统分区
MBR分为三个部分;0-445KB,是初始引导程序,也称为第一阶段的导引程序;446-509KB为磁盘分区表,内容包括分区标记、分区的起始位置、分区容量、分区类型等。最后一部分只占2KB,记录MBR标记代码。


#  查看分区信息
[root@localhost ~]# fdisk -l
Disk /dev/hda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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        1318    10482412+  83  Linux
/dev/hda3            1319        1579     2096482+  83  Linux
/dev/hda4            1580        5221    29254365    5  Extended
/dev/hda5            1580        1840     2096451   83  Linux
/dev/hda6            1972        2213     1943833+  8e  Linux LVM

#  MBR分区在/dev/hda1上,备份到/root/mbr下
#  dd命令 可备份某个文件或者整个分区,if 指定源文件,of 指定目标文件,bs指定块大小,count指定复制的块数量
[root@localhost ~]# dd if=/dev/hda1 of=/root/mbr bs=512 count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.000313997 seconds, 1.6 MB/s
系统无法启动时,可以采用“linux resue”模式启动,后把恢复MBR 分区
dd if=/root/mbr of=/dev/hda1  bs=512 count=1

恢复分区表
dd if=/root/mbr of=/dev/hda1 bs=512 skip=446 count=66
bs=512 skip=446 count=66  主要是指定分区表在备份文件中的位置

备份数据文件
#  查询在当前时间前5分钟建立的文件,并显示
#  -mmin -/+n    参数为少于/大于n分钟的时间,-print 参数表将结果输出到标准输出设备,可不加
#  -mtime -/+n    参数为少于/大于n天的时间
#  -cmin   -ctime 参数表文件属性发生变化的时间
#  -amin   -atime 参数表访问文件的时间变化

[root@localhost test]# find /root/test -mmin -5 -print
/root/test
/root/test/b
/root/test/a

# 查找在当前时间前20分钟内,在/root/test中建立的文件,并将结果定向到/tmp/bakf
#  !  -type   d 屏蔽掉目录

[root@localhost tmp]# find /root/test -mmin -20 ! -type d >/tmp/bakf
[root@localhost tmp]# cat /tmp/bakf
/root/test/b
/root/test/a
#  读取/tmp/bakf 中的文件记录,并将这些文件打包 ,tar -T 参数可以读取某个文件里的文件记录
[root@localhost tmp]# tar -T /tmp/bakf -cvf bf.tar
tar: Removing leading `/' from member names
/root/test/b
/root/test/a
#  查看tar包里内容
[root@localhost tmp]# tar -tf /tmp/bf.tar
root/test/b
root/test/a

查看tar命令参考地址:
http://towerman.blog.51cto.com/903432/214691

参考地址:

http://hi.baidu.com/qinziqiang/blog/item/1f3a8b51896ffe2c43a75bfc.html






阅读(1209) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~