Dans Ubuntu configuré avec LVM, j'ai essayé de vérifier ce qui se passerait si seul le disque amorçable était remplacé par un autre LV.
root@yayoi:/home/moly# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name ubuntu-vg
PV Size <9.00 GiB / not usable 0
Allocatable yes
PE Size 4.00 MiB
Total PE 2303
Free PE 1023
Allocated PE 1280
PV UUID mcw43c-b4ae-beqi-ISBZ-ZqPk-N46i-aGe5C6
root@yayoi:/home/moly# df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 472920 0 472920 0% /dev
tmpfs 100896 944 99952 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 4062912 2079568 1757248 55% /
tmpfs 504464 0 504464 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 504464 0 504464 0% /sys/fs/cgroup
/dev/loop0 89984 89984 0 100% /snap/core/5662
/dev/loop1 68352 68352 0 100% /snap/lxd/9239
/dev/sda2 999320 150336 780172 17% /boot
tmpfs 100892 0 100892 0% /run/user/1000
root@yayoi:/home/moly# file -s /dev/mapper/ubuntu--vg-ubuntu--lv
/dev/mapper/ubuntu--vg-ubuntu--lv: symbolic link to ../dm-0
/dev/mapper/ubuntu--vg-ubuntu--lv: symbolic link to ../dm-0
root@yayoi:/home/moly# file -s /dev/dm-0 #recherche dans le système de fichiers
/dev/dm-0: Linux rev 1.0 ext4 filesystem data, UUID=b50c9846-9c89-44c2-b57a-1c0a00c3afa5 (needs journal recovery) (extents) (64bit) (large files) (huge files)
root@yayoi:/home/moly# lvcreate -L 1G -n Bootable ubuntu-vg
filesystem
root@yayoi:/home/moly# mkfs.ext4 /dev/ubuntu-vg/Bootable
mke2fs 1.44.4 (18-Aug-2018)
Creating filesystem with 262144 4k blocks and 65536 inodes
Filesystem UUID: ef5bf14a-43fa-4dd3-9441-48e0ea4a0fbf
Superblock backups stored on blocks:
32768, 98304, 163840, 229376
Allocating group tables: done
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
root@yayoi:/home/moly# mktemp -d
/tmp/tmp.GauV3uu0St
root@yayoi:/home/moly# mount -t ext4 /dev/ubuntu-vg/Bootable /tmp/tmp.GauV3uu0St
root@yayoi:/tmp/tmp.GauV3uu0St# lvdisplay
--- Logical volume ---
LV Path /dev/ubuntu-vg/ubuntu-lv
LV Name ubuntu-lv
VG Name ubuntu-vg
LV UUID oeCuCc-vFAD-p1Pa-PfDK-sk4L-w6cn-ERFBNr
LV Write Access read/write
LV Creation host, time ubuntu-server, 2019-04-04 15:17:09 +0000
LV Status available
# open 1
LV Size 4.00 GiB
Current LE 1024
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/ubuntu-vg/Bootable
LV Name Bootable
VG Name ubuntu-vg
LV UUID ZPT9Lo-yY7O-WXvW-vVEa-O5xB-xIo5-9rR1qT
LV Write Access read/write
LV Creation host, time yayoi, 2019-04-04 15:24:19 +0000
LV Status available
# open 1
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
root@yayoi:/tmp/tmp.GauV3uu0St#
Ajout de ce qui suit.
root@yayoi:/etc/grub.d# cat 99_bootable_lvm
#!/bin/sh
set -e
echo "shitty bootable lvm" >&2
cat << EOF
menuentry "bootable lvm" {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
insmod lvm
set root='lvmid/Vgp9Fy-SOA4-Ff5x-sAs4-Bhfg-ppwG-gOf76f/ZPT9Lo-yY7O-WXvW-vVEa-O5xB-xIo5-9rR1qT'
search --no-floppy --fs-uuid --set=root --hint='lvmid/Vgp9Fy-SOA4-Ff5x-sAs4-Bhfg-ppwG-gOf76f/ZPT9Lo-yY7O-WXvW-vVEa-O5xB-xIo5-9rR1qT' 3ef3a667-f4ed-4399-8f31-11c29ef994eb
linux /vmlinuz-4.18.0-17-generic root=/dev/mapper/ubuntu--vg-ubuntu--lv ro maybe-ubiquity
initrd /initrd.img-4.18.0-17-generic
}
EOF
Bootable
du LV qui a été ajouté précédemment./ dev / mapper / ubuntu - vg-ubuntu - lv
=> / dev / dm-0
update-grub2
root@yayoi:/etc/grub.d# sudo update-grub2
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.18.0-17-generic
Found initrd image: /boot/initrd.img-4.18.0-17-generic
Found linux image: /boot/vmlinuz-4.18.0-10-generic
Found initrd image: /boot/initrd.img-4.18.0-10-generic
shitty bootable lvm
done
root@yayoi:/home/moly# cd /tmp/tmp.GauV3uu0St/
root@yayoi:/tmp/tmp.GauV3uu0St# cp -r /boot/* ./
Si vous sélectionnez dans l'entrée de menu de grub, il démarrera normalement.
Modifier fstab et redémarrer
root@yayoi:/tmp/tmp.GauV3uu0St# cat /etc/fstab
UUID=b50c9846-9c89-44c2-b57a-1c0a00c3afa5 / ext4 defaults 0 0
#UUID=3ef3a667-f4ed-4399-8f31-11c29ef994eb /boot ext4 defaults 0 0
Je ne sais pas qui a créé grubenv, mais pour le moment, j'ai démarré parce que je ne pouvais pas voir / boot. ** Meilleur **
root@yayoi:/home/moly# df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 472920 0 472920 0% /dev
tmpfs 100896 932 99964 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 4062912 2105112 1731704 55% /
tmpfs 504464 0 504464 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 504464 0 504464 0% /sys/fs/cgroup
/dev/loop0 89984 89984 0 100% /snap/core/5662
/dev/loop1 68352 68352 0 100% /snap/lxd/9239
tmpfs 100892 0 100892 0% /run/user/1000
root@yayoi:/home/moly# tree /boot
/boot
└── grub
└── grubenv
1 directory, 1 file
root@yayoi:/home/moly# cat /boot/grub/grubenv
# GRUB Environment Block
#######################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################################root@yayoi:/home/moly#
Changer fstab et redémarrer
root@yayoi:/home/moly# blkid
/dev/sda2: UUID="3ef3a667-f4ed-4399-8f31-11c29ef994eb" TYPE="ext4" PARTUUID="c0289df7-8720-4474-ae2d-66ed85f9b9a3"
/dev/sda3: UUID="mcw43c-b4ae-beqi-ISBZ-ZqPk-N46i-aGe5C6" TYPE="LVM2_member" PARTUUID="9a3e5412-0c8e-4623-a7ef-9143918a416e"
/dev/mapper/ubuntu--vg-ubuntu--lv: UUID="b50c9846-9c89-44c2-b57a-1c0a00c3afa5" TYPE="ext4"
/dev/loop0: TYPE="squashfs"
/dev/loop1: TYPE="squashfs"
/dev/mapper/ubuntu--vg-Bootable: UUID="ef5bf14a-43fa-4dd3-9441-48e0ea4a0fbf" TYPE="ext4"
/dev/sda1: PARTUUID="184382b2-05c6-4aa2-9ed6-d350573bfe9f"
root@yayoi:/home/moly# cat /etc/fstab
UUID=b50c9846-9c89-44c2-b57a-1c0a00c3afa5 / ext4 defaults 0 0
#UUID=3ef3a667-f4ed-4399-8f31-11c29ef994eb /boot ext4 defaults 0 0
UUID=ef5bf14a-43fa-4dd3-9441-48e0ea4a0fbf /boot ext4 defaults 0 0
/ boot
est monté avec / dev / mapper / ubuntu - vg-Bootable
root@yayoi:/home/moly# df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 472920 0 472920 0% /dev
tmpfs 100896 940 99956 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 4062912 2155104 1681712 57% /
tmpfs 504464 0 504464 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 504464 0 504464 0% /sys/fs/cgroup
/dev/loop0 89984 89984 0 100% /snap/core/5662
/dev/loop1 68352 68352 0 100% /snap/lxd/9239
/dev/mapper/ubuntu--vg-Bootable 999320 150328 780180 17% /boot
tmpfs 100892 0 100892 0% /run/user/1000
Recommended Posts