如何仅使用终端为 BIOS 创建具有持久性的实时 Ubuntu USB 驱动器?

如何仅使用终端为 BIOS 创建具有持久性的实时 Ubuntu USB 驱动器?

我希望能够从实时的 Ubuntu USB 启动,然后永久使用该 USB 上的 rsync 脚本制作增量快照(备份)将我的主要 Debian 系统迁移到第二个硬盘上。

人们会认为制作持久的实时 Ubuntu USB 棒会很容易,但大多数实时 USB 制造商都不允许持久性,而那些允许持久性的制造商也没有成功。这包括 UNetBootin,即使在我本地编译和调试了缺少的依赖项之后也是如此。所以我想要一个简单的、仅限终端的解决方案,我可以理解并在必要时进行调试。

简单的从 iso dd,然后添加 casper-rw 文件的方法存在分区工具被非标准 efi 分区映像混淆的问题。(參考

某些解决方案(例如 UNetBootin)几乎可以正常工作,但是当我尝试执行 sudo -s 来获取 root shell 时,它们会崩溃并转储,并破坏我的实时 USB 映像。

答案1

大部分解决方案(如下)来自很棒的文章,虽然接近可用,但还不够,因为有些地方需要更新。但我建议你看一下,因为它对步骤的解释更完整。

这是针对我的基于 BIOS 的笔记本电脑的。我猜这可能不适用于 EUFI 启动机器。

尖端:

  • 不要按照上述文章所建议的方式制作 grub 配置文件,而是按照我下面所展示的方式。

  • 一旦你最终让它在下面工作,你会发现随着时间的推移,文件系统会意外地变满。我终于明白了,这种情况的发生是因为 Ubuntu 默默地这样做apt-get update,这会填满你所有的文件空间,然后你会收到一条警告消息。(我花了几年时间才弄清楚发生了什么。)

最初的修复方法是apt-get clean转储 apt 缓存,但这并不能真正解决根本问题。然后我尝试简单地禁用 wifi,这样它就无法自动更新。这对我来说很有效!现在我的棒子可以使用很长时间而不会出现问题。


经过仔细测试以确保有效的步骤:

1. 下载Ubuntu 16.04 ISO 映像这里

2. 设置下面要使用的一些变量:

iso=/path/to/isoimage #e.g. iso=~/Downloads/ubuntu-16.04-desktop-amd64.iso

s=/mnt/isoimage   #Source mount point for ISO files (via loop file system)
t=/media/USBRoot  #Target mount point for USB files in partition #1

!! 接下来,在执行下一步时,请务必小心,正确指向 USB 驱动器,而不是硬盘驱动器,因为您可能会意外覆盖硬盘。(提示:查找并确认使用lsblk或类似词)

dev=/dev/sd?  #set the "?" to your USB drive letter, e.g. /dev/sdb

3. 插入并选择性擦除 如果分区失败,建议进行擦除。(之前,当我将 iso 映像添加到 usb 设备时,我必须将其清零,然后才能使 fdisk 再次正常工作。)

sudo dd if=/dev/zero of=$dev  #bs=2048 is optional and doesn't seem to matter

完成后你会收到如下消息:

dd: writing to ‘/dev/sdb’: No space left on device
30326785+0 records in
30326784+0 records out
15527313408 bytes (16 GB) copied, 4099.2 s, 3.8 MB/s

擦除步骤是因为我发现有时快速格式化不起作用。我不确定,但我怀疑分区图的第二份副本或类似的东西被发现并混淆了分区软件。因此,在开始之前将所有零写入 USB 记忆棒似乎可以确保您从头开始。但是,是的,我知道,这需要很长时间才能完成。

4.进行分区。使用分区工具将 msdos 类型的分区图放到 USB 驱动器上,并将其划分为两个分区,如下所示:

分区1)VFAT32 分区用于存放内核、ramdisk、grub 以及通过 casper-rw 文件实现的持久性。为此使用所有剩余空间。

分区2)linux iso 映像的可启动分区。将其大小设为大约 2G(因为 .iso 文件就是这么大)。

分区 #2 的大小需要约为 2g,因此从驱动器的大小中减去这个值,然后除以 512 即可得到分区 #1 的大小(以扇区为单位)。在我的例子中,即 16gb - 2gb = 14gb / 512 = 约 27343750 个扇区。

提示:如果设备已安装,请立即卸载该设备,否则使用 fdisk 后会出错。不要使用图形卸载按钮,因为它似乎会使设备无法找到(直到拔下 USB 驱动器然后重新插入),而是使用终端命令,如下所示:

? 问题:我不确定为什么这些分区不能交换,将启动分区作为第一个分区。但不管怎样,我尝试过,但无法正常工作。

sudo umount ${dev}1
sudo umount ${dev}2

就是这样:您可以使用 fdisk、parted、gparted 或 cfdisk,但我喜欢 fdisk。

sudo fdisk $dev
o                             [create partition map], and then

n (p) (1) (2048) 27343750     [new partition #1] 
t c                           [change partition type to type c, or W95 FAT32], and

n (p) (2) (default) (default) [new partition #2]
t 2 83                        [type 83 or linux], then
a (2)                         [set [toggle] the bootable flag], and

p                             [check new table], and finally 

它看起来应该是这样的:

Disk /dev/sdb: 14.5 GiB, 15527313408 bytes, 30326784 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xa42995f9

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sdb1           2048 27343750 27341703   13G  c W95 FAT32 (LBA)
/dev/sdb2  *    27344896 30326783  2981888  1.4G 83 Linux

然后执行以下操作:

w                         [write the partition table to the usb drive]

你应该会收到如下回复:

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

或者如果你忘记先卸载它,那么你将得到以下信息:

The partition table has been altered.
Calling ioctl() to re-read partition table.
Re-reading the partition table failed.: Device or resource busy

The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).

在这种情况下,您只需返回,按照上述说明卸载它,然后再次运行 fdisk 并点击,就大功告成了。

5.将 iso 映像写入第二个分区。 我纠结于是否要在此处包含块大小参数(例如 bs=2048),最后发现它无关紧要或影响不大。另请注意,此分区不需要格式化,因为 ISO 直接复制到分区时会有效地格式化它。

sudo dd if=$iso of=${dev}2

6.格式第一个分区。 请注意,他使用 VFAT32(即 FAT32 的长文件名版本)对其进行了格式化。我猜这是为了让任何机器上都能轻松读取该分区(即可移植性)。[我计划看看 ext3 是否也能工作,并将在稍后通过该测试更新此内容]。

sudo mkfs.vfat -F 32 -c ${dev}1   # for vFAT32 file system

7. 挂载分区 #1能够将文件安装到其中。

sudo mkdir -p      $t
sudo mount ${dev}1 $t

8. 安装 grub进入 USB 驱动器的第一个扇区以及分区 #1 中的根目录。

sudo grub-install --no-floppy --root-directory=$t $dev

9.复制内核和ram磁盘文件。 (注意,这是从文章中修改的。内核现在以 *.efi 版本提供,(但它仍然只是一个内核),并且 initrd(包含所有软件包的 RAM 磁盘)现在使用 lz 而不是 gz 压缩。)首先,我们安装映像文件(作为循环设备),我们将从中获取这两个文件:

sudo mkdir -p           $s
sudo mount -o loop $iso $s
sudo cp                 $s/casper/{vmlinuz.efi,initrd.lz} $t/boot/

10. 创建一个文件来保存持久文件系统。如果需要,可以调整大小。这里设置为 1024x1mb=1gb。请注意,casper-rw 文件内部是一个 ext3 文件系统。casper-rw 这个名字很神奇,所以不要更改它。

sudo dd if=/dev/zero of=$t/casper-rw bs=1M count=1024  
sudo mkfs.ext3 -F       $t/casper-rw     #takes a long time

11.创建一个简单的grub配置文件。确保给它一个(可能更新?)cfg 而不是 conf 文件扩展名,以便 grub 可以找到它(參考)。使用您喜欢的编辑器,或者使用:

sudo nano $t/boot/grub/grub.cfg

12.粘贴以下 grub 命令。

*注意:如有必要,您可以使用 echo 并阅读此处以了解更多调试信息。此外,“ro”、“splash”和“quiet”是可选的(但建议使用)内核选项,其行为大多不言自明。请参阅关于如何在必要时使用 GRUB> 提示符的非常有用的帖子。我猜他有一个.conf 文件,因为这可能是针对 GRUB 1.0,而不是 GRUB 2.0,这也可能解释了他没有使用的命令。还请注意,根目录是分区 1(即 msdos1)。

echo LOADING USB DRIVE
echo 
echo To continue press any key
echo To abort press ^-alt-delete
echo
read
echo Proceeding...

set default=0
set timeout=10
set title="Ubuntu (Live)"
set root=(hd0,msdos1)

linux /boot/vmlinuz.efi boot=casper file=/preseed/ubuntu.seed persistent ro splash quiet
echo vmlinuz.efi loaded

initrd /boot/initrd.lz
echo initrd.lz loaded
echo
echo Grub done. Booting...
boot

13.同步(推荐)和清理(可选):

sync

sudo umount $s;  sudo rmdir  $s
sudo umount $t;  sudo rmdir  $t

14. 备份您的新 USB 驱动器。

dd if=$dev of=/your/backup/location #需要很长时间

稍后若要恢复它,请使用相反的操作:

dd if=/your/backup/location of=$dev #需要很长时间

15. 重启并按下一个键来启动 Ubuntu USB 驱动器。

16.添加备份脚本将其添加到其中。这是我的增量脚本,用于处理两台笔记本电脑。首先仔细检查您的系统并根据需要进行调整。将其命名为我的备份和硬链接我的恢复将其设置为 ( ln mybackup myrestore)。使用 设置执行权限chmod u+x my{backup,restore}。使用 运行它./mybackup

#!/bin/bash

#Usage:
#
# mybackup                               - show list of current backups
# myrestore                              - ''
#
# mybackup  <machine> <BackupFolderName> - machine: love2d or sharon-pc
# myrestore <machine> <BackupFolderName> - by convention name is 'nn-descriptiveName' (so it sorts by date)


#################################################################
#################################################################

### PARTITIONS ######################
#Partition labels (also used for mount point folder names):
#  Note: use labels rather than UUID as they might be more controllable.
BackupDrive='Linux backup'              # USB backup drive (I removed space from 'name' & it removed it from 'label')
 BackupBase="$BackupDrive/Backups"      # Backup base folder directory & name
     SubDir="files"


### PARTITIONS LABEL HELP:
#lsblk -o +label        gives  (note older method was blkid, but this suggests we use lsblk):
#NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT                              LABEL
#sda      8:0    0 465.8G  0 disk
#├─sda1   8:1    0   199M  0 part                                         SYSTEM
#├─sda2   8:2    0 288.1G  0 part
#├─sda3   8:3    0     1K  0 part
#├─sda4   8:4    0  29.3G  0 part                                         Shared
#├─sda5   8:5    0  23.3G  0 part                                         d8root
#├─sda6   8:6    0 119.5G  0 part                                         d8home
#└─sda7   8:7    0   5.4G  0 part [SWAP]

#sdc      8:32   0   3.7T  0 disk
#├─sdc1   8:33   0   128M  0 part
#├─sdc2   8:34   0   2.7T  0 part /media/ubuntu/Seagate Backup Plus Drive Seagate Backup Plus Drive
#└─sdc3   8:35   0 976.6G  0 part                                         Linux backup



### MOUNTING 1of2 ######################
 sudo umount "/mnt/$BackupDrive">& /dev/null    # --- cleanup from prior failed attempt:
 sudo mkdir  "/mnt/$BackupDrive">& /dev/null; sudo mount -L "$BackupDrive"      "/mnt/$BackupDrive" -o defaults,suid >& /dev/null #Allow to set user owner of files




########################################################################
### FUNCTIONS #################################################################

####################
function usage          { echo; echo "Usage: ${0##*/} [machine name: Love2d|Sharon-pc] [BackupFolderName]";echo;}

####################

####################
#If parameter just show dirs for that machine, else show for both
function myls {
 echo -n "'$1' existing backups:"
 if [ -d "$2" ]; then echo; ls -lFgG "$2" |grep -v ^total |grep ' [0-9][0-9]-' |sed 's/..................//'; else echo ' (none)'; fi;
}

##################
function currentbackups {
 if [ "$1" ]; then
        myls "$1"               "/mnt/$BackupBase/$1/$SubDir"
 else
        myls 'Love2d'           "/mnt/$BackupBase/Love2d/$SubDir"
        echo
        myls 'Sharon-pc'        "/mnt/$BackupBase/Sharon-pc/$SubDir"
        echo
 fi
}

###################
function badmachine     { echo "Machine type '$1' is invalid.";}

###################
function cleanup        {
 # echo "--- cleaning up --------------------------------------"
 sudo umount "/mnt/$BackupDrive"
}

########################################################################
########################################################################


### CHECK INPUTS #######################################################
#Check if backup name paramter exists:
if [ $# = 0 ]; then usage;                                                                                                              cleanup; exit;     fi

if [ $# = 1 ]; then if [ "$1" != "Love2d" -a "$1" != "Sharon-pc" ]; then badmachine "$1"; usage; else usage; currentbackups "$1"; fi;                       cleanup; exit;     fi

if [ $# = 2 ]; then if [ "$1" != "Love2d" -a "$1" != "Sharon-pc" ]; then badmachine "$1"; usage;                                         cleanup; exit; fi; fi


### MOUNTING 2of2 ######################
if [ "$1" = 'Love2d' ]; then
    MyHome='d8home'             # Love2 Debian /home      partition name
    MyRoot='d8root'             # Love2 Debian /   (root) partition name
  MyShared='Shared'             # Love2 Debian Shared     partition name

 sudo umount "/mnt/$MyRoot"     >& /dev/null    # --- cleanup from prior failed attempt:
 sudo umount "/mnt/$MyHome"     >& /dev/null    #
 sudo umount "/mnt/$MyShared"   >& /dev/null    #

 sudo mkdir  "/mnt/$MyRoot"     >& /dev/null; sudo mount -L "$MyRoot"           "/mnt/$MyRoot"                          >& /dev/null
 sudo mkdir  "/mnt/$MyHome"     >& /dev/null; sudo mount -L "$MyHome"           "/mnt/$MyHome"                          >& /dev/null
 sudo mkdir  "/mnt/$MyShared"   >& /dev/null; sudo mount -L "$MyShared"         "/mnt/$MyShared"                        >& /dev/null

else
#    MyHome='uhome'             # Love2 Ubuntu /home      partition name
#    MyRoot='uroot'             # Love2 Ubuntu /   (root) partition name

    MyHome='a41eaa3e-bd31-4ebc-86d4-cf8ed5f3e779'               # Love2 Ubuntu /home      partition name
    MyRoot='f3b7424c-0144-42a6-8488-62fbee94d245'               # Love2 Ubuntu /   (root) partition name


 sudo umount "/mnt/$MyRoot"     >& /dev/null    # --- cleanup from prior failed attempt:
 sudo umount "/mnt/$MyHome"     >& /dev/null    #

#sudo mkdir  "/mnt/$MyRoot"     >& /dev/null; sudo mount -L "$MyRoot"           "/mnt/$MyRoot"                          >& /dev/null
#sudo mkdir  "/mnt/$MyHome"     >& /dev/null; sudo mount -L "$MyHome"           "/mnt/$MyHome"                          >& /dev/null

 sudo mkdir  "/mnt/$MyRoot"     >& /dev/null; sudo mount -U "$MyRoot"           "/mnt/$MyRoot"                          >& /dev/null
 sudo mkdir  "/mnt/$MyHome"     >& /dev/null; sudo mount -U "$MyHome"           "/mnt/$MyHome"                          >& /dev/null
fi


#=================================================================
BackupDir="$BackupBase/$1/$SubDir/$2"   # /dir/BackupFolderName


#rSync stuff:
MyRsync="sudo rsync -aAXv --delete"
RootExclude=" --exclude={\"/dev/*\",\"/lost+found\",\"/media/*\",\"/mnt/*\",\"/proc/*\",\"/run/*\",\"/sys/*\",\"/tmp/*\"}"
HomeExclude=" --exclude='*cache*'"      #this does not work

if [ "${0##*/}" = "mybackup" ]; then
echo backing up...
        sudo mkdir -p "/mnt/$BackupDir/root"    # Making directories to save backup to
        sudo mkdir -p "/mnt/$BackupDir/home"

        echo "--- Backing up:  / -----------------------------------"
        $MyRsync $RootExclude   "/mnt/$MyRoot/"                 "/mnt/$BackupDir/root/"
        echo "--- Backing up:  /home -------------------------------"

        $MyRsync $HomeExclude   "/mnt/$MyHome/"                 "/mnt/$BackupDir/home/"

   if [ "$MyShared" ]; then             #no shared partion on Sharon's machine
        sudo mkdir -p "/mnt/$BackupDir/shared"
        echo "--- Backing up:  Shared ------------------------------"
        $MyRsync                "/mnt/$MyShared/"               "/mnt/$BackupDir/shared/"
   fi

else

        # Confirm
        read -p "YOU ARE ABOUT TO OVERWRITE YOUR PARTITIONS - CONFIRM (y/N)?" -n 1 -r; echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo "Aborting.";exit; fi
        echo;
        read -p "DANGER!  Really overwrite your hard disk partitions? (y/N)?" -n 1 -r; echo if [[ ! $REPLY =~ ^[Yy]$ ]]; then echo "Aborting.";exit; fi

        echo "--- Restoring:   / -----------------------------------"
        $MyRsync                "/mnt/$BackupDir/root/"         "/mnt/$MyRoot"
        echo "--- Restoring:   /home -------------------------------"
        $MyRsync                "/mnt/$BackupDir/home/"         "/mnt/$MyHome"

   if [ "$MyShared" ]; then             #no shared partion on Sharon's machine
        echo "--- Restoring:   Shared ------------------------------"
        $MyRsync                "/mnt/$BackupDir/shared/"       "/mnt/$MyShared"
   fi

fi

cleanup
 sudo umount "/mnt/$MyRoot"     ;sudo rmdir "/mnt/$MyRoot"
 sudo umount "/mnt/$MyHome"     ;sudo rmdir "/mnt/$MyHome"

if [ "$MyShared" ]; then                #no shared partion on Sharon's machine
 sudo umount "/mnt/$MyShared"   ;sudo rmdir "/mnt/$MyShared"
fi

 echo "=== DONE. ============================================"

exit 0

答案2

我认为我们在做同样的事情。让我们交换想法并互相帮助 :-)

也许唯一的区别是我开始得更早。看看我的新工具杜斯,我希望它很快会被重新命名为“mkusb 版本 12”。

杜斯适用于zenity 菜单当有图形桌面环境并且 zenity 可用时,否则使用对话菜单当对话框可用时,否则使用纯文本用户界面,这是您所要求的(并且已经做出,因为没有早期的回复)。

杜斯由一组 bash shell 脚本组成,欢迎您阅读它们并了解它们的工作原理。这些脚本可通过 ppa:mkusb/unstable 或 phillw.net 获取。请参阅此链接此链接更多细节。

以下文本转储是纯文本对话(输入到终端并输出),制作持久实时驱动器时。我使用了一个慢速 USB 2 笔式驱动器,写入速度只有 6 MB/s。使用 USB 2 端口中的优质 USB 3 笔式驱动器,写入速度可以提高 4-5 倍,使用 USB 3 端口时速度会更高。

$ ssh sudodus@my_server
sudodus@my_server's password: 
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-45-generic i686)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

0 paket kan uppdateras.
0 uppdateringar är säkerhetsuppdateringar.

*** /dev/sda8 will be checked for errors at next reboot ***

sudodus@xenial32 ~ $ cd /media/multimed-2/test/mkmkusb/dus
sudodus@xenial32 /media/multimed-2/test/mkmkusb/dus $ dus lubuntu-16.04.1-desktop-amd64.iso 
 dus 0.0.0 
[sudo] password for sudodus: 
dus wants the program(s) 
mkusb-common 'to make a persistent live drive and to get a good GUI experience'
usb-pack-efi 'only to make a persistent live drive'
 Please install the corresponding package(s) 
Press Enter to continue, or wait 8 seconds 

 dus 0.0.0 - Cloning, live linux, windows / Persistent live
 ──────────────────────────────────────────────────────────────────────────────


             ┌──────Move between items with the arrow keys────────┐
             │                 - Do USB Stuff -                   │
             │       Welcome and Notice about Overwriting         │
             │ The target device will be completely overwritten   │
             │ ┌────────────────────────────────────────────────┐ │
             │ │c  Cloning iso file, [compressed] image file or │ │
             │ │l  'Live-only' or linux installer from iso file │ │
             │ │p  'Persistent live' - only Debian and Ubuntu   │ │
             │ │w  extracting Windows installer                 │ │
             │ │q  Quit                                         │ │
             │ └────────────────────────────────────────────────┘ │
             │                                                    │
             │                                                    │
             │                                                    │
             │                                                    │
             ├────────────────────────────────────────────────────┤
             │             <  OK  >       <Avbryt>                │
             └────────────────────────────────────────────────────┘

## oops - I have dialog installed - so I had better use the option -t ##
##        to make a demo with the plain text interface                ##

clean if necessary and return
sudodus@xenial32 /media/multimed-2/test/mkmkusb/dus $ dus -t lubuntu-16.04.1-desktop-amd64.iso 
 dus 0.0.0 
dus wants the program(s) 
mkusb-common 'to make a persistent live drive and to get a good GUI experience'
usb-pack-efi 'only to make a persistent live drive'
 Please install the corresponding package(s) 
Press Enter to continue, or wait 8 seconds 
+------------------------  Do USB Stuff  -------------------------+
|              Welcome and Notice about Overwriting               |
|        The target device will be completely overwritten         |
+------------------------  quit with (q)  ------------------------+
Cloning,live-only,windows / Persistent-live / Quit (c/l/p/w/q) p
Drive that contains source file: /dev/sdc
Live drive, that is booted from: /dev/sda
-------------------------------------------------------------------------------
Available drives (mass storage devices)
Dev  Target name/model              Size   Bus  Kind of device    
sdd  SanDisk_Cruzer                  15G   usb  USB or memory card
Example: add 'sdx':  /dev/sdx
Select target device /dev/sdd
p_target: target=/dev/sdd
Select 'MSDOS' partition table - default GPT?               (y/N) 
Select 'usb-pack-efi' - default grub from iso file?         (y/N) 
Select 'download and install' security update - default NO? (y/N) 
Enter 'percentage' for persistence - default 50  (enter: 1 - 100) 75
settings=
percent=75
Prepare  persistent live  system from
'lubuntu-16.04.1-desktop-amd64.iso'
to the target device (drive) '/dev/sdd'
MODEL            NAME   FSTYPE  LABEL                      SIZE
Cruzer           sdd                                        15G
                 ├─sdd1 ntfs    usbdata                    3,5G
                 ├─sdd2                                      1M
                 ├─sdd3 vfat    lub1604164                 122M
                 ├─sdd4 iso9660 Lubuntu 16.04.1 LTS amd64  874M
                 └─sdd5 ext4    casper-rw                 10,5G
 Final checkpoint, go ahead? (g/N) g
lubuntu-16.04.1-desktop-amd64.iso
/dev/sdd
75
settings=
-----
live system or temporary superuser permissions
lubuntu-16.04.1-desktop-amd64.iso
/dev/sdd
75
settings=
source=lubuntu-16.04.1-desktop-amd64.iso
target=/dev/sdd
percent=75
msdos=false
upefi=false
dni=false
source=lubuntu-16.04.1-desktop-amd64.iso
ls -l  lubuntu-16.04.1-desktop-amd64.iso
lrwxrwxrwx 1 olle olle 67 okt 22 21:44 lubuntu-16.04.1-desktop-amd64.iso -> /media/multimed-2/CD/ubuntu/16.04/lubuntu-16.04.1-desktop-amd64.iso
---------------------------------------------------------------------------
start [dus-persistent 0.0.0] @ 2016-11-17 19:15:23
---------------------------------------------------------------------------
Making a USB boot drive or memory card ..........................
ubuntu
grub_n_iso "$source" "$target" "$result"
grub_n_iso lubuntu-16.04.1-desktop-amd64.iso /dev/sdd 
***** tu=/dev/sdd ****************************************************
selected target partition table: 'gpt'
mount: /dev/loop0 is write-protected, mounting read-only
 Lubuntu 16.04.1 LTS "Xenial Xerus" - Release amd64 
mount: /dev/loop0 is write-protected, mounting read-only
select_boot_system: usb-pack_efi is available
select_boot_system: usb-pack_efi: using variable 'upefi=false'
'lubuntu-16.04.1-desktop-amd64.iso' is identified as the source ISO file
<pre>
MODEL            NAME   FSTYPE  LABEL                     MOUNTPOINT  SIZE
Cruzer           sdd                                                   15G
                 |-sdd1 ntfs    usbdata                               3,5G
                 |-sdd2                                                 1M
                 |-sdd3 vfat    lub1604164                            122M
                 |-sdd4 iso9660 Lubuntu 16.04.1 LTS amd64             874M
                 `-sdd5 ext4    casper-rw                            10,5G
</pre>
Using the file '/usr/share/mkusb/grub.cfg'
Clean for a GUID partition table
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.

Command (? for help): This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): 
Command (? for help): 
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): OK; writing new GUID partition table (GPT) to /dev/sdd.
The operation has completed successfully.
Wipe the first megabyte (mibibyte) to get a clean boot area
1024+0 records in
1024+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,00227566 s, 461 MB/s
Wait 5 seconds and a little more ...
---------------------------------------------------------------------------
 Selected percentage of remaining space for persistence = 75 
---------------------------------------------------------------------------

preparing /dev/sdd3  ------------------------------------------------
1024+0 records in
1024+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,290228 s, 3,6 MB/s
umount: /dev/sdd3: not mounted
mkfs.fat 3.0.28 (2015-05-16)
/dev/sdd3 has 64 heads and 32 sectors per track,
hidden sectors 0x1000;
logical sector size is 512,
using 0xf8 media descriptor, with 249856 sectors;
drive number 0x80;
filesystem has 2 32-bit FATs and 1 sector per cluster.
FAT size is 1922 sectors, and provides 245980 clusters.
There are 32 reserved sectors.
Volume ID is 3cfbdfa9, no volume label.

preparing /dev/sdd1  ------------------------------------------------
1024+0 records in
1024+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 0,317438 s, 3,3 MB/s
umount: /dev/sdd1: not mounted
Cluster size has been automatically set to 4096 bytes.
Creating NTFS volume structures.
Creating root directory (mft record 5)
Creating $MFT (mft record 0)
Creating $MFTMirr (mft record 1)
Creating $LogFile (mft record 2)
Creating $AttrDef (mft record 4)
Creating $Bitmap (mft record 6)
Creating $Boot (mft record 7)
Creating backup boot sector.
Creating $Volume (mft record 3)
Creating $BadClus (mft record 8)
Creating $Secure (mft record 9)
Creating $UpCase (mft record 0xa)
Creating $Extend (mft record 11)
Creating system file (mft record 0xc)
Creating system file (mft record 0xd)
Creating system file (mft record 0xe)
Creating system file (mft record 0xf)
Creating $Quota (mft record 24)
Creating $ObjId (mft record 25)
Creating $Reparse (mft record 26)
Syncing root directory index record.
Syncing $Bitmap.
Syncing $MFT.
Updating $MFTMirr.
Syncing device.
mkntfs completed successfully. Have a nice day.
preparing /dev/sdd5  ------------------------------------------------
1024+0 records in
1024+0 records out
1048576 bytes (1,0 MB, 1,0 MiB) copied, 1,7128 s, 612 kB/s
umount: /dev/sdd5: not mounted
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 2743296 4k blocks and 686784 inodes
Filesystem UUID: 3c0ee31f-b5f2-4b21-8ac8-bb8941c39697
Superblock backups stored on blocks: 
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

mount: /media/multimed-2/CD/ubuntu/16.04/lubuntu-16.04.1-desktop-amd64.iso is already mounted
fatlabel: warning - lowercase labels might not work properly with DOS or Windows
tune2fs 1.42.13 (17-May-2015)
---------------------------------------------------------------------------
source=lubuntu-16.04.1-desktop-amd64.iso
---------------------------------------------------------------------------
item 60
umount: /dev/sdd3: not mounted
mount /dev/sdd3 /tmp/dus.KMlnQuCB3J
/dev/sdd3       121M   512  121M   1% /tmp/dus.KMlnQuCB3J
item 65
umount: /dev/sdd1: not mounted
/dev/sdd1       3,5G   19M  3,5G   1% /tmp/dus.FkiHYIJh2I
 BIOS Bootloader:  Installing for i386-pc platform.
Installation finished. No error reported.
 64-bit bootloader: copy the boot files from the iso file 
looper=/tmp/dus.zAxhAauNxN
targ1=/tmp/dus.KMlnQuCB3J
rsync: symlink "/tmp/dus.KMlnQuCB3J/ubuntu" -> "." failed: Operation not permitted (1)
rsync: symlink "/tmp/dus.KMlnQuCB3J/dists/stable" -> "xenial" failed: Operation not permitted (1)
rsync: symlink "/tmp/dus.KMlnQuCB3J/dists/unstable" -> "xenial" failed: Operation not permitted (1)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1183) [sender=3.1.1]
rsync:  don't worry,  symlink errors are *expected*
because of the target file system.
Using the file '/tmp/dus.KMlnQuCB3J/boot/grub/grub.cfg'
 set security upgrade action to 'Display immediately' 
umount: /dev/sdd4: not mounted
 Please wait while copying and syncing until 'Done' is written ... 
< "lubuntu-16.04.1-desktop-amd64.iso" pv | dd of=/dev/sdd4 bs=4096
 855MiB 0:02:15 [6,33MiB/s] [================================>] 100%            
218880+0 records in
218880+0 records out
896532480 bytes (897 MB, 855 MiB) copied, 148,466 s, 6,0 MB/s
Syncing the target device ...
Wait 5 seconds and a little more ...
<pre>
parted -s "/dev/sdd" print
Model: SanDisk Cruzer (scsi)
Disk /dev/sdd: 16,0GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 2      1049kB  2097kB  1049kB               primary  bios_grub
 3      2097kB  130MB   128MB   fat32        primary  boot, esp
 4      130MB   1046MB  916MB                primary
 5      1046MB  12,3GB  11,2GB  ext2         primary
 1      12,3GB  16,0GB  3746MB  ntfs         primary  msftdata

lsblk -o MODEL,NAME,FSTYPE,LABEL,MOUNTPOINT,SIZE "/dev/sdd"
MODEL            NAME   FSTYPE  LABEL                     MOUNTPOINT  SIZE
Cruzer           sdd                                                   15G
                 |-sdd1 ntfs    usbdata                               3,5G
                 |-sdd2                                                 1M
                 |-sdd3 vfat    lub1604164                            122M
                 |-sdd4 iso9660 Lubuntu 16.04.1 LTS amd64             874M
                 `-sdd5 ext4    casper-rw                            10,5G
</pre>
 Done :-) 
The target device is ready to use.
'lubuntu-16.04.1-desktop-amd64.iso'
was installed
Cleanup after dus-persistent finished :-)
Cleanup after dus-persistent finished :-)
---------------------------------------------------------------------------
Total time used [by dus-persistent] = 276 s; 00:04:36


Check the result (scroll if possible), press Enter to finish 
p_clean:
live system or temporary superuser permissions
Cloning,live-only,windows / Persistent-live / Quit (c/l/p/w/q) q
clean if necessary and return
sudodus@xenial32 /media/multimed-2/test/mkmkusb/dus $ 

相关内容