如何制作 Ubuntu 16.04 的持久实时 USB?

Léo*_* 준영 11 live-usb boot 16.04

我需要最好是 16.04 的持久实时 Ubuntu,因为我需要拯救我的整个 16.04 加密硬盘,如线程如何将自己添加回 16.04 加密硬盘中的 sudo 组? 我在这里创建了一个新的持久 Live Ubuntu 16.04,并在末尾使用Videonauth描述了一些错误。

  1. sudo apt-get install gksu debootstrap
  2. gksudo gparted. 制作USB时ext4只留1GB空闲内存,Linux Swap设置1GB;管理标志 > only boot
  3. 准备操作系统并在 U 盘中运行

    sudo mkdir /mnt/stick
    sudo mount /dev/sdb1 /mnt/stick/
    sudo debootstrap --arch=amd64 xenial /mnt/stick http://de.archive.ubuntu.com/ubuntu/
    sudo mount -o bind /dev /mnt/stick/dev
    sudo mount -o bind /dev/pts /mnt/stick/dev/pts
    sudo mount -t sysfs /sys /mnt/stick/sys
    sudo mount -t proc /proc /mnt/stick/proc
    sudo cp /proc/mounts /mnt/stick/etc/mtab
    sudo cp /etc/resolv.conf /mnt/stick/etc/resolv.conf
    sudo chroot /mnt/stick/
    
    Run Code Online (Sandbox Code Playgroud)
  4. 提示看起来像root@masi-CM6340:/#。设置语言环境。

    %locale-gen en_US en_US.UTF-8
    %dpkg-reconfigure locale
    dpkg-rekonfigure locales % two above commands cause a bug in gnome-terminal; choose here your locales and set environment en_US.UTF-8
    dpkg-reconfigure keyboard-configuration
    localedef -i en_US -c -f UTF-8 en_US.UTF-8
    
    Run Code Online (Sandbox Code Playgroud)
  5. apt-get install linux-image-generic. 你得到/dev/sda [NotThisOne, your HDD], 2 /dev/sdb (31474 MB; ???) 2b - /dev/sdb1 (30398 MB; /)。选择/dev/sdb1/dev/sdb。在这里选择你喜欢的 Linux 内核。我保持 Linux 内核 4.6 最稳定,您可以按照正文末尾的描述下载。

  6. apt-get install vim wget

  7. blkid,复制到剪贴板,vim /etc/fstab。删除sda行,所以只有两sdb行。编辑它们以喜欢UUID="..." swap swap defaulst 0 0UUID="..." / ext4 defaults 0 1

  8. 将以下内容粘贴到文件中 /etc/apt/sources.list

    #deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
    
    # See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
    # newer versions of the distribution.
    deb http://de.archive.ubuntu.com/ubuntu/ xenial main restricted
    # deb-src http://de.archive.ubuntu.com/ubuntu/ xenial main restricted
    
    ## Major bug fix updates produced after the final release of the
    ## distribution.
    deb http://de.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
    # deb-src http://de.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
    
    ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
    ## team, and may not be under a free licence. Please satisfy yourself as to
    ## your rights to use the software. Also, please note that software in
    ## universe WILL NOT receive any review or updates from the Ubuntu security
    ## team.
    deb http://de.archive.ubuntu.com/ubuntu/ xenial universe
    # deb-src http://de.archive.ubuntu.com/ubuntu/ xenial universe
    deb http://de.archive.ubuntu.com/ubuntu/ xenial-updates universe
    # deb-src http://de.archive.ubuntu.com/ubuntu/ xenial-updates universe
    
    ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu 
    ## team, and may not be under a free licence. Please satisfy yourself as to 
    ## your rights to use the software. Also, please note that software in 
    ## multiverse WILL NOT receive any review or updates from the Ubuntu
    ## security team.
    deb http://de.archive.ubuntu.com/ubuntu/ xenial multiverse
    # deb-src http://de.archive.ubuntu.com/ubuntu/ xenial multiverse
    deb http://de.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
    # deb-src http://de.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
    
    ## N.B. software from this repository may not have been tested as
    ## extensively as that contained in the main release, although it includes
    ## newer versions of some applications which may provide useful features.
    ## Also, please note that software in backports WILL NOT receive any review
    ## or updates from the Ubuntu security team.
    deb http://de.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
    # deb-src http://de.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
    
    ## Uncomment the following two lines to add software from Canonical's
    ## 'partner' repository.
    ## This software is not part of Ubuntu, but is offered by Canonical and the
    ## respective vendors as a service to Ubuntu users.
    deb http://archive.canonical.com/ubuntu xenial partner
    deb-src http://archive.canonical.com/ubuntu xenial partner
    
    deb http://security.ubuntu.com/ubuntu xenial-security main restricted
    # deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
    deb http://security.ubuntu.com/ubuntu xenial-security universe
    # deb-src http://security.ubuntu.com/ubuntu xenial-security universe
    deb http://security.ubuntu.com/ubuntu xenial-security multiverse
    # deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse
    
    Run Code Online (Sandbox Code Playgroud)
  9. dpkg-divert --local --rename --add /sbin/initctl
    ln -s /bin/true /sbin/initctl
    apt-get update
    % Comment this out if ubuntu-desktop is wanted
    apt-get install ubuntu-desktop 
    % Comment out if ubuntu-server is wanted
    % apt-get install ubuntu-server
    adduser --home /home/masi masi
    
    Run Code Online (Sandbox Code Playgroud)
  10. 添加masi到现有组中usermod -aG adm,cdrom,sudo,dip,plugdev,lpadmin,sambashare masi,您可以在其中省略sambashare

  11. 忽略驱动程序,因为 USB 记忆棒不是为一台 PC 制作的。

  12. 对于恢复加密的硬盘,安装的软件包apt-get ecryptfs-utils schroot testdisk,其中testdisk准备光盘和其他两个用于恢复加密的Ubuntu 16.04整个光盘。

  13. sudo echo 'GRUB_DISABLE_OS_PROBER="true"' >> /etc/default/grub; update-grub

  14. 完成安装。做

    rm /sbin/initctl
    dpkg-divert --local --rename --remove /sbin/initctl
    
    Run Code Online (Sandbox Code Playgroud)

