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