[LINUX] Erstellen Sie eine bootfähige LV

Hintergrund

In Ubuntu, das mit LVM eingerichtet wurde, habe ich versucht zu überprüfen, was passieren würde, wenn nur die bootfähige Festplatte in eine andere LV geändert würde.

Aktuelle Partition

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 #Dateisystem suchen
/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)

Machen Sie lv


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

montieren


root@yayoi:/home/moly# mktemp -d
/tmp/tmp.GauV3uu0St
root@yayoi:/home/moly# mount -t ext4 /dev/ubuntu-vg/Bootable /tmp/tmp.GauV3uu0St

gv, lv Bestätigung

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#

Grub-Menüeintrag hinzugefügt

Folgendes hinzugefügt.


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

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

Boot kopieren

root@yayoi:/home/moly# cd /tmp/tmp.GauV3uu0St/
root@yayoi:/tmp/tmp.GauV3uu0St# cp -r /boot/* ./

versuchen Sie zu booten

Wenn Sie aus dem Menüeintrag von grub auswählen, wird es normal gestartet.

Versuchen Sie, das Mounten / Booten von fstab zu stoppen! w

Fstab bearbeiten und neu starten


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

Ergebnis

Ich weiß nicht, wer Grubenv gemacht hat, aber vorerst habe ich angefangen, weil ich nicht sehen / booten konnte. ** Beste **


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#

Hängen Sie das neu erstellte bootfähige LV an / boot ein

Ändern Sie fstab und starten Sie neu


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

Ergebnis

/ boot wird mit / dev / mapper / ubuntu - vg-Bootable gemountet

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

Erstellen Sie eine bootfähige LV
Erstellen Sie einen Django-Zeitplan
Erstellen Sie ein Python-Modul
Erstellen Sie eine Python-Umgebung
Erstellen Sie einen Slack Bot
Erstellen Sie ein Wox-Plugin (Python)
Erstellen Sie eine Funktion in Python
Erstellen Sie ein Wörterbuch in Python
Erstellen Sie einen (einfachen) REST-Server
Erstellen Sie eine Homepage mit Django
Erstellen Sie ein Python-Numpy-Array
Erstellen Sie eine Dummy-Datendatei
Erstellen Sie einen Django-Anmeldebildschirm
Erstellen Sie ein Klassenzimmer auf Jupyterhub
Erstellen Sie einen einfachen Textlint-Server
Erstellen Sie ein Verzeichnis mit Python
Erstellen Sie einen rudimentären ELF-Packer
Erstellen Sie mit Flask einen CSV-Reader
Erstellen Sie mit tkinter eine Python-GUI
Erstellen Sie einen DI-Container mit Python
Schritte zum Erstellen eines Django-Projekts
Erstellen Sie einen Pandas-Datenrahmen aus einer Zeichenfolge.
Erstellen Sie eine Python-Umgebung auf dem Mac (2017/4)
Erstellen Sie ein verschachteltes Wörterbuch mit defaultdict
So erstellen Sie ein Conda-Paket
Erstellen Sie eine virtuelle Umgebung mit Python!
Erstellen Sie eine Binärdatei in Python
So erstellen Sie eine virtuelle Brücke
Erstellen Sie einen SlackBot-Dienst für Pepper
Erstellen Sie eine Linux-Umgebung unter Windows 10
Wie erstelle ich eine Docker-Datei?
Erstellen Sie einen Unix Domain Socket-Server
Erstellen Sie eine 1-MByte-Zufallszahlendatei
Erstellen Sie ein universelles Dekorationsframework für Python
5 Möglichkeiten zum Erstellen eines Python-Chatbots
Erstellen Sie die CRUD-API mit der Fast API
Erstellen Sie einen Poisson-Stepper mit numpy.random
Erstellen Sie eine zufällige Zeichenfolge in Python
So erstellen Sie eine Konfigurationsdatei
Erstellen Sie mit Boost.Python einen C-Sprach-Wrapper
Erstellen Sie mit Django einen Datei-Uploader
Erstellen Sie mit Django einen LINE-Bot
Ich habe versucht, einen Linebot zu erstellen (Implementierung)
So erstellen Sie einen Klon aus Github
Erstellen Sie mit Class einen Python-Funktionsdekorator
Erstellen Sie einen Bot, um Corona-Virus-Informationen zu retweeten
Erstellen Sie ein neues numerisches Python-Berechnungsprojekt
So erstellen Sie einen Git-Klonordner
Ich habe versucht, einen Linebot zu erstellen (Vorbereitung)
Erstellen Sie mit Python + PIL ein Dummy-Image.
Erstellen Sie ein Modell für Ihren Django-Zeitplan
Erstellen Sie eine Python-Umgebung auf Ihrem Mac
Erstellen Sie eine einfache GUI-App in Python
Erstellen wir eine virtuelle Umgebung für Python
[Python] Erstellen Sie mit Anaconda eine virtuelle Umgebung
Erstellen wir mit Python eine kostenlose Gruppe