如何获取这些事件的日期/时间:
- 最后一个系统休眠/挂起
- 上次系统恢复
我有一台支持 UEFI 的 HP Pavilion G7 笔记本电脑和一个 250GB GPT SSD 磁盘。笔记本电脑最初安装了 Windows 8,但后来我进行了 Windows 10 全新安装并为 linux 保留了一些空白空间。
现在我想拥有 Win10 和 Ubuntu16 Mate 16.04 LTS 双引导、LUKS 加密磁盘和 LVM。
这种带有 LUKS 和 LVM 的双引导配置在 Ubuntu Mate GUI 安装程序中是不可能的,但我发现遵循以下说明(针对 Ubuntu 13.04 测试):
我尝试按照这些说明进行操作,但总是在启动时无法打开加密磁盘,因为cryptsetup
失败。
这是我的程序,编号与说明中的相同:
使用包含在活动磁盘中的 GParted 创建分区。分手。创建 2 个分区:LUKS 的引导和数据。Windows esp 也将用于 Ubuntu。
(parted) print list
Model: ATA Samsung SSD 850 (scsi)
Disk /dev/sda: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 473MB 472MB ntfs Basic data partition hidden, diag
2 473MB 578MB 105MB fat32 EFI system partition boot, esp
3 578MB 595MB 16.8MB Microsoft reserved partition msftres
4 595MB 123GB 123GB ntfs Basic data partition msftdata
5 123GB 124GB 835MB ntfs hidden, diag
6 124GB 125GB 524MB ext4 NotUsed
7 125GB 126GB 1049MB ext4 linux-boot
8 126GB 250GB 124GB linux-data
ubuntu-mate@ubuntu-mate:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 232.9G 0 disk
├─sda1 8:1 0 450M 0 part
├─sda2 8:2 0 100M 0 part (This is Windows esp)
├─sda3 8:3 0 16M 0 part
├─sda4 8:4 0 114.4G 0 part
├─sda5 8:5 0 796M 0 part
├─sda6 8:6 0 500M 0 part
├─sda7 8:7 0 1000M 0 part (boot)
└─sda8 8:8 0 115.7G 0 part (LUKS)
格式化分区 sda7, sda8
使用这些命令创建一个 LUKS 容器
sudo cryptsetup luksFormat /dev/sda8
sudo cryptsetup luksOpen /dev/sda8 pv_data
正确初始化新的 LUKS 容器至关重要
ubuntu-mate@ubuntu-mate:~$ sudo dd if=/dev/zero of=/dev/mapper/pv_data bs=16M
dd: error writing '/dev/mapper/pv_data': No space left on device
7469+0 records in
7468+0 records out
125303783424 bytes (125 GB, 117 GiB) copied, 381.69 s, 328 MB/s
在挂载的 LUKS 容器中,创建一个 LVM 物理卷、一个卷组和两个逻辑卷。第一个逻辑卷将安装在 /,第二个将用作交换。
ubuntu-mate@ubuntu-mate:~$ sudo pvcreate /dev/mapper/pv_data
Physical volume "/dev/mapper/pv_data" successfully created
ubuntu-mate@ubuntu-mate:~$ sudo vgcreate vg_data /dev/mapper/pv_data
Volume group "vg_data" successfully created
ubuntu-mate@ubuntu-mate:~$ sudo lvcreate -n lv_swap -L 12g vg_data
Logical volume "lv_swap" created.
ubuntu-mate@ubuntu-mate:~$ sudo lvcreate -n lv_root -L 80g vg_data
Logical volume "lv_root" created.
ubuntu-mate@ubuntu-mate:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 232.9G 0 disk
...
└─sda8 8:8 0 115.7G 0 part
└─pv_data 252:0 0 115.7G 0 crypt
├─vg_data-lv_swap 252:1 0 12G 0 lvm
└─vg_data-lv_root 252:2 0 80G 0 lvm
为两个逻辑卷创建文件系统
ubuntu-mate@ubuntu-mate:~$ sudo mkfs.ext4 /dev/mapper/vg_data-lv_root
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 20971520 4k blocks and 5242880 inodes
Filesystem UUID: 1cbd1ea6-fa20-41f6-a870-5c159301bee4
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
ubuntu-mate@ubuntu-mate:~$ sudo mkswap /dev/mapper/vg_data-lv_swap
Setting up swapspace version 1, size = 12 GiB (12884897792 bytes)
no label, UUID=d665e5d7-b81f-4078-a5d5-bb1dd137fce2
使用图形安装程序安装 Ubuntu,选择手动分区。
分配:/
到/dev/mapper/vg_data-lv_root
,/boot
到/dev/sda7
,交换到/dev/mapper/vg_data-lv_swap
将其他分区标记为“不使用”,除了 sda7 boot、lv_root、lv_swap、sda2 efi windows boot manager
选择用于引导加载程序安装的设备/dev/sda
图形安装程序完成后,选择“继续测试”并打开终端。
查找 LUKS 分区的 UUID:/dev/sda8
ubuntu-mate@ubuntu-mate:~$ sudo blkid
/dev/sda1: LABEL="Recovery" UUID="FABE4708BE46BCBF" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="69ee7fd0-ed56-41b2-b974-b76647cb98d5"
/dev/sda2: UUID="9A47-7CB4" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="3cfbb43a-3bfd-48ac-b673-109f469c4d72"
/dev/sda4: UUID="82324D05324D0021" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="342a1cfb-8587-4dbc-a180-4872aa23aff5"
/dev/sda5: UUID="D606B52306B50611" TYPE="ntfs" PARTUUID="6bebe835-96b9-422e-b9c1-baf69ae085b3"
/dev/sda6: UUID="341a01d8-dcb7-4c51-99aa-22a84d53054b" TYPE="ext4" PARTLABEL="NotUsed" PARTUUID="f2524ea7-8736-4998-8705-5e9d22c42b3c"
/dev/sda7: UUID="d0033e81-c785-4efc-a0d3-1128b7a99792" TYPE="ext4" PARTLABEL="linux-boot" PARTUUID="08e453f9-84ca-48b0-a26f-915f2462c578"
/dev/sdb1: LABEL="UBUNTU-MATE" UUID="8EDE-65EA" TYPE="vfat" PARTLABEL="Microsoft Basic Data" PARTUUID="2c0f92b3-5d67-45c7-bc1b-ce8a1a284015"
/dev/loop0: TYPE="squashfs"
/dev/sda8: UUID="ec4c6b1d-0bf1-41d4-81ec-754987a5532f" TYPE="crypto_LUKS" PARTLABEL="linux-data" PARTUUID="18bf1837-1dda-477a-9007-e3478e12f565"
/dev/sdc1: LABEL="FAT32GB" UUID="FE56-878C" TYPE="vfat" PARTUUID="58ee1847-01"
/dev/mapper/pv_data: UUID="11kz5r-WtT9-c2oU-sDrB-ObWm-OCiP-t0JG9c" TYPE="LVM2_member"
/dev/mapper/vg_data-lv_swap: UUID="d665e5d7-b81f-4078-a5d5-bb1dd137fce2" TYPE="swap"
/dev/mapper/vg_data-lv_root: UUID="57c480e3-59c7-4203-ac5c-2a08075fd71c" TYPE="ext4"
/dev/dm-1: UUID="d665e5d7-b81f-4078-a5d5-bb1dd137fce2" TYPE="swap"
/dev/sda3: PARTLABEL="Microsoft reserved partition" PARTUUID="dfbb8924-81a1-4646-9baa-3a4977641f5e"
将适当的设备挂载到 /mnt 中的适当位置,然后 chroot 进入其中:
sudo mount /dev/mapper/vg_data-lv_root /mnt
sudo mount /dev/sda7 /mnt/boot
sudo mount --bind /dev /mnt/dev
sudo chroot /mnt
在 chrooted 环境中创建一个名为 /etc/crypttab 的文件:
root@ubuntu-mate:/# cat /etc/crypttab
# <target name> <source device> <key file> <options>
pv_data UUID=ec4c6b1d-0bf1-41d4-81ec-754987a5532f none luks,retry=1,lvm=vg_data
在 chrooted 环境中创建一个名为 /etc/initramfs-tools/conf.d/cryptroot 的文件:
root@ubuntu-mate:/# cat /etc/initramfs-tools/conf.d/cryptroot
CRYPTROOT=target=pv_data,source=/dev/disk/by-uuid/ec4c6b1d-0bf1-41d4-81ec-754987a5532f
在 chrooted 环境中运行以下命令:
root@ubuntu-mate:/# update-initramfs -k all -c
update-initramfs: Generating /boot/initrd.img-4.4.0-38-generic
cat: /proc/cmdline: No such file or directory
update-initramfs: Generating /boot/initrd.img-4.4.0-31-generic
cat: /proc/cmdline: No such file or directory
这些错误是否严重?
在 chrooted 环境中编辑名为 /etc/default/grub 的文件:
root@ubuntu-mate:/# cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
#GRUB_CMDLINE_LINUX=""
GRUB_CMDLINE_LINUX="cryptopts=target=pv_data,source=/dev/disk/by-uuid/ec4c6b1d-0bf1-41d4-81ec-754987a5532f,lvm=vg_data"
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
root@ubuntu-mate:/#
在 chrooted 环境中运行以下命令:
root@ubuntu-mate:/# update-grub
Generating grub configuration file ...
...
/proc/devices: fopen failed: No such file or directory
Found linux image: /boot/vmlinuz-4.4.0-38-generic
Found initrd image: /boot/initrd.img-4.4.0-38-generic
/proc/devices: fopen failed: No such file or directory
device node not found
/proc/devices: fopen failed: No such file or directory
device node not found
Found linux image: /boot/vmlinuz-4.4.0-31-generic
Found initrd image: /boot/initrd.img-4.4.0-31-generic
/proc/devices: fopen failed: No such file or directory
/proc/devices: fopen failed: No such file or directory
/proc/devices: fopen failed: No such file or directory
device node not found
...
device node not found
/proc/devices: fopen failed: No such file or directory
device node not found
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
grep: /proc/mounts: No such file or directory
Cannot find list of partitions! (Try mounting /sys.)
done
root@ubuntu-mate:/#
这里去掉了几十个device node not found
错误,update-grub产生这么多错误是正常的吗?
重新启动并启动到加密的 Ubuntu。应该提示您输入密码。
在重新启动期间,Windows 10 默认开始启动。如果我Esc从列表中点击并选择 Ubuntu,Ubuntu 开始启动但cryptsetup
失败并显示以下错误消息:
cryptsetup: cryptsetup failed, bad password or options?
/scripts/local-top/cryptroot: line:1 /sbin/cryptsetup: not found.
此故障的原因是什么,我该如何解决?
/etc/modules
文件为空。应该有什么吗?