测试 Persistent Live Ubuntu 16.04 [alpha] 的安装

  1. 启动新的 Persistent Ubuntu。在终端中,执行sudo true. 如果你得到Unable to resolve host * Connection refused,做

    # https://askubuntu.com/q/59458/25388
    sudo vim /etc/hostname
    masi 
    
    sudo vim /etc/hosts 
    127.0.0.1    localhost.localdomain masi
    [...]
    
    Run Code Online (Sandbox Code Playgroud)
  2. 可能的并发症:Ubuntu 以 $(inittramfs)$ 开始。做 ...

结果:USB 启动 Ubuntu 桌面 GUI 和 UI

  • 您可以打开 LibreOffice、Firefox、...
  • masi在 sudo 组中;组正确。
  • 何时chroot坚持使用区域设置正确。
  • 如果您在 gnome-terminal 中有错误,即在 GUI 中打开它,请sudo dpkg-rekonfigure locales在 TTY1 中再次执行。它解决了这个问题。

报告给 Videonauth 的错误

在进行测试时始终更新和升级系统:sudo apt-get update && sudo apt-get upgrade.

  1. Ubuntu 的互联网浏览器。启动它会使系统崩溃。鼠标只能工作,但没有信号可以发送到 TTY。
  2. 火狐。启动它会发出关于 [profile exists] 的警告,因此无法打开。rm -r ~/.mozilla && rm -r ./.cache/mozilla仅针对一个会话进行临时修复。每次登录时问题仍然存在。更好的工作修复:sudo mv -v /home/masi /home/masi_backup, sudo mkdir -v /home/masi, sudo chown masi:masi /home/masi,sudo chmod 755 /home/masi并且sudo reboot因为主文件夹的某些所有权导致错误。运行源码的命令,你得到以下区别
  3. /etc/hostname/etc/hosts一段时间后无法匹配
  4. 有时,启动到 (inittramsfs)

