Fs-images

From Bashlinux
Revision as of 04:51, 12 June 2012 by (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Disk images

How to backup a whole HD

The byte size bs is useful to do a fast copy, specially then output location is remotly on a network

 dd if=/dev/sda of=/path/to/store/disk.img bs=4096
 


To mount a partition from here, you have to consider that you have to ignore partition table.

 mount -o loop,offset=32256 /path/to/store/disk.img /mnt/mydisk
 


How to backup only one partition from a HD

 dd if=/dev/sda1 of=/path/to/store/disk.img bs=4096
 


How to convert a raw image from HD in a VMWare HD image

 qemu-img convert -f raw /path/to/image/XPSP2.img -O vmdk /path/to/image/XPSP2.vmdk
 


How to create a filesystem for CentOS 5 an older distros

One of the issues is grub is unable to read the filesystem, and must of the time is because the recent distros uses 256-byte node size. In order to fix it, specially on VMs, do:

  1. Create the virtual drive as usual
 # qemu-img create -f raw disk.img 20G
 
  1. boot using a knoppix image as cdrom
 # qemu-system-x86_64 -m1024 -hda disk.img -cdrom knoppix.iso -boot d
 
  1. On knoppix prompt, type knoppix 3, in order to boot in init level 3
  2. From the shell, start cfdisk and add only one linux partition.
  3. Create the filesyste in the created partition with 128-byte node size
  # mkfs.ext3 -I 128 /dev/sda1
 
  1. Turn off the virtual machine
  2. Now, you can mount the drive as a real physical disk with
 # mkdir disk
 # mount -o loop,offset=32256 disk.img disk/