File: example.txt

package info (click to toggle)
cloud-initramfs-tools 0.18.debian14
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 240 kB
  • sloc: sh: 1,032; makefile: 57
file content (107 lines) | stat: -rw-r--r-- 4,220 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
On a Eucalyptus kvm instance, I did the following to demonstrate function.

- launch instance
- show original partition table:
  $ sudo sfdisk -G /dev/sda
  /dev/sda: 164288 cylinders, 4 heads, 32 sectors/track
  $ CHS=$(sudo sfdisk -G /dev/sda | awk '{print "-C",$2,"-H",$4,"-S",$6}')
  $ sudo sfdisk -uS ${CHS} /dev/sda -d
  # partition table of /dev/sda
  unit: sectors

  /dev/sda1 : start=       63, size=  2883585, Id=83
  /dev/sda2 : start=  2883648, size= 16558001, Id=83
  /dev/sda3 : start= 19441649, size=  1587215, Id=82
  /dev/sda4 : start=        0, size=        0, Id= 0
  $ df -h /dev/sda1 /dev/sda2
  Filesystem            Size  Used Avail Use% Mounted on
  /dev/sda1             1.4G  581M  735M  45% /
  /dev/sda2             7.8G   52K  7.4G   1% /mnt

- now, modify the partition table
  This will destroy the filesystem on /dev/sda2 as we move it.  A
  reboot will get the new partition and not see a filesystem on /dev/sda2

  $ cat > rewrite.txt <<EOF
  # partition table of /dev/sda
  unit: sectors

  /dev/sda1 : start=       63, size=  2883585, Id=83
  /dev/sda2 : start= 10000000, size=  9441649, Id=83
  /dev/sda3 : start= 19441649, size=  1587215, Id=82
  /dev/sda4 : start=        0, size=        0, Id= 0
  $ sudo sfdisk --force -uS ${CHS} /dev/sda < rewrite.txt

- At this point, the disk is in a state where the root partition
  could be grown.  You can see that with:
  $ sudo growpart --dry-run /dev/sda 1
  CHANGE: partition=1 start=63 old: size=2883585 end=2883648 new: size=9999937,end=10000000
  # === old sfdisk -d ===
  # partition table of /dev/sda
  unit: sectors

  /dev/sda1 : start=       63, size=  2883585, Id=83
  /dev/sda2 : start= 10000000, size=  9441649, Id=83
  /dev/sda3 : start= 19441649, size=  1587215, Id=82
  /dev/sda4 : start=        0, size=        0, Id= 0
  # === new sfdisk -d ===
  # partition table of /dev/sda
  unit: sectors

  /dev/sda1 : start=       63, size=  9999937, Id=83
  /dev/sda2 : start= 10000000, size=  9441649, Id=83
  /dev/sda3 : start= 19441649, size=  1587215, Id=82
  /dev/sda4 : start=        0, size=        0, Id= 0

- To verify that the rewrite is safe for the following partition
  we will put a filesystem into the newly sized /dev/sda2.

  disable growroot for this reboot, and reboot the instance, so
  that the kernel will have the new partition table, but growroot will
  not resize.
  $ sudo touch /etc/growroot-disabled
  $ sudo reboot

  After the reboot, the partition table with the gap will have been
  read by the kernel and we can make a new filesystem on /dev/sda2 and
  put some things in it.
  $ sudo mkfs.ext3 /dev/sda2 -L HIMOM
  $ sudo  mount /dev/sda2 /mnt 
  $ sudo rsync -a /etc /mnt/

  
- Reboot the system, and the ramdisk should resize the root partition
  However, in order to make filesystem know about its larger size, we
  have to run resize2fs.  That can be done by cloud-init.  So that
  cloud-init does that on first boot, remove the marker that it has
  already done so.
  $ sudo rm /etc/growroot-disabled
  $ sudo rm /var/lib/cloud/instance/sem/config-resizefs 
  $ sudo reboot

- After reboot, the partition table should look like the 'new sfdisk -d'
  partition table listed in the --dry-run output above.  Also, a 'df /'
  should show that the / partition was grown (by cloud-init).

  Console output will have a GROWROOT string in the output with information
  about what was done:
  $ euca-get-console-output i-46EE07DB > console.out
  $ grep GROW  console.out
  GROWROOT: CHANGED: partition=1 start=63 old: size=2883585 end=2883648 new: size=9999937,end=10000000

  And, on the instance, you can see that the partition table has been
  updated and that / partition has been resized by cloud-init.

  $ sudo sfdisk -uS ${CHS} /dev/sda -d
  # partition table of /dev/sda
  unit: sectors

  /dev/sda1 : start=       63, size=  9999937, Id=83
  /dev/sda2 : start= 10000000, size=  9441649, Id=83
  /dev/sda3 : start= 19441649, size=  1587215, Id=82
  /dev/sda4 : start=        0, size=        0, Id= 0

  $ df -h /dev/sda1 /dev/sda2
  Filesystem            Size  Used Avail Use% Mounted on
  /dev/sda1             4.7G  582M  3.9G  13% /
  /dev/sda2             4.5G  143M  4.1G   4% /mnt