输出 vimdiff <(find /home/masi -printf "%P %u:%g %m\n" | sort) <(find /home/masi_backup -printf "%P %u:%g %m\n" | sort)

%LHS-file
.bash_history masi:masi 600
.cache/compizconfig-1/animation.pb masi:masi 664
.cache/compizconfig-1/commands.pb masi:masi 664
.cache/compizconfig-1/compiztoolbox.pb masi:masi 664
% here many files not existing in the RHS

%RHS-file (fresh installation)
.bash_history root:root 600
.bash_logout masi:masi 664
.bashrc masi:masi 644
.cache root:root 700
Run Code Online (Sandbox Code Playgroud)

我不明白是哪个导致了错误。

升级到 Linux 内核 4.6

按照此处的说明操作。在 Linux 内核 4.4 中,resume/suspend 有一个普遍的错误。升级到 4.6 解决了这个问题并使系统变得更好。

系统:14.04、16.04
Linux 内核:4.4 - 4.6

Vid*_*uth 11

要在 USB 或外部 HDD 上完全正常安装 Ubuntu,您可以按照我在此处描述的步骤进行操作。

你想先做一些准备安装,你需要gksudo包中的哪个gksuschrootdebootstrap. 这些软件包不被默认安装,所以输入一个终端(ctrl+ alt+ t):

sudo apt-get install gksu debootstrap schroot
Run Code Online (Sandbox Code Playgroud)

现在,您可以通过以下方式开始准备 USB/HDD 以进行安装:

gksudo gparted
Run Code Online (Sandbox Code Playgroud)

首先,您要转到devices菜单并选择create partition table,当被要求选择类型时msdos。现在您应该看到未分配空间的条目。单击此选项并选择 new 并将其设置为 ext4,仅保留 1GB 作为可用内存,然后再次单击未分配的空间条目并为 Linux Swap 设置为 1GB。在此之后,您将设置应用到 USB/HDD。然后右键单击 ext4 条目并选择manage flags,然后在那里勾选复选标记boot并离开。

现在,您需要chroot通过一一执行以下命令来准备工作环境:

sudo mkdir /mnt/stick
sudo mount /dev/sdb1 /mnt/stick/
sudo debootstrap --arch=amd64 xenial /mnt/stick http://archive.ubuntu.com/ubuntu/
sudo mount -o bind /dev /mnt/stick/dev
sudo mount -o bind /dev/pts /mnt/stick/dev/pts
sudo mount -t sysfs /sys /mnt/stick/sys
sudo mount -t proc /proc /mnt/stick/proc
sudo cp /proc/mounts /mnt/stick/etc/mtab
sudo cp /etc/resolv.conf /mnt/stick/etc/resolv.conf
sudo chroot /mnt/stick/
Run Code Online (Sandbox Code Playgroud)

您的提示现在应如下所示:

root@HOSTNAME:/#
Run Code Online (Sandbox Code Playgroud)

现在您可以开始真正的安装过程,首先设置locale设置keyboard-configuration并安装内核。

locale-gen en_US.UTF-8
dpkg-reconfigure locale
dpkg-reconfigure keyboard-configuration
localedef -i en_US -c -f UTF-8 en_US.UTF-8

apt-get install linux-image-generic
Run Code Online (Sandbox Code Playgroud)

虽然此安装会GRUB询问您要安装的设备。你会看到这样的选择:

[ ]/dev/sda [NotThisOne, this is your HDD]
[ ]/dev/sdb (31474 MB; ???)
[ ]/dev/sdb1 (30398 MB; /)
Run Code Online (Sandbox Code Playgroud)

