Portál AbcLinuxu, 2. listopadu 2025 10:31
Loopback půjde, ale chce to trochu snahy navíc. :)
Pomocí losetup nejprv připojit celý image, na kterém by se potom mělo dát fdisk-em, či podobnou utilitou zjistit offset konkrétní partition. S touto informací pak na image poslat losetup s parametrem -o.
Prakticky jsem to nezkoušel, ale nevidím důvod, proč by to nemělo fungovat.
dobry den
jenom dodam, ze postup uvedeny v odkazu u me funguje az po pridani modprobe dm-mod.
a at je to tady cele:
root@setapouch:~# dd if=/dev/zero of=zkouska bs=$((1024*1024)) count=1024
1024+0 vstoupivších záznamů
1024+0 vystoupivších záznamů
1 073 741 824 bajtů (1,1 GB) zkopírováno, 18,1613 s, 59,1 MB/s
root@setapouch:~# losetup -f zkouska
root@setapouch:~# cat /proc/partitions
major minor #blocks name
8 0 78150744 sda
8 1 1959898 sda1
8 2 76188262 sda2
7 0 1048576 loop0
root@setapouch:~# fdisk /dev/loop0
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x73740bc7.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130): 65
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (66-130, default 66):
Using default value 66
Last cylinder or +size or +sizeM or +sizeK (66-130, default 130):
Using default value 130
Command (m for help): p
Disk /dev/loop0: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x73740bc7
Device Boot Start End Blocks Id System
/dev/loop0p1 1 65 522081 83 Linux
/dev/loop0p2 66 130 522112+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 22: Nepřípustný argument.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
root@setapouch:~# modprobe dm-mod
root@setapouch:~# kpartx -a /dev/loop0
root@setapouch:~# cat /proc/partitions
major minor #blocks name
8 0 78150744 sda
8 1 1959898 sda1
8 2 76188262 sda2
7 0 1048576 loop0
253 0 522081 dm-0
253 1 522112 dm-1
root@setapouch:~# ls /dev/dm-*
/dev/dm-0 /dev/dm-1
root@setapouch:~# kpartx -d /dev/loop0
root@setapouch:~# losetup -d /dev/loop0
root@setapouch:~# cat /proc/partitions
major minor #blocks name
8 0 78150744 sda
8 1 1959898 sda1
8 2 76188262 sda2
root@setapouch:~#
marek
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.