Thursday, 12 June 2008

burn big files >4GB under Linux

1. prepare a DVD size file:
dd if=/dev/zero of=dvd_file.iso bs=1024 count=4589800
mkudffs dvd_file.iso
mkdir iso
mount -o loop -t udf dvd_file.iso iso
cp your_big_file_to_burn iso
umount iso

2. burn it
cdrecord -verbose -dao -driveropts=burnfree dvd_file.iso

Wednesday, 11 June 2008

creating image of NTFS drive under Linux - ntfsclone

use rescucd ( with ntfsclone in ver.2.0) for this task.

0. mount backup medium on /mnt

1. save NTFS image:
ntfsclone --save-image --output /mnt/winxp.img /dev/sda2

2. restore NTFS image from image file:
ntfsclone --restore-image --overwrite /dev/sda2 /mnt/winxp.img

if your target backup drive is limited to some smaller file size (like 4GB) you might want to compress and split the image into multiple files:
e.g. (all one line)
ntfsclone -s -o - /dev/sda2 |gzip|split -b 2000m -  /mnt/winxp.img.gz_

this will create 2GB big multiple files for that image

To restore: (assuming 3 files were created aa, ab, ac)
cat /mnt/winxp.img.gz_aa /mnt/winxp.img.gz_ab /mnt/winxp.img.gz_ac  |gunzip -c|ntfsclone --restore-image --overwrite /dev/sda2 -

partimage to backup restore drive images

1. partimage ( here 0.6.7)
2. rescuecd ( here 1.0.3) and burn it on CD
3. sfdisk
4. 2 drives with same size (or the one that you will be restoring to bigger size) + the backup HDD with some file system on it (in my case ext3 to hold big data files)

HowTo Backup:
1. attach the backup drive (can be USB HDD, stick, whatever that will save your images - in my case I use 300GB USB drive)
2. Boot the rescuecd
3. to find out the location of the drive in my case /dev/sdb1, use command
fdisk -l

- if this is linux fs drive with ext3 , use following command:
mount -t ext3 /dev/sdb1 /mnt

4. save original MBR with dd
dd if=/dev/sda of=backup-sda.mbr count=1 bs=512

5. save all the extended partition entries
sfdisk -d /dev/sda > backup-sda.sf

IMPORTANT: save both files from 4. and 5. in safe places (they will be needed to restore the structure of the original to the new disk)

6. run partimage command

7. mark the partition that you want to back up (e.g. /dev/sda3)
8. in the Image file to create/use enter the path to the backup disk

9. in Action to be done:
mark - Save partition into a new image file
10. press F5 to go to Next Page
11. Choose required Compression level (e.g. gz)
12. Image split mode if the partitions you save are big, it is wise to split them into the file that fit on CD or DVD (I enter here 4500MB)
After continuing with F5 you give a description and the process starts, generating files:
sda3_partimage.000, sda3_partimage.001, etc
be careful these file are gzip'ed file, please rename them to sda3_partimage.00X.gz for X in 0,1,2..

How To Restore:
1. attach the backup drive containing your partimage files and mbr and extended partition entries
2. attach empty drive (in my case /dev/sda)
3. Boot the rescuecd
4. to find out the location of the backup drive in my case /dev/sdb1, use command
fdisk -l

- if this is linux fs drive with ext3 , use following command:
mount -t ext3 /dev/sdb1 /mnt

5. restore MBR and extended partition entries:
- dd if=/mnt/backup-sda.mbr of=/dev/sda
- sfdisk /dev/sda <> check with fdisk -l if all partitions made on /dev/sda

6. make sure backup file names on backup drive (/mnt) are renamed to gz, then gunzip them:
gunzip sda3_patimage.000.gz (will create much bigger sda3_partimage.000 file),     
... or
gunzip sda3_partimage.*.gz

7. run partimage command
8. Partition to save/resotre (in my case sda3)
9. Image file: enter the path to your gunziped image files /mnt/sda3_partimage.000
even if you have more than 1 file, always put the location of the 000 file
10. Action to be done: pick Restore partition from an image file After continuing with F5 you should get restored partition on /dev/sda3
11. format SWAP partition (in my case /dev/sda5 -> check your fdisk -l)
mkswap -c /dev/sda5

12. Install GRUB boot-loader
mkdir /new_disk
mount /dev/sda3 /new_disk
grub-install --root-directory=/new_disk /dev/sda