install windows 10 using ide disk and virtio.iso drivers
[gnt-info] / doc / deboostrap-4k-msdos.diff
1 commit 13ab06fc005d4e2325ac459032d9a5fbbaa7a383
2 Author: Dobrica Pavlinusic <dpavlin@rot13.org>
3 Date:   Thu Oct 4 12:21:51 2018 +0200
4
5     remove PARTITION_ALIGNMENT and fix 4k block size instance disks
6     
7     Since sfdisk doesn't supprot forced chs geometry any more, in situations
8     where underlaying storage has 4k block, this script will create correct
9     partition table for host, but not for guest which expects 512b blocks.
10     
11     This will make machine unbootable, since once kvm starts partition will
12     be at wrong offset and it won't boot.
13     
14     Solution is to re-create partition table at end using losetup which has
15     512b blocks.
16     
17     Since PARTITION_ALIGNMENT is created using 4k block as base, it will
18     create filesystem at wrong place if you are using default value of 2048.
19     This hard-codes host partition table to 1M (which will work on hosts
20     with both 512b and 4k blocks) and then use 2048 when using 512b blocks.
21
22 diff --git a/common.sh.in b/common.sh.in
23 index 8caeffc..0029d1e 100644
24 --- a/common.sh.in
25 +++ b/common.sh.in
26 @@ -99,8 +99,9 @@ format_disk0() {
27    if sfdisk --help | fgrep -q -- '--no-reread'; then
28      ARGS="--no-reread $ARGS"
29    fi
30 +  ARGS="--label dos $ARGS"
31    sfdisk $ARGS --quiet "$1" <<EOF
32 -${PARTITION_ALIGNMENT},,L,*
33 +1M,,L,*
34  EOF
35  }
36  
37 @@ -124,6 +125,18 @@ map_disk0() {
38  
39  unmap_disk0() {
40    kpartx -d -p- $1
41 +
42 +  if sfdisk --help | fgrep -q -- '--no-reread'; then
43 +    ARGS="--no-reread $ARGS"
44 +  fi
45 +
46 +  # loopback device has correct 512b blocks
47 +  blockdev=$(losetup --show -f $1)
48 +  sfdisk $ARGS --delete "$blockdev"
49 +  sfdisk $ARGS --label dos --quiet $blockdev <<EOF
50 +2048,,L,*
51 +EOF
52 +  losetup -d $blockdev
53  }
54  
55  cleanup() {