OMV的备份恢复(2019-06-18)

前提说明:
旧的omv安装在了/dev/sda上,备份的时候只备份了/dev/sda1,由于mbr和grub那部分缺失,需要恢复的时候重建

一、tinycore Linux

Tiny Core Linux是一份很小(18 MB)的最低限度Linux桌面。它基于Linux 4.x内核、Busybox、Tiny X、FLTK图形用户界面、JWM窗口管理器,全部运行在内存中。它并非一份完整的桌面,也不完整支持所有的硬件;它只代表能引导进入一份最小X窗口桌面所需的核心内容,典型情况下可包含对有线网络的访问。这份最小桌面可以通过从在线软件仓库安装额外应用软件来进行扩展。

使用tinycore linux来重建,下载好tinycore后(下载64位的),加载tinycore启动,可以用图形界面,也可以用纯命令行,差别不大,因为所有操作都是命令。

二、新硬盘中分区

sudo -s进入root用户来操作

root@box:~ dd if=/dev/zero of=/dev/sda bs=100M    #清空硬盘分区表
root@bogon:~ fdisk /dev/sda

Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xde369dae.

Command (m for help): p
Disk /dev/sda: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xde369dae

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-8388607, default 2048): 
Last sector, +sectors or +size{K,M,G,T,P} (2048-8388607, default 8388607): 

Created a new partition 1 of type 'Linux' and of size 4 GiB.

Command (m for help): a
Selected partition 1
The bootable flag on partition 1 is enabled now.

Command (m for help): p
Disk /dev/sda: 4 GiB, 4294967296 bytes, 8388608 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xde369dae

Device     Boot Start     End Sectors Size Id Type
/dev/sda1  *     2048 8388607 8386560   4G 83 Linux

Command (m for help): w   
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

这样分区就好了,下面需要格式化硬盘:

root@box~: mkfs.ext4 -T largefile /dev/sda1
mke2fs 1.44.5 (15-Dec-2018)
Discarding device blocks: done                            
Creating filesystem with 1048320 4k blocks and 4096 inodes
Filesystem UUID: 82bdc768-b2ac-4bfd-a5d1-38b163e0abf6
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done 

三、恢复镜像文件

首先,需要把镜像文件挂载到机器上,可以访问,然后用dd命令写入/dev/sda1

root@box:/mnt/vda1:  dd if=./omv-bak.img of=/dev/sda1 bs=4M
1024+0 records in
1024+0 records out
4294967296 (4.0GB) copied, 87,718746 seconds, 46.7MB/s 

四、恢复引导

a. 用chroot进去配置

root@box:~: mount /dev/sda1 /mnt/sda1
root@box:~: mount -t proc /proc /mnt/sda1/proc
root@box:~: mount --rbind /dev /mnt/sda1/dev
root@box:~: mount --rbind /sys /mnt/sda1/sys
root@box:~: chroot /mnt/sda1 /bin/bash
root@box:~: source /etc/profile

b. 重新配置grub

root@box:~: grub-install /dev/sda   #这里的sda要根据实际情况,可以fdisk -l确认一下
root@box:~: update-grub2
root@box:~: grub-probe / 
root@box:~: update-initramfs -u -k all

#退出chroot
root@box:~: exit

五、重启

你可能感兴趣的:(OMV的备份恢复(2019-06-18))