R.A. Epigonos et al.

[linux] ext2でフォーマットしたusbにgrubをインストールして、usbに入れたisoから起動

linux mintのDVDのisoイメージをusbディスクに格納し、grubを使ってこれを起動する方法。

fdiskでパーティションを作成

% fdisk /dev/sdc

Command (m for help): p

Disk /dev/sdc: 2021 MB, 2021654016 bytes
57 heads, 11 sectors/track, 6297 cylinders, total 3948543 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003d993

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-3948542, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-3948542, default 3948542):
Using default value 3948542

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p

Disk /dev/sdc: 2021 MB, 2021654016 bytes
57 heads, 11 sectors/track, 6297 cylinders, total 3948543 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003d993

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *        2048     3948542     1973247+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
% mkfs.ext2 /dev/sdc1
mke2fs 1.42.3 (14-May-2012)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
123392 inodes, 493311 blocks
24665 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=507510784
16 block groups
32768 blocks per group, 32768 fragments per group
7712 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

% fsck.ext2 -vr /dev/sdc1
e2fsck 1.42.3 (14-May-2012)
/dev/sdc1: clean, 11/123392 files, 8482/493311 blocks

grub2をusbディスクの先頭にインストール

% mount /dev/sdc1 /mnt/windows
% grub2-install /dev/sdc
Path `/boot/grub2' is not readable by GRUB on boot. Installation is impossible. Aborting.
% grub2-install --root-directory=/mnt/windows /dev/sdc
Installation finished. No error reported.
% umount /mnt/windows

適当なisoをダウンロードしてusbディスクに保存。md5sumの確認。

% mount /dev/sdc1 /mnt/windows
% cd /mnt/windows
% wget 'http://ftp.tsukuba.wide.ad.jp/Linux/mint-iso/stable/13/linuxmint-13-mate-dvd-32bit.iso'
--2002-01-01 03:29:57--  http://ftp.tsukuba.wide.ad.jp/Linux/mint-iso/stable/13/linuxmint-13-mate-dvd-32bit.iso
Resolving ftp.tsukuba.wide.ad.jp... 203.178.132.85
Connecting to ftp.tsukuba.wide.ad.jp|203.178.132.85|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 941621248 (898M) [application/octet-stream]
Saving to: `linuxmint-13-mate-dvd-32bit.iso'

100%[==================>] 941,621,248 3.15M/s   in 7m 26s

2002-01-01 03:37:23 (2.01 MB/s) - `linuxmint-13-mate-dvd-32bit.iso' saved [941621248/941621248]
% echo '43ca0be4501b9d1a46fea25ec2cd556e  linuxmint-13-mate-dvd-32bit.iso' > linuxmint-13-mate-dvd-32bit.md5
% md5sum --check linuxmint-13-mate-dvd-32bit.md5
linuxmint-13-mate-dvd-32bit.iso: OK

起動用の設定ファイルを編集。

% cat boot/grub2/grub.cfg
set timeout=none
menuentry "Linux Mint 13" {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
loopback loop /linuxmint-13-mate-dvd-32bit.iso
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/linuxmint-13-mate-dvd-32bit.iso noeject noprompt
initrd (loop)/casper/initrd.lz
}

リファレンス

  1. Mounting SFTP and FTP shares - Gentoo Linux Wiki
  2. sftp mount - Google 検索
  3. sshでリモートサーバーをマウント、便利にsshfs - Unix的なアレ
  4. sshで他マシンのファイルシステムをマウントするには - @IT

ソーシャルブックマーク

  1. はてなブックマーク
  2. Google Bookmarks
  3. del.icio.us

ChangeLog

  1. Posted: 2010-05-29T22:51:56+09:00
  2. Modified: 2010-05-29T22:51:56+09:00
  3. Generated: 2023-08-27T23:09:13+09:00