Copy 2 partitions to .img file
Hello all, I have a memory card with 16GB of size, but only 4GB are partitioned through 2 partitions (sdb1 and 2). I want to copy the content of both partitions into a .img file, in order to be able to flash it on another 4GB memory card.. I tried with dd command, but I am only able to copy one partition each time or the entire 16 GB. Could you help me copying only the two partitions? Cumprimentos, Hélder Pinheiro
Re: Copy 2 partitions to .img file
On Thu, Dec 06, 2012 at 01:00:38PM +, Hélder Pinheiro wrote: Hello all, I have a memory card with 16GB of size, but only 4GB are partitioned through 2 partitions (sdb1 and 2). I want to copy the content of both partitions into a .img file, in order to be able to flash it on another 4GB memory card.. I tried with dd command, but I am only able to copy one partition each time or the entire 16 GB. Could you help me copying only the two partitions? You COULD append the second partition to the first one, but then you have a problem of where does one partition end and the other finish? Why not make a separate image for each partition and then, if you really must have one file, tar them together? signature.asc Description: Digital signature
Re: Copy 2 partitions to .img file
Le 15680ième jour après Epoch, Hélder Pinheiro écrivait: Hello all, I have a memory card with 16GB of size, but only 4GB are partitioned through 2 partitions (sdb1 and 2). I want to copy the content of both partitions into a .img file, in order to be able to flash it on another 4GB memory card.. I tried with dd command, but I am only able to copy one partition each time or the entire 16 GB. Could you help me copying only the two partitions? You could try the seek= and/or skip= options of dd to create only one .img file, but why not create 2 .img files? -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/87fw3js325@tourde.org
Re: Copy 2 partitions to .img file
On 6.12.2012 15:00, Hélder Pinheiro wrote: I want to copy the content of both partitions into a .img file, in order to be able to flash it on another 4GB memory card.. I tried with dd command, but I am only able to copy one partition each time or the entire 16 GB. dd if=/dev/sdb of=4GB.img bs=1M count=4k Copies 4096 times 1 megabyte blocks. For exact size image(?): sudo fdisk -l /dev/sdd Disk /dev/sdd: 7969 MB, 7969177600 bytes 246 heads, 62 sectors/track, 1020 cylinders, total 15564800 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 Disk identifier: 0x000a8206 Device Boot Start End Blocks Id System /dev/sdd12048 206847 1024006 FAT16 /dev/sdd2 20684813314047 6553600 83 Linux dd if=[Input Device] of=[Output File] bs=[Sector size] count=[End of last partition] dd if=/dev/sdd of=8GB.img bs=512 count=13314047 Using small block size could be really slow. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/50c0b63b.80...@pp.nic.fi
Re: Copy 2 partitions to .img file
On 06/12/12 15:14, Pertti Kosunen wrote: On 6.12.2012 15:00, Hélder Pinheiro wrote: I want to copy the content of both partitions into a .img file, in order to be able to flash it on another 4GB memory card.. I tried with dd command, but I am only able to copy one partition each time or the entire 16 GB. dd if=/dev/sdb of=4GB.img bs=1M count=4k Copies 4096 times 1 megabyte blocks. For exact size image(?): sudo fdisk -l /dev/sdd Disk /dev/sdd: 7969 MB, 7969177600 bytes 246 heads, 62 sectors/track, 1020 cylinders, total 15564800 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 Disk identifier: 0x000a8206 Device Boot Start End Blocks Id System /dev/sdd1 2048 206847 102400 6 FAT16 /dev/sdd2 206848 13314047 6553600 83 Linux dd if=[Input Device] of=[Output File] bs=[Sector size] count=[End of last partition] dd if=/dev/sdd of=8GB.img bs=512 count=13314047 That should be count=13314048 as the sector number starts at 0, so from sector 0 to sector 13314047 is 13314048 sectors. It will only be an issue if the last sector is used though. -- Dom -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/50c0c97e.6050...@rpdom.net
Re: Copy 2 partitions to .img file
If you just copy the first 4GB, which includes the partition table, and put it on a 4GB drive, you will have a bogus partitions table (I think). Maybe it will just work as long as you don't try to make new partitons. Alternately, I don't know what it would take to repair it although I'm sure it can be done. Thus the alternative of dumping each partition may be safer. However, note that if you dump each partition, you will have to deal with putting a correct partition table and MBR on the new drive. If the drive is bootable, this will probably involve re-running the boot loader install process. -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/874njy1w76@aptiva.optonline.net
Re: Copy 2 partitions to .img file
On Thu, Dec 06, 2012 at 08:34:53PM -0500, Marc Auslander wrote: If you just copy the first 4GB, which includes the partition table, and put it on a 4GB drive, you will have a bogus partitions table (I think). Maybe it will just work as long as you don't try to make new partitons. Alternately, I don't know what it would take to repair it although I'm sure it can be done. Thus the alternative of dumping each partition may be safer. I think all you'd have to do is use fdisk to delete the bogus partitions. But test it first with data that you don't care about! -Rob -- To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/20121207020806.gb16...@aurora.owens.net
Re: Copy 2 partitions to .img file
Hélder Pinheiro wrote: I have a memory card with 16GB of size, but only 4GB are partitioned through 2 partitions (sdb1 and 2). I understand that: sdb1 is 2G sdb2 is 2G Total of 4G I want to copy the content of both partitions into a .img file, in order to be able to flash it on another 4GB memory card.. Okay. Then copy each of the partitions off. Then copy each of the partitions onto the new device. Right? I tried with dd command, but I am only able to copy one partition each time or the entire 16 GB. Right. But isn't that what you want? Could you help me copying only the two partitions? dd if=/dev/sdb1 of=sdb1.img dd if=/dev/sdb2 of=sdb2.img Then partition the new device with two 2G partitions, the same size as the previous partitions. If you need help doing this ask. I would use 'sfdisk -d' to dump the previous and 'sfdisk' again to write the new partitions. This is the only tricky part of things. Then copy the saved data off to the new partitions. dd if=sdb1.img of=/dev/sdb1 dd if=sdb2.img of=/dev/sdb2 If the above just isn't going to work for you then if the file size is only 4G in total then you could simply copy the data off the filesystem and then copy the data back onto the new device. mount /dev/sdb1 /mnt rsync -a /mnt/ ./backupdir/sdb1/ umount /mnt mount /dev/sdb2 /mnt rsync -a /mnt/ ./backupdir/sdb2/ umount /mnt Then mount the new device: mount /dev/sdb1 /mnt rsync -a ./backupdir/sdb1/ /mnt/ umount /mnt mount /dev/sdb2 /mnt rsync -a ./backupdir/sdb2/ /mnt/ Note the trailing '/' characters on the rsync command args are intentional and important. Bob signature.asc Description: Digital signature