1106 shaares
6 results
tagged
img
J'essaye de shrinker une .img contenant 3 partitions (dont une de boot chromeOS = non montable) de 7Go en 4Go.
Marche pas. J'ai réduis l'image mais ça boot pas...
Marche pas. J'ai réduis l'image mais ça boot pas...
The problem is that the .img files are not images of a partition, but of a whole disk. That means they start with a bootloader and a partition table. You have to find out the offset of the partition and mount it with the offset option of mount.
If you do a
Code:
fdisk -l /path/to/image
it will show you the block-size and the start-block of the partition. You can use that to calculate the offset.
For example, I have an image of a bootable stick with a 4GB FAT32 partition. The output of the fdisk command is
Code:
Disk Stick.img: 3984 MB, 3984588800 bytes
249 heads, 6 sectors/track, 5209 cylinders, total 7782400 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: 0x0004bfaa
Device Boot Start End Blocks Id System
Stick.img1 * 128 8015999 4007936 b W95 FAT32
So I have a block-size of 512 bytes and the start-block is 128. The offset is 512 * 128 = 65536.
So the mount command would be
Code:
mount -o loop,offset=65536 Stick.img /mnt/tmp
If you do a
Code:
fdisk -l /path/to/image
it will show you the block-size and the start-block of the partition. You can use that to calculate the offset.
For example, I have an image of a bootable stick with a 4GB FAT32 partition. The output of the fdisk command is
Code:
Disk Stick.img: 3984 MB, 3984588800 bytes
249 heads, 6 sectors/track, 5209 cylinders, total 7782400 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: 0x0004bfaa
Device Boot Start End Blocks Id System
Stick.img1 * 128 8015999 4007936 b W95 FAT32
So I have a block-size of 512 bytes and the start-block is 128. The offset is 512 * 128 = 65536.
So the mount command would be
Code:
mount -o loop,offset=65536 Stick.img /mnt/tmp
# Creating a 1G img file
dd if=/dev/zero of=disk.img bs=1k count=1048576
# Format it in ext2
sudo mkfs -t ext2 disk.img
# Mount it
mkdir disk && sudo mount -t ext2 -o loop disk.img disk/
#Extract your tar.gz in the mountpoint
sudo bsdtar -xpf yourfile.tar.gz -C disk/
# Umount your img file
umount disk
source : the internet...
dd if=/dev/zero of=disk.img bs=1k count=1048576
# Format it in ext2
sudo mkfs -t ext2 disk.img
# Mount it
mkdir disk && sudo mount -t ext2 -o loop disk.img disk/
#Extract your tar.gz in the mountpoint
sudo bsdtar -xpf yourfile.tar.gz -C disk/
# Umount your img file
umount disk
source : the internet...
A tester si ça marche vraiment sur un gros fichier img issue de ddrescue.
VBoxManage convertdd file.img file.vdi
VBoxManage convertdd file.img file.vdi