通过使用箭头键移动到相应的字段并按下然后最后点击返回来选择/dev/sdb1和。现在安装完成后,您可以安装您选择的编辑器,我在这里作为示例和:/dev/sdbspacenanovim

apt-get install nano vim
Run Code Online (Sandbox Code Playgroud)

现在您可以编辑您的/etc/fstab文件,首先通过以下方式获取系统中的 UUIDS 列表:

blkid
Run Code Online (Sandbox Code Playgroud)

这应该给你一个这样的输出:

/dev/sda1: UUID="8f8f130f-e127-43b6-b797-8bfa3f1e1631" TYPE="ext4" PARTUUID="06bd4abe-01"
/dev/sda5: UUID="8469c58b-b2bb-4551-b47d-c1a7d21e9ebd" TYPE="swap" PARTUUID="06bd4abe-05"
/dev/sdb1: UUID="b08ab271-5619-479c-aa21-8aea7f4e6f3b" TYPE="ext4" PARTUUID="5872a1f8-01"
/dev/sdb2: UUID="c3309cee-731e-4030-93b9-f1d88c12c806" TYPE="swap" PARTUUID="5872a1f8-02"
Run Code Online (Sandbox Code Playgroud)

为了更容易编辑,您可以通过用鼠标选择终端并按ctrl+ shift+来复制终端的输出c,然后通过键入打开您选择的编辑器(例如,我在这里选择 nano):

nano /etc/fstab
Run Code Online (Sandbox Code Playgroud)

您可以在通过按ctrl+ shift+清除文件内容后粘贴这些行c。现在删除标有/dev/sda最有可能是您的硬盘的行并更改其他两行,使它们最终看起来像这样:

UUID=18055918-6045-42e9-9492-66e3fd29c199 swap swap defaults 0 0
UUID=69b5fb9c-774d-4d35-82f2-6a17faa446a1 / ext4 defaults 0 1
Run Code Online (Sandbox Code Playgroud)

然后按ctrl+x结束编辑,选择y保存并点击enter

接下来您需要填写您的/etc/apt/sources.list,您可以通过将以下块复制并粘贴到您的终端并点击enter一次来完成。

cat > /etc/apt/sources.list << "EOF"
deb http://archive.ubuntu.com/ubuntu/ xenial main restricted
deb http://archive.ubuntu.com/ubuntu/ xenial-updates main restricted
deb http://archive.ubuntu.com/ubuntu/ xenial universe
deb http://archive.ubuntu.com/ubuntu/ xenial-updates universe
deb http://archive.ubuntu.com/ubuntu/ xenial multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-updates multiverse
deb http://archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://security.ubuntu.com/ubuntu xenial-security main restricted
deb http://security.ubuntu.com/ubuntu xenial-security universe
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
EOF
Run Code Online (Sandbox Code Playgroud)

至于必须安装需要通过Upstart启动服务的最终配置包,这些必须chroot暂时禁用:

dpkg-divert --local --rename --add /sbin/initctl
ln -s /bin/true /sbin/initctl
Run Code Online (Sandbox Code Playgroud)

现在运行的更新,你可以安装ubuntu-server或者ubuntu-desktop甚至两者只要你的桌面之前做的服务器。

apt-get update
# Comment this out if ubuntu-desktop is not wanted
apt-get install ubuntu-desktop 
# remove comment if ubuntu-server is wanted
# apt-get install ubuntu-server
Run Code Online (Sandbox Code Playgroud)

最后添加您的用户并将他放入适当的组中:

adduser --home /home/<username> <username>

usermod -aG adm,cdrom,sudo,dip,plugdev,lpadmin,sambashare <username>
Run Code Online (Sandbox Code Playgroud)

如果 sambashare 给您带来错误,您可以在何处忽略它。通过以下方式检查组设置是否正确:

