15 | | |
16 | | = GRUB2 = |
17 | | == reduce grub entry == |
18 | | * WindowsとLinuxのマルチブート -> Windowsを消してシングルブート化 |
19 | | |
20 | | 1. 元の状態 |
21 | | * fdisk -lu /dev/sda |
22 | | {{{ |
23 | | Disk /dev/sda: 120.0 GB, 120034123776 bytes |
24 | | 255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors |
25 | | Units = sectors of 1 * 512 = 512 bytes |
26 | | Sector size (logical/physical): 512 bytes / 512 bytes |
27 | | I/O size (minimum/optimal): 512 bytes / 512 bytes |
28 | | Disk identifier: 0x36ea3e05 |
29 | | |
30 | | Device Boot Start End Blocks Id System |
31 | | /dev/sda1 63 524351 262144+ 82 Linux swap / Solaris |
32 | | Partition 1 does not end on cylinder boundary. |
33 | | /dev/sda2 524352 42467392 20971520+ 7 HPFS/NTFS |
34 | | /dev/sda3 42467393 234441647 95987127+ 83 Linux |
35 | | }}} |
36 | | * OSのインストールは、Windows 7 -> Ubuntu 10.04の順 |
37 | | * grep menuentry /boot/grub/grub.cfg | tr \" \' | cut -d\' -f2 |
38 | | {{{ |
39 | | Ubuntu, with Linux 2.6.32-33-generic |
40 | | Ubuntu, with Linux 2.6.32-33-generic (recovery mode) |
41 | | Ubuntu, with Linux 2.6.32-32-generic |
42 | | Ubuntu, with Linux 2.6.32-32-generic (recovery mode) |
43 | | Ubuntu, with Linux 2.6.32-31-generic |
44 | | Ubuntu, with Linux 2.6.32-31-generic (recovery mode) |
45 | | Memory test (memtest86+) |
46 | | Memory test (memtest86+, serial console 115200) |
47 | | Windows 7 (loader) (on /dev/sda2) |
48 | | }}} |
49 | | 1. NTFSパーティションの削除 |
50 | | * root@Microknoppix:~# fdisk /dev/sdb |
51 | | {{{ |
52 | | |
53 | | Device Boot Start End Blocks Id System |
54 | | /dev/sdb1 1 33 262144+ 82 Linux swap / Solaris |
55 | | Partition 1 does not end on cylinder boundary. |
56 | | /dev/sdb2 * 33 2644 20971520+ 7 HPFS/NTFS |
57 | | /dev/sdb3 2644 14594 95987127+ 83 Linux |
58 | | |
59 | | Command (m for help): d |
60 | | Partition number (1-4): 2 |
61 | | |
62 | | Command (m for help): d |
63 | | Partition number (1-4): 3 |
64 | | |
65 | | Command (m for help): n |
66 | | Command action |
67 | | e extended |
68 | | p primary partition (1-4) |
69 | | p |
70 | | Partition number (1-4): 2 |
71 | | First cylinder (33-14593, default 33): |
72 | | Using default value 33 |
73 | | Last cylinder, +cylinders or +size{K,M,G} (33-14593, default 14593): |
74 | | Using default value 14593 |
75 | | |
76 | | Command (m for help): w |
77 | | }}} |
78 | | {{{ |
79 | | Device Boot Start End Blocks Id System |
80 | | /dev/sdb1 63 524351 262144+ 82 Linux swap / Solaris |
81 | | Partition 1 does not end on cylinder boundary. |
82 | | /dev/sdb2 524352 234436544 116956096+ 83 Linux |
83 | | }}} |
84 | | 1. backupしておいたdisk imageからLinuxパーティションを書き戻し |
85 | | * root@Microknoppix:~# dd if=/media/sda/bb.sda bs=512 skip=42467393 of=/dev/sdb2 |
86 | | {{{ |
87 | | 191974255+0 records in |
88 | | 191974255+0 records out |
89 | | 98290818560 bytes (98 GB) copied, 3223.76 s, 30.5 MB/s |
90 | | }}} |
91 | | 1. 正常には起動しなくなるため、grubから手動でUbuntuを起動する |
92 | | * 以下の様に、grub consoleに落ちる |
93 | | {{{ |
94 | | grub rescue> set |
95 | | prefix=(hd0,3)/boot/grub |
96 | | root=(hd0,3) |
97 | | }}} |
98 | | * [http://d.hatena.ne.jp/syque/20110225/1298618896 Ubuntu で grub rescue -> grub-install を実行して grub を修復 - 新芽の手、ほんとの手] |
99 | | * 上記サイトに倣い、以下のようにしてGRUBメニューを起動する |
100 | | {{{ |
101 | | set prefix=(hd0,2)/boot/grub |
102 | | insmod (hd0,2)/boot/grub/normal.mod |
103 | | normal |
104 | | }}} |
105 | | * これで、以前のGRUB起動メニューが表示される |
106 | | * 通常通り起動 |
107 | | 1. grubを修復する |
108 | | * sudo grub-install /dev/sda |
109 | | {{{ |
110 | | Installation finished. No error reported. |
111 | | }}} |
112 | | * sudo update-grub |
113 | | {{{ |
114 | | Generating grub.cfg ... |
115 | | Found linux image: /boot/vmlinuz-2.6.32-33-generic |
116 | | Found initrd image: /boot/initrd.img-2.6.32-33-generic |
117 | | Found linux image: /boot/vmlinuz-2.6.32-32-generic |
118 | | Found initrd image: /boot/initrd.img-2.6.32-32-generic |
119 | | Found linux image: /boot/vmlinuz-2.6.32-31-generic |
120 | | Found initrd image: /boot/initrd.img-2.6.32-31-generic |
121 | | Found memtest86+ image: /boot/memtest86+.bin |
122 | | done |
123 | | }}} |
124 | | 1. GRUBメニュー修復完了 |
125 | | * grep menuentry /boot/grub/grub.cfg | tr \" \' | cut -d\' -f2 |
126 | | {{{ |
127 | | Ubuntu, with Linux 2.6.32-33-generic |
128 | | Ubuntu, with Linux 2.6.32-33-generic (recovery mode) |
129 | | Ubuntu, with Linux 2.6.32-32-generic |
130 | | Ubuntu, with Linux 2.6.32-32-generic (recovery mode) |
131 | | Ubuntu, with Linux 2.6.32-31-generic |
132 | | Ubuntu, with Linux 2.6.32-31-generic (recovery mode) |
133 | | Memory test (memtest86+) |
134 | | Memory test (memtest86+, serial console 115200) |
135 | | }}} |
136 | | 1. 適宜、Filesystemの伸張をする |
137 | | * df -h / |
138 | | {{{ |
139 | | Filesystem Size Used Avail Use% Mounted on |
140 | | /dev/sda2 93G 33G 56G 37% / |
141 | | }}} |
142 | | * sudo resize2fs /dev/sda2 |
143 | | {{{ |
144 | | resize2fs 1.41.11 (14-Mar-2010) |
145 | | Filesystem at /dev/sda2 is mounted on /; on-line resizing required |
146 | | old desc_blocks = 6, new_desc_blocks = 7 |
147 | | Performing an on-line resize of /dev/sda2 to 29239024 (4k) blocks. |
148 | | The filesystem on /dev/sda2 is now 29239024 blocks long. |
149 | | }}} |
150 | | * df -h / |
151 | | {{{ |
152 | | Filesystem Size Used Avail Use% Mounted on |
153 | | /dev/sda2 110G 33G 72G 32% / |
154 | | }}} |