当前位置: 首页>>技术教程>>正文


partitioning – 2分区usb-drive上的实时USB

, ,

问题描述

我想知道我是否可以在USB-drive上有2个分区,以使我可以像普通的USB-installation-disk(分区1)那样在我的钥匙上启动,而在Windows /Ubuntu(分区2)下有另一个分区用于常规存储。我想有一个磁盘:

/dev/sdb (16GB)
 - sdb1 : ext4/fat32, LiveUSB (2GB)
 - sdb2 : fat32, storage (14GB)

该密钥可以启动并用作常规USB驱动器吗?

PS:那是因为每次我需要抢救PC时我都讨厌在USB驱动器上安装/卸载Ubuntu,并且我不愿意只为Ubuntu-installation-disk购买USB-drive。

最佳办法

是的,您可以对USB闪存驱动器进行分区以引导进入Ubuntu Live Session,并在单独的分区上将其用作常规USB驱动器(可通过Windows访问)。我能够在装有UEFI和Windows 8.0的Sony Vaio T系列Ultrabook笔记本电脑上使用32GB PNY USB 2.0闪存驱动器来执行此操作。我还在我的16TB RAID5 i7-290服务器上的Ubuntu服务器12.04上对此进行了测试。

在以下配置中,我使用GParted对USB闪存驱动器进行了分区:

sdh1是Windows可以访问的”Storage”分区。 sdh2是Ubuntu桌面12.04 boot-able分区。这些是我的步骤:


 1. Created a new 10 GB, ntfs, logical partition, with 25 MB Free space preceding     and 0 MB following, labeled Storage (must be first on the drive)
 2. Created a new 5 GB, fat32, logical partition, with 0 MB preceding and following
 3. Set a boot flag for the second partition
 4. (Created the other partitions which are not needed)
 5. Booted to a Ubuntu Live Session loaded on a DVD and selected Try Ubuntu     without installing from the GRUB menu
 6. Opened Startup Disk Creator with the USB flash drive pluged-in
 7. The Ubuntu-Desktop 12.04 Image and pny USB 2.0 flash drive (/dev/sdh2) 5.0 GB     partition were already selected, moved the How much slide to store documents     and settings in reserved extra space and selected Make Startup Disk

如果不选择启动标志,启动磁盘创建器将只能将整个闪存驱动器识别为/dev/sdh,而不是所需的第二个分区/dev/sdh2

如果不首先放置Windows分区,则Removable Media Bit


"The removable media device setting is a flag contained within the SCSI Inquiry Data response to the SCSI Inquiry command. Bit 7 of byte 1 (indexed from 0) is the Removable Media Bit (RMB). An RMB set to zero indicates that the device is not aremovable media device. An RMB of one indicates that the device is a removable media device. Drivers obtain this information by using the StorageDevicePropertyrequest."

would mean在Windows中仅显示1个分区:


"Q. What is a superfloppy?

A.  
Removable media without either GPT or MBR formatting is considered a "superfloppy." The entire media is treated as a single partition. 
The media manufacturer performs any MBR partitioning of removable media. If the media does have an MBR, only one partition is supported. There is little user-discernible difference between MBR-partitioned media and superfloppies. 
Examples of removable media include floppy disk drives, JAZ disk cartridges, magneto-optical media, DVD-ROM, and CD-ROM. Hard disk drives on external buses such as SCSI or IEEE 1394 are not considered removable."

以下是一些可以翻转人民币的工具(在这种情况下是不需要的):Laxar’s USB Format Tool Bootice RMPrepUSB

这些是软件方法(在这种情况下,也是不必要的):创建dummy.sys Driver使用Hitachi Microdrive Filterdriver

信用:TSJNachos117 Live USB on a 2-partition usb-drive http://ubuntuforums.org/showthread.php?t=1020293 https://stackoverflow.com/questions/2598502/howto-flip-removable-bit-on-usb-drive-in-c http://www.rmprepusb.com/tutorials/multipartufd

次佳办法

我发现了一种更简单的替代方法。关于它为什么起作用,需要了解两点重要信息。第一个是关于引导过程,以及有关初始开机自检(由BIOS执行)如何在所连接设备的第一个引导扇区上查找引导记录的信息。这是一个小文件,基本上将引导执行过程传递给引导装载程序/管理器,例如在较新的Linux安装中,为GRUB2。有关此的更多信息,请阅读此非常有帮助的post

第二条信息是要了解Linux操作系统的ISO下载旨在安装在磁盘(CD /DVD /USB)上,而不是分区上。这些ISO需要使用一个小的工具进行修改,该工具可以在syslinux-utils软件包中找到,称为isohybrid。用于在分区上安装的ISO修改是使用--partok flag完成的。我从post中找到了此信息,该信息描述了完全相同的问题。我不确定--partok魔术的工作方式,我搜索了一些解释,但找不到任何解释。

总之,这是我进行的实时安装PureOS从USB分区启动的操作,

  1. 我使用GNOME磁盘对USB进行了分区,最初使用MBR /DOS格式化了磁盘。我在剩余空间中创建了一个4GB分区(FAT32),然后创建了一个ext4 Linux分区,以进行备份。

  2. 接下来,我修改了下载的ISO文件,使其可从分区启动。为此,我必须从isohybrid工具所在的存储库中安装syslinux-utils

    sudo apt-get install syslinux-utils
    

    然后,我使用以下命令修改了ISO文件:

    isohybrid --partok pureos.ISO
    
  3. 我使用dd将此ISO复制到上述分区。您可以从GNOME磁盘详细信息中获取分区设备。

    dd if=pureos.ISO of=/dev/sdb1 bs=1M
    
  4. 在GNOME磁盘上,我编辑了分区并检查了可引导选项,该选项将安装所需的书记录。

现在,我可以从USB密钥引导到实时CD,并将其用作恢复解决方案,同时将系统备份存储在另一个分区上。

第三种办法

这应该很容易做到。但是,请提前警告Windows将只能看到第一个分区(/dev/sdb1),第二个分区将是不可见的(我不知道为什么)。因此,我建议将general-purpose存储分区作为第一个分区,将LiveUSB分区作为第二个分区。

如果执行此操作后仍无法启动,则应该可以使用GParted设置启动标志。

请注意:尽管我之前已经成功完成了此操作,但我从未测试过在基于UEFI的系统上执行类似的操作,更不用说使用安全启动的操作了。

参考资料

本文由Ubuntu问答整理, 博文地址: https://ubuntuqa.com/article/11360.html,未经允许,请勿转载。