less /etc/group
Run Code Online (Sandbox Code Playgroud)

您应该看到上面usermod命令和条目中列出的每个组,如下所示(例如 sudo):

sudo:x:27:<username>
Run Code Online (Sandbox Code Playgroud)

如果没有,则使用上述usermod命令一一添加组。现在是时候安装驱动程序和有用的工具了,我在这里只列出了一些您需要的工具。

apt-get ecryptfs-utils testdisk schroot
Run Code Online (Sandbox Code Playgroud)

要使 GRUB 仅将您的棒识别为操作系统,而不添加您在其上构建棒的系统,请执行以下操作:

echo 'GRUB_DISABLE_OS_PROBER="true"' >> /etc/default/grub
update-grub
Run Code Online (Sandbox Code Playgroud)

通过以下方式完成安装:

rm /sbin/initctl
dpkg-divert --local --rename --remove /sbin/initctl
Run Code Online (Sandbox Code Playgroud)

现在你可以重新启动到你的 USB 并有一个完全安装的 Ubuntu 系统来使用。如果碰上不能够启动这似乎是相关的一个bug终端的麻烦gnome-terminal,你可以在TTY(检查ctrl+ alt+f1和登录与您的用户名和密码)的内容/var/log/syslog是否包含这样几行:

May 7 22:30:00 NEXUS-TWO org.gnome.Terminal[1432]: Non UTF-8 locale (ISO-8859-1) is not supported!
Run Code Online (Sandbox Code Playgroud)

为了解决这个问题,sudo dpkg-reconfigure locales在 TTY 中执行并明确选择 UTF-8似乎就足够了。或在 GUI 设置中设置语言等。之后重启。


sud*_*dus 5

这里有一些细节。(其他人应该写一篇关于利弊的更独立的评论。)

  • 克隆:dd是一个非常强大但也非常危险的工具,通常被称为“磁盘破坏者”或“数据破坏者”。dd 用于将iso 文件克隆到 U 盘。创建仅实时 USB 引导驱动器时,mkusb 会“在 dd 周围系上安全带”。这种方法适用于所有混合 iso 文件,大多数现代 linux 发行版都提供这种 iso 文件。16.04 LTS 中新的Ubuntu Startup Disk Creator 也使用了克隆方法。

  • 许多其他工具将 iso 文件的内容提取到 FAT32 分区,例如RufusUnetbootin。(Rufus 也有克隆dd模式。)

  • mkusb 是一个 linux 工具。它在 Windows 中不起作用。

  • mkusb 是一个 bash 脚本,它使用多种标准工具,可在大多数 linux 发行版中使用。mkusb在图形用户界面可用时使用zenity

  • mkusb-nox (No X) 在文本模式下工作,例如在 Ubuntu Server 中。mkusb-dus(别名 mkusb 版本 12)也可以在文本模式下使用对话框文本模式菜单或纯文本界面工作。

  • 其他一些工具由编译代码组成。

  • mkusb 可以为 Debian 和 Ubuntu创建持久的实时系统。这些系统通过 grub2 启动,iso 文件被克隆到一个单独的分区。将创建一个casper-rw 分区用于持久性,并创建一个usbdata 分区用于存储数据并与运行 Windows 的计算机共享数据。这些持久的实时系统可以在 UEFI 和 BIOS 模式下启动。

  • mkusb-nox 和 mkusb-dus(别名版本 12)可以通过提取为 Windows 7-10创建USB 安装程序。它使用 grub-pc 包来安装 grub2,这使得 USB 闪存盘在 BIOS 模式下启动。该系统可以在 UEFI 和 BIOS 模式下启动。

  • mkusb并没有创建多引导USB驱动器。还有其他工具可用于此目的。

  • mkusb 还可以擦除混乱的数据和/或将 USB 引导驱动器恢复到具有 MSDOS 分区表和 FAT32 文件系统的标准存储设备

如果您想了解更多详情,请参阅以下链接,