manbytesgnu_site

Source files for manbytesgnu.org
git clone git://holbrook.no/manbytesgnu_site.git
Info | Log | Files | Refs

20220102_qemu_raw.rst (1724B)


      1 Working with raw qemu partitions
      2 ################################
      3 
      4 :date: 2022-01-02 12:09:55
      5 :category: Offlining
      6 :author: Louis Holbrook
      7 :tags: qemu,fdisk
      8 :slug: qemu-raw-partitions
      9 :summary: Rearranging your raw qemu image from the host
     10 :lang: en
     11 :status: draft
     12 
     13 
     14 .. code-block: bash
     15 
     16         $ fdisk -l raw.img
     17         $ qemu-image resize raw.img +2G
     18         $ fdisk -l raw.img 
     19         Disk raw.img: 4 GiB, 4294967296 bytes, 8388608 sectors
     20         Units: sectors of 1 * 512 = 512 bytes
     21         Sector size (logical/physical): 512 bytes / 512 bytes
     22         I/O size (minimum/optimal): 512 bytes / 512 bytes
     23         Disklabel type: dos
     24         Disk identifier: 0x79c2484b
     25 
     26         Device        Boot   Start     End Sectors  Size Id Type
     27         raw.img1 *       2048 2193407 2191360    1G 83 Linux
     28         raw.img2      2195454 4192255 1996802  975M  5 Extended
     29         raw.img3      4192256 8388607 4196352    2G 83 Linux
     30         raw.img5      2195456 4192255 1996800  975M 82 Linux swap / Solaris
     31 
     32         Partition table entries are not in disk order.
     33         $ mke2fs -E offset=$(4192256*512) raw.img
     34         $ sudo mount -o loop,offset=$(calc 2048*512),sizelimit=$(calc 2191360*512) /mnt/a
     35         $ sudo mount -o loop,offset=$(calc 4192256*512) /mnt/b
     36         $ sudo umount /mnt/b
     37         $ losetup -f -P raw.img
     38         $ lsblk -no NAME,UUID /dev/loop0
     39         loop0     
     40         ├─loop0p1 34b73576-e8c6-4ffb-a503-a9828639b5e9
     41         ├─loop0p2 
     42         ├─loop0p3 ff6235cc-2f72-4551-a3d3-73d8df2e21b9
     43         └─loop0p5 0255cf3e-b10b-4522-8cfe-9ef8e2fc2d6a
     44         $ echo "UUID=ff6235cc-2f72-4551-a3d3-73d8df2e21b9 /usr ext4 errors=remount-ro 0 2" >> /mnt/a/etc/fstab
     45         $ sudo umount /mnt/a