How to Backup Harddisk to image file
and mount Backup images in Linux
Introduction:
Linux deals a harddisk almost like a regular file. So the /dev/sda is like a big file that contains the harddisk data, so any command you use in a regular file works on /dev/sda file, so you always should take care with these files.
The easiest way to backup the hole harddisk with all the partitions is copying the harddisk file like:
# cp /dev/sda backup_sda
or
# dd if=/dev/sda of=backup_sda bs=100M
Depending on the size of the harddisk the copy may take several hours because the "dd" or "cp" command copies everything, including the empty space, and the created backup file have the harddisk size. The advantage of this method is that you can mount and access the files of your backup file. If you don't want to access the files later, only want to backup and restore later in another harddisk, I would recommend using other tools like partimage, that is faster and don't copy the empty space.
MOUNTING THE PARTITION FROM THE BACKUP
1) Look the partitions in your backup file:
# fdisk -l backup_sda
Disk backup_sda1: 209 MB, 209715200 bytes
255 heads, 63 sectors/track, 25 cylinders, total 409600 sectors
Units = setores of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00068d2c
Dispositivo Boot Start End Blocks Id System
backup_sda1 2048 204799 101376 83 Linux
backup_sda2 204800 409599 102400 7 NTFS
2) Note the "Start" number of the partition you want to mount.
Note that the first partition (backup_sda1), the start number is 2048 and the second partition (backup_sda2) the start number is 204800.
3) Create directory, and mount the first partition:
# mkdir /mnt/part1
# mount backup_sda /mnt/part1 -o offset=$((2048*512))
Note: Use the noted number from the start of first partition.
The partition is mounted, now you can list and copy files from your backup inside /mnt/part1
4) Create directory and mount the second partition with NTFS filesystem (Windows)
Mounting NTFS in read-only
# mkdir /mnt/part2
# mount -t ntfs backup_sda /mnt/part2 -o offset=$((204800*512))
Mounting NTFS in read-write
# mkdir /mnt/partition2
# mount -t ntfs-3g backup_sda /mnt/part2 -o offset=$((204800*512))
Note: Use the noted number from the start of second partition.
The partition is mounted, now you can list and copy files from your backup inside /mnt/part2.
# fdisk -l backup_sda
Disk backup_sda1: 209 MB, 209715200 bytes
255 heads, 63 sectors/track, 25 cylinders, total 409600 sectors
Units = setores of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00068d2c
Dispositivo Boot Start End Blocks Id System
backup_sda1 2048 204799 101376 83 Linux
backup_sda2 204800 409599 102400 7 NTFS
Note that the first partition (backup_sda1), the start number is 2048 and the second partition (backup_sda2) the start number is 204800.
3) Create directory, and mount the first partition:
# mkdir /mnt/part1
# mount backup_sda /mnt/part1 -o offset=$((2048*512))
Note: Use the noted number from the start of first partition.
The partition is mounted, now you can list and copy files from your backup inside /mnt/part1
4) Create directory and mount the second partition with NTFS filesystem (Windows)
Mounting NTFS in read-only
# mkdir /mnt/part2
# mount -t ntfs backup_sda /mnt/part2 -o offset=$((204800*512))
Mounting NTFS in read-write
# mkdir /mnt/partition2
# mount -t ntfs-3g backup_sda /mnt/part2 -o offset=$((204800*512))
The partition is mounted, now you can list and copy files from your backup inside /mnt/part2.
Nenhum comentário:
Postar um comentário