FreeBSD Backup

FreeBSD Backup

環境介紹:kFreeBSD(與FreeBSD幾乎一樣)

Hardisk:建立兩個slice, 各自再兩個label

da0

da0s1

da0s1a / ufs2

da0s1b swap

da0s2

da0s2d /home

da0s2e /usr

mapping 到 linux kernel

da0 --> sda

da0s1 --> sda1 <bsd: sda5 sda6> // 暫時想像成延伸分割區吧

da0s1a / ufs2 --> sda5

da0s1b swap --> sda6

da0s2 --> sda2 <bsd: sda7 sda8>

da0s2d /home --> sda7

da0s2e /usr --> sda8

先用 Clonezilla 開機,進入shell模式,手動下指令:

raw backup:

dd if=/dev/sda of=mbr.dd bs=512 count=1

dd if=/dev/sda1 of=slice1-table.dd bs=512 count=16

dd if=/dev/sda2 of=slice2-table.dd bs=512 count=16

partclone.ufs -d -c -s /dev/sda5 -o sda5.ptl.img

partclone.ufs -d -c -s /dev/sda7 -o sda7.ptl.img

partclone.ufs -d -c -s /dev/sda8 -o sda8.ptl.img

restore:

dd if=mbr.dd of=/dev/sda

dd if=slice1-table.dd of=/dev/sda1

dd if=slice2-table.dd of=/dev/sda2

partclone.ufs -d -r -s sda5.ptl.img  -o /dev/sda5

partclone.ufs -d -r -s sda7.ptl.img  -o /dev/sda7

partclone.ufs -d -r -s sda8.ptl.img  -o /dev/sda8

直接pipe資料到新的硬碟:

dd if=/dev/sda of=/dev/sdb bs=512 count=1

partprobe /dev/sdb

dd if=/dev/sda1 of=/dev/sdb1 bs=512 count=16

dd if=/dev/sda2 of=/dev/sdb2 bs=512 count=16

reboot

partclone.ufs -d -b -s /dev/sda5 -o /dev/sdb5

partclone.ufs -d -b -s /dev/sda7 -o /dev/sdb7

partclone.ufs -d -b -s /dev/sda8 -o /dev/sdb8

remove sda, update sdb to first hard disk

boot...

other notes:

  • 可以考慮備份硬碟前 0-62 這區段的sector, 雖然不確定是做什麼的?

  • BSD建立partition 一律在尾端保留約 2678 個 sector,是否要備份?

  • 為什麼slice 是 sda1的前16個sector

http://fuse4bsd.creo.hu/localcgi/man-cgi.cgi?bsdlabel+8

The offset of the start of the partition from the beginning of

the drive in sectors, or * to have bsdlabel calculate the correct

offset to use (the end of the previous partition plus one, ignor-

ing partition `c').  For partition `c', * will be interpreted as

an offset of 0.  The first partition should start at offset 16,

because the first 16 sectors are reserved for metadata.

  • mount ufs2

mount -r -t ufs -o ufstype=ufs2 /dev/sda5 /mnt

  • 判斷UFS partition

debian:\~# dmesg | grep hda

[    3.440093] hda: VMware Virtual IDE Hard Drive, ATA DISK drive

[    4.112099] hda: host max PIO4 wanted PIO255(auto-tune) selected PIO4

[    4.112207] hda: UDMA/33 mode selected

[    5.208450] hda: max request size: 128KiB

[    5.208654] hda: 16777216 sectors (8589 MB) w/32KiB Cache, CHS=17753/15/63

[    5.208858]  hda: hda1

[    5.229445]  hda1: <bsd: hda5 hda6 >

--------------- check hda ---------------

debian:\~# disktype /dev/hda

--- /dev/hda

Block device, size 8 GiB (8589934592 bytes)

DOS/MBR partition map

Partition 1: 8.000 GiB (8589579264 bytes, 16776522 sectors from 63, bootable)

Type 0xA5 (FreeBSD)

FreeBSD boot loader (i386 boot1 at sector 0)

BSD disklabel (at sector 1), 8 partitions

Partition a: 7.500 GiB (8052708352 bytes, 15727946 sectors from 1048639)

Type 7 (4.2BSD fast file system)

UFS2 file system, 64 KiB offset, little-endian

Last mounted at "/"

Partition b: 512 MiB (536870912 bytes, 1048576 sectors from 63)

Type 1 (swap)

Includes the disklabel and boot code

UFS2 file system, 64 KiB offset, little-endian

Last mounted at "/"

Partition c: 8.000 GiB (8589579264 bytes, 16776522 sectors from 63)

Type 0 (Unused)

--------------- check hda5 ---------------

debian:\~# disktype /dev/hda5

--- /dev/hda5

Block device, size 7.500 GiB (8052708352 bytes)

UFS2 file system, 64 KiB offset, little-endian

Last mounted at "/"

convert from Thomas blog post id 553 old convert log: ./101102/tag%3E2009%2010%20drbl%20partclone%20clonezilla%20freebsd)

@2009 @10 @drbl @partclone @clonezilla @freebsd

Comments