■debian stretch上で、最新バージョンのnetinstllイメージを取得、USB起動する。
導入機器を増やす目的でインストーラを作成する。
今回はsdb3はフォーマットするだけで、以下のように追加のISOを用意しない。
jessieのUSB起動メディアを作成する。
http://labunix.hateblo.jp/entry/20151112/1447259525
■USBメモリを操作する環境の確認
$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.3 (stretch)
Release: 9.3
Codename: stretch
■debian stretch上で、最新バージョンのnetinstllイメージを取得
公式(32.7KB/s)、ミラーサイト(2.89MB/s)では全然速さが違う。
公式 :http://cdimage.debian.org/debian-cd/current
ミラー:http://ftp.riken.jp/Linux/debian/debian-cdimage/release/current
$ echo http://ftp.riken.jp/Linux/debian/debian-cdimage/release/current/$(uname -r | awk -F\- '{print $NF}')/iso-cd/ | \
awk '{print "echo -n "$0"$(w3m -dump "$0" | awk \047/.iso/&&!/mac/&&/netinst/{print $3}\047)"}' | \
sh | xargs wget -c
■SHA1SUMSとsha1sumでハッシュの比較
$ echo http://ftp.riken.jp/Linux/debian/debian-cdimage/release/current/$(uname -r | awk -F\- '{print $NF}')/iso-cd/SHA1SUMS | \
awk '{print "w3m -dump "$0" | awk \047/netinst/&&/.iso/&&!/mac/\047"}' | sh
0dab4812fd1bb959e506d7ff6096bc9cb04d824a debian-9.3.0-amd64-netinst.iso
$ sha1sum debian-9.3.0-amd64-netinst.iso
0dab4812fd1bb959e506d7ff6096bc9cb04d824a debian-9.3.0-amd64-netinst.iso
■今回は64GBのUSBメモリを使用、USBメモリが認識されていてマウントされていないことを確認。
$ sudo dmesg | awk '/\[sd[b-z]/'
[434128.399497] sd 6:0:0:0: [sdb] 120933888 512-byte logical blocks: (61.9 GB/57.7 GiB)
[434128.399778] sd 6:0:0:0: [sdb] Write Protect is off
[434128.399780] sd 6:0:0:0: [sdb] Mode Sense: 45 00 00 00
[434128.400061] sd 6:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[434128.616909] sd 6:0:0:0: [sdb] Attached SCSI removable disk
$ sudo mount | grep sdb | wc -l
0
■既存のパーティションを確認する。
以下で4,5年前にもWheezyのUSB起動で使用したUSBメモリだった。
debian wheezyのUSB起動インストーラの作成
http://labunix.hateblo.jp/entry/20131228/1388238056
$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 57.7 GiB, 61918150656 bytes, 120933888 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
Disklabel type: dos
Disk identifier: 0x18402221
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 120933887 120931840 57.7G 7 HPFS/NTFS/exFAT
■USBメモリのパーティション切り直し
$ sudo fdisk /dev/sdb
...
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (32-120933887, default 32):
Last sector, +sectors or +size{K,M,G,T,P} (32-120933887, default 120933887):
Created a new partition 1 of type 'Linux' and of size 57.7 GiB.
Command (m for help): p
Disk /dev/sdb: 57.7 GiB, 61918150656 bytes, 120933888 sectors
Geometry: 48 heads, 32 sectors/track, 59049 cylinders
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x18402221
Device Boot Start End Sectors Size Id Type
/dev/sdb1 32 120933887 120933856 57.7G 83 Linux
Command (m for help): wq
The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: デバイスもしくはリソースがビジー状態です
The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
$ su root -c 'sync;sync;sync'
$ sudo eject /dev/sdb && echo "USBメモリの抜き差し"
USBメモリの抜き差し
$ sudo dmesg | awk '/\[sd[b-z]/'
[438865.038866] sd 6:0:0:0: [sdb] 120933888 512-byte logical blocks: (61.9 GB/57.7 GiB)
[438865.039151] sd 6:0:0:0: [sdb] Write Protect is off
[438865.039153] sd 6:0:0:0: [sdb] Mode Sense: 45 00 00 00
[438865.039420] sd 6:0:0:0: [sdb] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA
[438865.266999] sd 6:0:0:0: [sdb] Attached SCSI removable disk
■最小インストーラを書き込み。
$ sudo dd if=debian-9.3.0-amd64-netinst.iso of=/dev/sdb bs=512
593920+0 レコード入力
593920+0 レコード出力
304087040 bytes (304 MB, 290 MiB) copied, 23.3105 s, 13.0 MB/s
■起動可能かどうかのチェック
$ sudo fdisk /dev/sdb -l
Disk /dev/sdb: 57.7 GiB, 61918150656 bytes, 120933888 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
Disklabel type: dos
Disk identifier: 0x0347fd41
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 0 593919 593920 290M 0 Empty
/dev/sdb2 3760 4591 832 416K ef EFI (FAT-12/16/32)
■sdb3を作成
$ sudo fdisk /dev/sdb -l
Disk /dev/sdb: 57.7 GiB, 61918150656 bytes, 120933888 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
Disklabel type: dos
Disk identifier: 0x0347fd41
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 0 593919 593920 290M 0 Empty
/dev/sdb2 3760 4591 832 416K ef EFI (FAT-12/16/32)
(
Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/sdb: 57.7 GiB, 61918150656 bytes, 120933888 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
Disklabel type: dos
Disk identifier: 0x0347fd41
Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 0 593919 593920 290M 0 Empty
/dev/sdb2 3760 4591 832 416K ef EFI (FAT-12/16/32)
Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3):
First sector (593920-120933887, default 593920):
Last sector, +sectors or +size{K,M,G,T,P} (593920-120933887, default 120933887):
Created a new partition 3 of type 'Linux' and of size 57.4 GiB.
Command (m for help): wq
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
$ su root -c 'sync;sync;sync'