Povestiri din tranșee - Partiționare cu forța

Petru Rațiu aka. rpetre

RLUG

Povești cu blockdevices

Povestea de azi: "cum pot monta o partiție dintr-un device oarecare?"

De ce Nu Merge

include/linux/genhd.h
struct gendisk {
        /* major, first_minor and minors are input parameters only,
         * don't use directly.  Use disk_devt() and disk_max_parts().
         */
        int major;           /* major number of driver */
        int first_minor;
        int minors;          /* maximum number of minors, =1 for
                              * disks that can't be partitioned. */
    

Posibile soluții

  1. losetup + offsets
  2. devmapper magic
  3. raw devices

losetup

Raw devices

devmapper magic

kpartx in action

    lvcreate -s --name mysnap -L 100M /dev/vg0/myvol
    kpartx -a /dev/vg0/mysnap
    mount /dev/mapper/vg0-mysnap1 /mnt/test
    [ ... happy hacking happens here ... ]
    umount /mnt/test
    kpartx -d /dev/vg0/mysnap
    lvremove -f /dev/vg0/mysnap
    

The end(?)

...va urma