AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 1181854
Accepted
sudodus
sudodus
Asked: 2019-10-19 03:12:42 +0800 CST2019-10-19 03:12:42 +0800 CST 2019-10-19 03:12:42 +0800 CST

使用 Ubuntu 19.10 制作持久的实时驱动器如何更容易?

  • 772

具有持久性分区的持久性实时驱动器

有一些网站描述

  • 新工具
  • [新版本] 旧工具的新功能

它可以使用 Ubuntu 19.10 和相应的 Ubuntu 系列风格从 iso 文件创建持久的实时驱动器。

  • 为什么以及如何工作?
  • 它与早期的持久实时驱动器方法有何不同?
  • live不是克隆驱动器的默认设置吗?
boot live-usb partitioning persistence
  • 3 3 个回答
  • 21743 Views

3 个回答

  • Voted
  1. Best Answer
    sudodus
    2019-10-19T03:23:36+08:002019-10-19T03:23:36+08:00

    具有持久性分区的持久性实时驱动器

    是的,有一些网站描述了 [新版本] 旧工具中的新工具和新功能,这些旧工具可以使用 Ubuntu 19.10 和相应的 Ubuntu 系列风格从 iso 文件创建持久的实时驱动器。

    • 当直接从 iso 文件的克隆或提取副本引导时,新功能或已修复的错误(根据 此链接的“功能请求”或“错误修复”)可以使用分区进行持久性。

    这使得在 Ubuntu 19.10 中创建具有持久性分区的实时驱动器变得更加容易。

    • 在以前的 Ubuntu 版本中,可以使用 FAT32 文件系统中的文件来实现持久性。它的大小限制为 4 GiB。可以通过 grub 在单独的分区中引导(从 iso 文件的内容)并使用分区进行持久性。但这更复杂,因此不适合手动方法。

    • 在 19.10 和未来版本中,用于持久性的分区大小仅受驱动器大小(USB pendrive、SSD、HDD、存储卡)的限制。

    • Debian 10 live iso 文件也具有此功能,可用于创建具有持久性分区的持久性 live 驱动器。

    • 最新消息:在开发中的 Focal Fossa 中,将作为 20.04 LTS 发布,持久化分区的默认标签由 更改casper-rw为writable。这是在mkusb-plug版本 2.5.5 中实现的(在 PPA 中与 mkusb 版本 12.4.3 捆绑在一起)。

    工具

    Ubuntu 和 Debian

    • mkusb - 适用于所有当前版本的 Ubuntu

    如果您运行标准的 Ubuntu live,则需要额外的指令来获取存储库 Universe。(Kubuntu、Lubuntu ... Xubuntu 已自动激活存储库 Universe。)

        sudo add-apt-repository universe  # only for standard Ubuntu
    
        sudo add-apt-repository ppa:mkusb/ppa  # and press Enter
        sudo apt-get update
        sudo apt-get install mkusb mkusb-nox usb-pack-efi
    

    在此处输入图像描述

    • mkusb-minp - 可以在 Ubuntu 19.10 中使用此新功能的小型独立 shellscript。它也适用于 Debian 10。

    当您尝试旧版本或重新旋转(基于 Ubuntu 的发行版)时,请阅读警告

    对话开始: 在此处输入图像描述

    对话结束: 在此处输入图像描述

    • mkusb-plug - 可以在 Ubuntu 19.10 中使用此新功能的一小部分 shellscript。它也适用于 Debian 10。我认为使用这个带有图形用户界面的全新且非常安全的工具,您会发现事情变得更容易。

    在此处输入图像描述

    在此处输入图像描述

    在此处输入图像描述

    视窗

    • 更新: Rufus - 一个可以在 Ubuntu 19.10 中使用此新功能的知名工具。请务必使用当前版本(Rufus 3.9 或更高版本),

    • 可以很好地使用所有当前的 Ubuntu 版本创建仅实时驱动器,

    • 可以使用 Ubuntu 19.10 和未来版本创建持久的实时驱动器。请升级到版本 3.9(或更高版本),它创建了一个良好的ext3文件系统并可以制作良好的持久实时驱动器。

    • 请阅读网站上的更新日志和警告(弹出窗口),它们可以帮助您避免严重错误。

    • 编辑: Rufus 3.9 已经到来:-)

      在此处输入图像描述

    • 克隆前编辑iso文件的简单方法

    Ubuntu 19.10 中的这个新功能也可以在 Windows 中使用,

    • 使用HxD(二进制编辑器)编辑 iso 文件,以便将两个外观引导选项 'quiet splash' 替换为 'persistent'(将 12 个字符替换为 12 个字符)

    • 使用Win32 Disk Imager克隆编辑好的 iso 文件

    • 克隆驱动器第一次启动时,Ubuntu系统会自动casper-rw创建一个带有ext4文件系统的分区。简单而强大!

    • 这些链接有详细的描述:

      • wiki.ubuntu.com/Win32DiskImager/iso2usb/persistent

      在此处输入图像描述

      • wiki.ubuntu.com/Win32DiskImager/iso2usb

      在此处输入图像描述

    MacOS 和 Windows 和 Linux

    • Unetbootin - 您必须casper-rw 手动创建一个持久性分区并删除或重命名casper-rw文件

    请参阅此链接,描述如何将持久分区添加到 UNetbootin live/persistent USB (Ubuntu 19.10+)

    Please notice 'Space used to preserve files across reboots ...'
    
    [![enter image description here][10]][10]
    
    • 压缩图像文件

    您可以直接根据以下链接提取和克隆压缩的图像文件,

    Xubuntu Core 20.04 LTS 和 mkusb 12.4.5(mkusb-dus 和 mkusb-plug)

    这适用于您拥有的所有操作系统

    • 一种可以提取压缩文件的工具xz
    • 一个克隆工具

    . 在此处输入图像描述

    手动方式

    当您运行 Ubuntu 时,您只需要几个手动步骤即可创建具有持久性分区的持久性实时驱动器。

    • 编辑 iso 文件以替换quiet splash为persistent . 是的,您可以编辑二进制 iso 文件并将 12 个字符替换为 12 个其他字符并将输出闪存到目标设备(通常是 USB 随身碟)。sed可以做到。

    • 在已编辑的 iso 文件的闪存副本“后面”创建一个分区。fdisk可以做到。

    • 在这个分区中创建一个ext2文件系统,并将标签casper-rw 放在这个分区上。mkfs.ext2可以做到。

    • 冲洗缓冲区。sync可以做到。

    这就是mkusb-minp正在做的事情加上大量的检查,将安全带缠绕在整个过程中。换句话说,您可以获得写入正确目标设备的帮助,并在可能出现问题时收到警告。

    可以自己动手,感受每一步,也可以阅读shellscript的代码,mkusb-minp了解细节。

    请注意,我dus在以下示例中使用并选择了“克隆”。您可以使用其他克隆工具,但如果您使用简单的工具dd,请 仔细检查您正在克隆到当前设备,并且该设备上的所有分区都已卸载。

    strings lubuntu-19.10-desktop-amd64.iso |grep 'quiet splash'  # check that 'quiet splash' is there to be replaced by 'persistent  ' (12 characters)
    sed 's/quiet splash/persistent  /' lubuntu-19.10-desktop-amd64.iso > persistent-lubuntu-19.10-desktop-amd64.iso  # yes, sed works with binary files
    ls -l *19.10*  # check that the size is the same
    strings persistent-lubuntu-19.10-desktop-amd64.iso |grep 'persistent  '  # check that 'persistent' is there now
    dus persistent-lubuntu-19.10-desktop-amd64.iso  # I use mkusb-dus, you can use the Ubuntu Startup Disk Creator or another cloning tool
    sudo lsblk -fm  # It is important to check the device letter of the target drive (the USB drive, that you want persistent live
    sudo fdisk /dev/sdx  # x is the device letter of the target drive, please double-check that you have the correct letter
    n           # new partition
    p           # primary
    <Return>    # default: 3
    <Return>    # default: next free sector
    <Return>    # default: last addressable sector
    w           # write and quit
    sudo lsblk -fm  # check that things look good and verify that partition #3 is the correct partition to be used to store the persistent data
    sudo mkfs.ext2 -L casper-rw /dev/sdx3  # put label and file system into the partition of persistence
    sudo lsblk -fm  # check that things look good
    sync  # flush the buffers and wait for prompt
    

    链接

    • 使用 Lubuntu Eoan 克隆的 USB 驱动器可以持久化
    • F. Hauri 开发的适用于 Debian 10 的方法

    有一些通用的手动方法可以很容易地从使用文件进行持久性修改为使用分区进行持久性。请参阅以下链接,

    • help.ubuntu.com/community/Installation/iso2usb/diy

    克隆的 Ubuntu 19.10+ live 驱动器并不是真正的 live-only

    live 不是克隆驱动器的默认设置吗?

    嗯,它曾经是,它仍然存在,但不是仅在 19.10 中存在。

    如果你想制作一个纯实时驱动器,在关机和重启后什么都不会保留,你可以

    • 使用带有选项的mkusb-minp-n或mkusb-plug并选择“No-persistent live drive”。

    • 或手动修改内置引导选项,将 'quiet splash' 替换为 'nopersistent'

    关联

    • 如何使用 Ubuntu 19.10 和更新版本获得仅实时驱动器?
    • 21
  2. Martian2020
    2021-10-30T08:14:47+08:002021-10-30T08:14:47+08:00

    bash根据@sudodus 的回答,我编写了一个脚本(一个衬里)来编辑实时 USB 磁盘以将“安静的启动”更改为“持久的”。

    免责声明:它适用于我的系统,使用风险自负。它适用于bash,可能无法在没有编辑的其他 shell 上工作。

    After boot from USB extra partition writable was created w/out my intervention for overlay for persistence, if not fdisk can be used.

    First variant of code is not efficient as it starts search with grep all over after each edit; but it can be stopped via ctrl-c when some changes are made.

    device_to_edit=/dev/sdb; string_to_edit="quiet splas\x68"; new_string="persistent  "; block_size=512; ed_count=0; to_end=""; if [ ! ${#string_to_edit} -eq ${#new_string} ]; then echo -e "\n Suspect a danger as strings lengths not same"; elif [ $block_size -lt ${#new_string} ]; then echo -e "\n\ Suspect a danger as block size too small for string length"; elif file_size=$(lsblk -b --output PATH,SIZE | grep "$device_to_edit " | sed -E 's/.* ([0-9]{1,})/\1/'); [ $((file_size/1024/1024/1024)) -gt 20 ]; then echo -e "\n Suspect a danger as device size is large"; else while [ -z $to_end ]; do offset_to_edit=$(sudo grep --only-matching --byte-offset --max-count=1 --text --perl-regexp "$string_to_edit" $device_to_edit | awk --field-separator ":" '{ FS = "0" ; print $1 ; exit }'); if [ -z "$offset_to_edit" ]; then echo -e "\n end of file is reached" ; to_end="yes" ; else block_to_edit=$(($offset_to_edit/$block_size)) ; sudo dd if=/$device_to_edit count=2 skip=$block_to_edit bs=$block_size | sed "s/$string_to_edit/$new_string/" | sudo dd conv=notrunc of=$device_to_edit count=2 seek=$block_to_edit bs=$block_size; echo "blocks $block_to_edit and next edited (blocks start with 0)"; ((ed_count++)) ; fi ; done ; echo -e "\n$ed_count editions made"; fi
    

    In second variant of code grep is done only one time, but grep goes through complete file (e.g. block device, USB) which can take significant time before any editing (on my system it took ~ 15 minutes for 8Gb drive, I added date for the sake of that curiosity):

    date; device_to_edit=/dev/sdb; string_to_edit="quiet splash"; new_string="persistent  "; block_size=512; ed_count=0; to_end=""; if [ ! ${#string_to_edit} -eq ${#new_string} ]; then echo -e "\n Suspect a danger as strings lengths not same"; elif [ $block_size -lt ${#new_string} ]; then echo -e "\n\ Suspect a danger as block size too small for string length"; elif file_size=$(lsblk -b --output PATH,SIZE | grep "$device_to_edit " | sed -E 's/.* ([0-9]{1,})/\1/'); [ $((file_size/1024/1024/1024)) -gt 20 ]; then echo -e "\n Suspect a danger as device size is large"; else sudo grep --only-matching --byte-offset --text --perl-regexp "$string_to_edit" $device_to_edit | awk --field-separator ":" '{ FS = ":" ; print $1 }' | { IFS=$'\n' read -d '' -a offsets_to_edit ; for offset in ${offsets_to_edit[@]}; do block_to_edit=$(($offset/$block_size)) ; sudo dd if=/$device_to_edit count=2 skip=$block_to_edit bs=$block_size | sed "s/$string_to_edit/$new_string/" | sudo dd conv=notrunc of=$device_to_edit count=2 seek=$block_to_edit bs=$block_size; echo "blocks $block_to_edit and next edited (blocks start with 0)"; ((ed_count++)); done; echo -e "\n$ed_count editions made"; } ; fi; date
    

    Notes:

    Meaning of the scripts parameters and syntax could be understood by reading man bash, man awk, man sed, info '(coreutils) dd invocation', help read. Why (list) / { list; } needed in pipe is explained in https://stackoverflow.com/questions/2746553/read-values-into-a-shell-variable-from-a-pipe ("A pipeline may spawn a subshell, where the environment is inherited by value, not by reference"), working with two blocks is needed in case string starts in one block and ends in next one.

    The scrips include three safety checks: lengths of original and replacement strings are same, block size is sufficiently large, device size is not larger then 20Gb (against accidental edit of main drive, need to be edited for larger flash storage, code is $((file_size/1024/1024/1024)) -gt 20).

    脚本中有一些冗余,即FS = ":" ;in awk,由于某种原因,字段分隔符没有像我预期的那样工作,我不得不添加--field-separator ":",还grep --perl-regexp需要 in 才能使用十六进制\xaa值,但是这个编辑没有它们。

    • 4
  3. C.S.Cameron
    2019-10-23T23:22:27+08:002019-10-23T23:22:27+08:00

    Rufus 是使用 Ubuntu 19.10 制作持久实时驱动器的最简单工具

    (但不一定是最好的)。

    为了在 Ubuntu 中制作不限于 4GB 的永久驱动器,mkusb 是最容易(也是最好)使用的。(那里还有什么)?

    为了在 Windows 10 中制作不限于 4GB 的永久驱动器,Rufus 似乎是目前最容易使用的工具。

    但这并不能使它成为最好的工具。

    我做了一些简单的实验,比较了最新版本的 Rufus 和 mkusb:

    首先,我擦除了 4GB USB,然后在 Windows 10 中运行 Rufus,重新启动,并使用 Disk Usage Analyzer 查看 /casper-rw/upper/ 文件夹。

    然后我删除了 casper-rw 分区并创建了一个新分区。

    我重新启动了几次驱动器,没有进行任何更改或保存任何内容,然后再次查看了使用 DUA 重新填充的持久分区。

    我再次擦除了驱动器并使用 mkusb 创建了另一个持久 USB,重新启动并使用 DUA 再次查看。

    我再次删除了 casper-rw 分区并创建了一个新分区。

    我重新启动了几次驱动器,没有进行任何更改,然后再次查看了使用 DUA 重新填充的持久分区。

    从附表可以看出,mkusb 在磁盘空间的使用上似乎更胜一筹,而 grub 2 比 syslinux 更直接。

    使用 Rufus 制作的持久 USB

    使用 Rufus 制作的持久 USB

    用 Rufus 制造的持久性 USB 重新填充

    使用 Rufus 制作的持久性 USB,带有重新填充的 casper-rw 分区

    使用 mkusb 制作的持久 USB

    使用 mkusb 制作的持久 USB

    使用 mkusb 重新填充的持久 USB

    使用 mkusb 制作的持久 USB,带有重新填充的 casper-rw 分区

    编辑:跟踪永久磁盘空间使用情况。

    我查看了 Rufus 和 mkusb 新制作的持久 USB 的 casper-rw 分区中的磁盘空间使用情况

    Rufus var 文件夹

    Rufus var 文件夹

    Rufus snaps 文件夹的内容

    Rufus snaps 文件夹的内容

    ![mkusb var 文件夹

    mkusb var 文件夹

    ![mkusb snaps 文件夹的内容

    mkusb snaps 文件夹的内容

    数据尚未确认

    编辑:鲁弗斯 3.9.1624

    使用最新版本的 Rufus 运行 Disk Usage Analyzer,结果接近 Rufus 3.8。看来 mkusb 仍然是一种更节省空间的持久驱动器。

    在此处输入图像描述 使用 Rufus 3.9 Rufus 3.9 var 文件夹制作的持久 USB在此处输入图像描述

    同样,数据和方法尚未得到确认。

    • 0

相关问题

  • 如何从双启动计算机访问加密的主文件夹?

  • 如何在 Ubuntu 启动时显示或隐藏启动消息?

  • 您对台式机和家庭服务器的驱动器分区方案有什么建议?[关闭]

  • 如何避免启动时出现“S to Skip”消息?

  • 如何使用 Mac 创建 Ubuntu live USB?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve