如何制作Ubuntu 16.04的持久USB?
我需要持久的实时Ubuntu,优选16.04,因为我需要拯救我的整个16.04的加密硬盘驱动器,如线程中所讨论的如何将自己添加回16.04的加密硬盘中的sudo组? 我在这里创建了一个新的持久性Live Ubuntu 16.04,最后用Videonauth描述了一些bug。
sudo apt-get install gksu debootstrap
-
gksudo gparted
。 使用ext4
制作USB只剩下1GB作为可用内存,并为Linux Swap设置1GB; 管理标志>仅boot
。 -
通过USB记忆棒准备操作系统并运行
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/
-
提示看起来像
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
-
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最稳定,你可以按照正文末尾的描述下载。 -
apt-get install vim wget
-
blkid
,复制到剪贴板,vim /etc/fstab
。 删除sda
行只有两个sdb
行。 将它们编辑为UUID="..." swap swap defaulst 0 0
和UUID="..." / ext4 defaults 0 1
。 -
将以下内容粘贴到文件
/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 ## NB 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 ## NB 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 ## NB 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
-
做
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
-
将
masi
添加到现有组usermod -aG adm,cdrom,sudo,dip,plugdev,lpadmin,sambashare masi
,您可以省略sambashare
。 -
忽略驱动程序,因为USB记忆棒不适用于一台PC。
-
要恢复加密的硬盘驱动器,请安装
apt-get ecryptfs-utils schroot testdisk
,其中testdisk
用于准备光盘,另外两个用于恢复整个光盘加密的Ubuntu 16.04。 -
sudo echo 'GRUB_DISABLE_OS_PROBER="true"' >> /etc/default/grub
;update-grub
-
完成安装。 做
rm /sbin/initctl dpkg-divert --local --rename --remove /sbin/initctl
测试你的持久Live Ubuntu 16.04的安装[alpha]
-
启动新的持久性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 [...]
-
可能的复杂情况:Ubuntu以$(inittramfs)$开头。 做……
结果:USB启动Ubuntu Desktop GUI和UI
- 你可以打开LibreOffice,Firefox,……
-
masi
是sudo组; 团体正确。 - 当
chroot
粘住时,语言环境设置正确。 - 如果您在gnome-terminal中有错误,即在GUI中打开它,请在TTY1中再次执行
sudo dpkg-rekonfigure locales
。 它解决了这个案子。
向Videonauth报告的错误
在进行测试时始终更新和升级系统: sudo apt-get update && sudo apt-get upgrade
。
- Ubuntu的互联网浏览器。 启动它会导致系统崩溃。 鼠标只能工作但没有信号可以发送到TTY。
- Firefox浏览器。 启动它会发出关于[配置文件存在]的警告,因此无法打开。 临时修复
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
因为一些所有权home-folder导致bug。 运行源代码的命令,您会得到以下差异 - 一段时间后,
/etc/hostname
无法匹配/etc/hosts
- 有时,启动到
(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
在哪里我不明白哪个导致了这个bug。
升级到Linux Kernel 4.6
按照这里的指示行事 。 Linux内核4.4中存在恢复/暂停的通用错误。 升级到4.6解决了它并使系统更好。
系统:14.04,16.04
Linux内核:4.4 – 4.6
要在USB或外部硬盘上安装完整的普通Ubuntu,您可以按照我在此处描述的步骤进行操作。
你想从做一些准备安装开始,你需要gksudo
,包括gksu
, schroot
和debootstrap
。 默认情况下不安装这些软件包,因此键入终端( ctrl + alt + t ):
sudo apt-get install gksu debootstrap schroot
现在,您可以通过以下方式开始准备USB / HDD进行安装:
gksudo gparted
首先,您要转到devices
菜单并选择create partition table
,当询问类型时选择msdos
。 现在您应该看到未分配空间的条目。 单击此选项并选择new并将其设为ext4,只留下1GB作为可用内存,然后再次单击未分配的空间条目并将其设置为1GB用于Linux Swap。 在此之后,您将设置应用于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/
您的提示现在应该如下所示:
root@HOSTNAME:/#
现在,您可以开始真正的安装过程,首先设置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
虽然此安装GRUB
询问您要安装哪个设备。 你会看到这样的选择:
[ ]/dev/sda [NotThisOne, this is your HDD] [ ]/dev/sdb (31474 MB; ???) [ ]/dev/sdb1 (30398 MB; /)
选择/dev/sdb1
和/dev/sdb
,方法是使用箭头键移动到相应的字段,然后按空格键,最后点击return。 现在安装完成后你可以安装你选择的编辑器,我这里做的例子是nano
和vim
:
apt-get install nano vim
现在您可以编辑/etc/fstab
文件,首先通过以下方式获取系统中UUIDS的列表:
blkid
这应该给你一个像这样的输出:
/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"
为了便于编辑,您可以通过鼠标选择并按ctrl + shift + c复制终端输出,然后输入打开您选择的编辑器(例如我选择nano):
nano /etc/fstab
按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
然后按ctrl + x结束编辑,选择y
保存并按Enter键
接下来你需要填写你的/etc/apt/sources.list
,你可以复制并将以下块粘贴到你的终端并点击输入一次。
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
至于必须安装的最终配置软件包需要通过Upstart启动服务,这些必须在chroot
暂时禁用:
dpkg-divert --local --rename --add /sbin/initctl ln -s /bin/true /sbin/initctl
现在运行更新,只要您在桌面之前执行服务器,就可以安装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
最后添加你的用户并将他放入适当的组:
adduser --home /home/ usermod -aG adm,cdrom,sudo,dip,plugdev,lpadmin,sambashare
如果它给你错误,你可以省略sambashare。 通过以下方式检查组设置是否正确:
less /etc/group
您应该看到上面的usermod
命令和条目中列出的每个组都是这样的(示例sudo):
sudo:x:27:
如果没有使用上面的usermod
命令逐个添加组。 现在是时候安装驱动程序和有用的工具了,我在这里只列出了一些必要的工具。
apt-get ecryptfs-utils testdisk schroot
为了使GRUB只识别您的操作系统作为操作系统,而不是添加系统,您已经构建了操作系统:
echo 'GRUB_DISABLE_OS_PROBER="true"' >> /etc/default/grub update-grub
通过以下方式完成安装:
rm /sbin/initctl dpkg-divert --local --rename --remove /sbin/initctl
现在您可以重新启动USB并使用完全安装的Ubuntu系统。 如果您遇到无法启动终端的麻烦,这似乎与gnome-terminal
的错误相关,您可以检查TTY( ctrl + alt + f1并使用您的用户名和密码登录) /var/log/syslog
的内容/var/log/syslog
如果它包含这样的行:
May 7 22:30:00 NEXUS-TWO org.gnome.Terminal[1432]: Non UTF-8 locale (ISO-8859-1) is not supported!
要解决此问题,似乎足以在TTY中执行sudo dpkg-reconfigure locales
并明确选择UTF-8。 或在GUI设置中设置语言等。 然后重启。
这是一些细节。 (其他人应该写一篇关于利弊的更独立的评论。)
-
克隆:dd是一个非常强大但也非常危险的工具,通常被称为“磁盘驱逐舰”或“数据驱逐舰”。 dd用于将iso文件克隆到USB pendrive。 在创建仅限实时USB启动驱动器时, mkusb ‘将安全带包裹在dd’周围。 此方法适用于所有混合iso文件,大多数现代Linux发行版都提供此类iso文件。 16.04 LTS中新的Ubuntu Startup Disk Creator也使用了克隆方法。
-
许多其他工具将iso文件的内容提取到FAT32分区,例如Rufus和Unetbootin 。 (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 pendrive在BIOS模式下启动。 该系统可以在UEFI和BIOS模式下启动。
-
mkusb不会创建多重启动USB驱动器。 还有其他工具可用于此目的。
-
mkusb还可以擦除混乱的数据和/或将USB启动驱动器恢复到具有MSDOS分区表和FAT32文件系统的标准存储设备 。
如果您想了解更多详细信息,请参阅以下链接
- mkUSB -快速启动手册
- mkusb-Persistent live系统
哇听起来很复杂, mkusb可以比我上面的任何一个程序都快得多地进行Live Persistent安装。 它们听起来像完全安装而不是永久安装。 持久安装使用casper-rw文件或分区。 它被称为持久安装,因为引导文件中的持久性一词用于激活持久性。
有关mkusb的详细信息,请参阅: https : //help.ubuntu.com/community/mkusb 。
使用mkusb制作的USB驱动器在完全安装到HDD或USB时也没有问题。
- 在Ubuntu 16.04 LTS上安装texlive 2017
- 在MSI GE72MVR上安装Ubuntu 16.04时,系统会在重新启动时冻结
- Ubuntu gnome 16.04 xenial xerus – 更改自动亮度响应时间
- 16.04 LTS至18.04.1 LTS升级:未找到新版本
- 在Apache上安装auth_mellon模块时出现语法错误
- 升级到16.04后媒体密钥未通过
- 没有硬件在Ubuntu 16.04内核4.4.0-78-generic上工作
- 慢Ubuntu 16.04无线信息速度
- 是否有可能使Popper邮件通知在Ubuntu 16.04和18.04(MATE和Unity)上运行?