在 GPT LVM 上安装
这是以下内容的更新版本:Setting up LVM on GPT-labeled disks。
本文档描述了如何设置从逻辑卷启动的 Alpine Linux 系统,使用 lvm2 和 GPT 标记的磁盘。
首先以通常方式从 Alpine Linux 安装介质启动。以 `root` 身份登录,运行 `setup-alpine`,并在要求选择磁盘时回答 `none`。
信息
此安装中使用的 Alpine Linux ISO:alpine-vanilla-3.7.0-x86_64.iso
此 PC 具有 BIOS,而非 UEFI(UEFI 安装可能有所不同)
在 APU4C 上使用 30GB Kingston mSata SSD (SMS200S3/30G) 测试。
分区
我们需要安装一些工具。即 'gptfdisk' 和 'sgdisk'。
安装 gptfdisk。
apk add -U gptfdisk sgdisk
创建分区。在我的例子中,SSD 磁盘被发现为 sda,因此我将在整个过程中使用 'sda'。
gdisk /dev/sda
# create a new empty GUID partition table (GPT) with 'o' o # then 'y' to confirm # create partitions: BIOS (needed only for GRUB2), Boot (needed by SYSLINUX), and LVM n 1 <enter> +2M ef02 n 2 <enter> +100M 8300 n 3 <enter> <enter> 8e00 # print the partition with 'p'
您应该得到类似这样的结果
Number Start (sector) End (sector) Size Code Name 1 2048 6143 2.0 MiB EF02 BIOS boot partition 2 6144 210943 100.0 MiB 8300 Linux filesystem 3 210944 15662270 7.4 GiB 8E00 Linux LVM
我们需要在我们的启动分区上设置“legacy BIOS bootable”标志。这可以在 gdisk 中完成,首先使用 'x' 进入专家模式,然后使用 'a' 编辑属性。SYSLINUX 的 GPT 支持使用它来识别保存第二阶段引导代码的分区。
x a 2 2
它看起来像这样
Command (? for help): x
Expert command (? for help): a Partition number (1-3): 2 Known attributes are: 0: system partition 1: hide from EFI 2: legacy BIOS bootable 60: read-only 62: hidden 63: do not automount
Attribute value is 0000000000000000. Set fields are: No fields set
Toggle which attribute field (0-63, 64 or <Enter> to exit): 2 Have enabled the 'legacy BIOS bootable' attribute. Attribute value is 0000000000000004. Set fields are: 2 (legacy BIOS bootable)
按“Enter”退出专家模式,然后将表写入磁盘。使用 'w' 退出 gdisk。
您可以使用 sgdisk(也是 gptfdisk 的一部分)验证 legacy_boot 标志。
sgdisk /dev/sda --attributes=1:show
sgdisk /dev/sda --attributes=2:show
2:2:1 (legacy BIOS bootable)
sgdisk /dev/sda --attributes=3:show
删除 gptfdisk(如果不再需要)。
apk del gptfdisk sgdisk
LVM 设置
现在我们可以在上面过程中创建的第三个分区上设置 LVM。
apk add lvm2 e2fsprogs syslinux
pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
vgcreate vg00 /dev/sda3
Volume group "vg00" successfully created
lvcreate -n alpine_rootfs -L4G vg00
Logical volume "alpine_rootfs" created
lvcreate -n swap -C y -L 512M vg00
Logical volume "swap" created
rc-update add lvm
* service lvm added to runlevel default
vgchange -ay
2 logical volume(s) in volume group "vg00" now active
格式化新的逻辑卷并激活交换空间。
mkfs.ext3 /dev/sda2
mkfs.ext4 /dev/vg00/alpine_rootfs
mkswap /dev/vg0/swap
挂载以完成 Alpine Linux 安装。
mount -t ext4 /dev/vg00/alpine_rootfs /mnt
mkdir /mnt/boot
mount -t ext3 /dev/sda2 /mnt/boot
完成安装
运行此命令以完成将 Alpine Linux 安装到我们新挂载的分区
setup-disk -m sys /mnt
setup-disk 的输出应如下所示
Installing system on /dev/vg00/alpine_rootfs: /mnt/boot is device /dev/sda2 /boot is device /dev/sda2 You might need fix the MBR to be able to boot
Syslinux
安装 MBR。
dd bs=440 conv=notrunc count=1 if=/usr/share/syslinux/gptmbr.bin of=/dev/sda
重启并享受您的新 Alpine Linux 安装!