leiqzhang / leiqzhang.github.com

leiqzhang-pages
0 stars 0 forks source link

Merge two linear-dm disk into one virtual disk as individual partitions #1

Closed leiqzhang closed 11 years ago

leiqzhang commented 11 years ago
  1. 8G os img; 3G data img
  2. 20G LUN (/dev/sdf)
  3. create first dm: echo -e "0 16777216 linear /dev/sdf 0" | dmsetup create vol-win2003
  4. create second dm: echo -e "0 6291456 linear /dev/sdf 16777220" | dmsetup create vol-data (offset 4 sectors)
  5. dd os img => first dm
  6. dd data img => second dm
  7. fdisk -l /dev/sdf / fdisk -l /dev/mapper/vol-data
   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1   *          63    16755794     8377866    7  HPFS/NTFS/exFAT
  1. fdisk /dev/sdf
    • add partition
    • start: 1677216+4+63; end: 1677216+4+6281414
    • t: change a partition's system id => 7
    • w
   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1   *          63    16755794     8377866    7  HPFS/NTFS/exFAT
/dev/sdf2        16777283    23058634     3140676    7  HPFS/NTFS/exFAT
  1. other situations:
    • GPT
    • multiple partitions in data vol
    • Generate the Script to automate this process