Preparing Files for USB Memory Stick Booting

Stella981
• 阅读 581

4.3. Preparing Files for USB Memory Stick Booting

There are two installation methods possible when booting from USB stick. The first is to install completely from the network. The second is to also copy a CD image onto the USB stick and use that as a source for packages, possibly in combination with a mirror. This second method is the more common.

For the first installation method you'll need to download an installer image from the netboot directory (at the location mentioned in Section 4.2.1, “Where to Find Installation Images”) and use the “flexible way” explained below to copy the files to the USB stick.

Installation images for the second installation method can be found in the hd-media directory and either the “easy way” or the “flexible way” can be used to copy the image to the USB stick. For this installation method you will also need to download a CD image. The installation image and the CD image must be based on the same release of debian-installer. If they do not match you are likely to get errors[6] during the installation.

To prepare the USB stick, you will need a system where GNU/Linux is already running and where USB is supported. With current GNU/Linux systems the USB stick should be automatically recognized when you insert it. If it is not you should check that the usb-storage kernel module is loaded. When the USB stick is inserted, it will be mapped to a device named /dev/sdX, where the “X” is a letter in the range a-z. You should be able to see to which device the USB stick was mapped by running the command dmesg after inserting it. To write to your stick, you may have to turn off its write protection switch.

Warning

The procedures described in this section will destroy anything already on the device! Make very sure that you use the correct device name for your USB stick. If you use the wrong device the result could be that all information on for example a hard disk could be lost.

Note that the USB stick should be at least 256 MB in size (smaller setups are possible if you follow Section 4.3.2, “Copying the files — the flexible way”).

4.3.1. Copying the files — the easy way

There is an all-in-one file hd-media/boot.img.gz which contains all the installer files (including the kernel) as well as syslinux and its configuration file.

Note that, although convenient, this method does have one major disadvantage: the logical size of the device will be limited to 256 MB, even if the capacity of the USB stick is larger. You will need to repartition the USB stick and create new file systems to get its full capacity back if you ever want to use it for some different purpose. A second disadvantage is that you cannot copy a full CD image onto the USB stick, but only the smaller businesscard or netinst CD images.

To use this image simply extract it directly to your USB stick:

# zcat boot.img.gz > /dev/sdX

After that, mount the USB memory stick (mount /dev/_`sdX`_ /mnt), which will now have a FAT filesystem on it, and copy a Debian netinst or businesscard ISO image to it. Unmount the stick (umount /mnt) and you are done.

4.3.2. Copying the files — the flexible way

If you like more flexibility or just want to know what's going on, you should use the following method to put the files on your stick. One advantage of using this method is that — if the capacity of your USB stick is large enough — you have the option of copying a full CD ISO image to it.

4.3.2.1. Partitioning the USB stick

We will show how to set up the memory stick to use the first partition, instead of the entire device.

Note

Since most USB sticks come pre-configured with a single FAT16 partition, you probably won't have to repartition or reformat the stick. If you have to do that anyway, use cfdisk or any other partitioning tool to create a FAT16 partition[7], and then create the filesystem using:

# mkdosfs /dev/sdX1

Take care that you use the correct device name for your USB stick. The mkdosfs command is contained in the dosfstools Debian package.

In order to start the kernel after booting from the USB stick, we will put a boot loader on the stick. Although any boot loader (e.g. lilo) should work, it's convenient to use syslinux, since it uses a FAT16 partition and can be reconfigured by just editing a text file. Any operating system which supports the FAT file system can be used to make changes to the configuration of the boot loader.

To put syslinux on the FAT16 partition on your USB stick, install the syslinux and mtools packages on your system, and do:

# syslinux /dev/sdX1

Again, take care that you use the correct device name. The partition must not be mounted when starting syslinux. This procedure writes a boot sector to the partition and creates the file ldlinux.sys which contains the boot loader code.

4.3.2.2. Adding the installer image

Mount the partition (mount /dev/_`sdX1`_ /mnt) and copy the following installer image files to the stick:

  • vmlinuz or linux (kernel binary)

  • initrd.gz (initial ramdisk image)

You can choose between either the regular version or the graphical version of the installer. The latter can be found in the gtk subdirectory. If you want to rename the files, please note that syslinux can only process DOS (8.3) file names.

Next you should create a syslinux.cfg configuration file, which at a bare minimum should contain the following two lines (change the name of the kernel binary to “linux” if you used a netboot image):

default vmlinuz append initrd=initrd.gz

For the graphical installer you should add video=vesa:ywrap,mtrr vga=788 to the second line.

If you used an hd-media image, you should now copy a Debian ISO image[8] onto the stick. When you are done, unmount the USB memory stick (umount /mnt).

4.3.3. Booting the USB stick

Warning

If your system refuses to boot from the memory stick, the stick may contain an invalid master boot record (MBR). To fix this, use the install-mbr command from the package mbr:

# install-mbr /dev/sdX
点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Wesley13 Wesley13
3年前
java将前端的json数组字符串转换为列表
记录下在前端通过ajax提交了一个json数组的字符串,在后端如何转换为列表。前端数据转化与请求varcontracts{id:'1',name:'yanggb合同1'},{id:'2',name:'yanggb合同2'},{id:'3',name:'yang
待兔 待兔
3个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Stella981 Stella981
3年前
KVM调整cpu和内存
一.修改kvm虚拟机的配置1、virsheditcentos7找到“memory”和“vcpu”标签,将<namecentos7</name<uuid2220a6d1a36a4fbb8523e078b3dfe795</uuid
Stella981 Stella981
3年前
Android So动态加载 优雅实现与原理分析
背景:漫品Android客户端集成适配转换功能(基于目标识别(So库35M)和人脸识别库(5M)),导致apk体积50M左右,为优化客户端体验,决定实现So文件动态加载.!(https://oscimg.oschina.net/oscnet/00d1ff90e4b34869664fef59e3ec3fdd20b.png)点击上方“蓝字”关注我
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Wesley13 Wesley13
3年前
35岁是技术人的天花板吗?
35岁是技术人的天花板吗?我非常不认同“35岁现象”,人类没有那么脆弱,人类的智力不会说是35岁之后就停止发展,更不是说35岁之后就没有机会了。马云35岁还在教书,任正非35岁还在工厂上班。为什么技术人员到35岁就应该退役了呢?所以35岁根本就不是一个问题,我今年已经37岁了,我发现我才刚刚找到自己的节奏,刚刚上路。
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
9个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这