Proposta di modifica dell' imagine fuss-server cloudinit
by Von Guggenberg, Michael
Salve,
Progongo la migrazione del disco formatato con singola partizione in
ext4 agganciata alla vm fuss-server 10 cloudinit ad uno formatato con
LVM e vari punti di mount per /boot /root /var,la home dell' utente
clonezilla e una partizione dedicata per swap. Vorrei anche aggiungere
contrib e non-free a sources.list
sda è il disco nuov a 140G
sdb2 la partizione / ext4
#!/bin/bash
wipefs -af /dev/sda
parted -s /dev/sda mklabel gpt
parted -s /dev/sda unit s mkpart primary 34 2047
parted -s /dev/sda set 1 bios_grub on
parted -s -- /dev/sda unit s mkpart primary 2048 90%
parted -s /dev/sda set 2 lvm on
pvcreate /dev/sda"2"
vgcreate system /dev/sda"2"
lvcreate -L512M -nboot system
lvcreate -L8192M -nswap system
lvcreate -L20G -nroot system
lvcreate -L70G -nvar system
lvcreate -L15G -nclonezilla system
lvcreate -L1G -nhome system
mkfs.ext4 -m0 -Lboot -U4dcd9414-57e8-4da3-a2f5-67c7834f4f90 /dev/system/boot
mkswap -Lswap -U b3fcce22-2ec9-438e-9795-d89152a32c1c /dev/system/swap
mkfs.ext4 -m0 -Lroot -Ub466bc88-54ba-4aac-a832-e313d8d578b9 /dev/system/root
mkfs.ext4 -m0 -Lvar -Ufb882564-ee8f-43b3-91ea-4f3d0831e9fc /dev/system/var
mkfs.ext4 -m0 -Lclonezilla -Uefe83f50-165c-4377-adf5-5783637f540b
/dev/system/clonezilla
mkfs.ext4 -m9 -Lhome -U014b239b-8027-416a-9d5a-55e1ec140977 /dev/system/home
mount /dev/system/root /mnt
mkdir /mnt/boot
mkdir /mnt/var
mkdir /mnt/home
mount /dev/system/boot /mnt/boot
mount /dev/system/var /mnt/var
mkdir -p /mnt/srv/clonezilla
mount /dev/system/clonezilla /mnt/srv/clonezilla
mount /dev/system/home /mnt/home
mkdir /tmp/old
mount /dev/sdb2 /tmp/old
rsync -aAXHv
--exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"}
/tmp/old/ /mnt/
mount --bind /dev /mnt/dev
mount --bind /dev/pts /mnt/dev/pts
mount --bind /proc /mnt/proc
mount --bind /sys /mnt/sys
mount --bind /run /mnt/run
sed -i
's/UUID=92a90245-3178-4b16-876d-4521b4107f13/\/dev\/system\/swap/g'
/mnt/etc/initramfs-tools/conf.d/resume
sed -i 's/main/main\ contrib\ non-free/g' /mnt/etc/apt/sources.list
sed -i 's/archive\.fuss\.bz\.it\/\ buster\ main\ contrib\
non-free/archive\.fuss\.bz\.it\/\ buster\ main\ contrib/g'
/mnt/etc/apt/sources.list
sed -i 's/archive\.fuss\.bz\.it\/\ buster-proposed-updates\ main\
contrib\ non-free/archive\.fuss\.bz\.it\/\ buster-proposed-updates\
main\ contrib/g' /mnt/etc/apt/sources.list
echo "GRUB_DISABLE_OS_PROBER=true" >> /mnt/etc/default/grub
tee /mnt/etc/fstab << EOF
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point> <type>
<options> <dump> <pass>
UUID=4dcd9414-57e8-4da3-a2f5-67c7834f4f90 /boot ext4
defaults 0 2
UUID=b466bc88-54ba-4aac-a832-e313d8d578b9 / ext4
errors=remount-ro 0 1
UUID=fb882564-ee8f-43b3-91ea-4f3d0831e9fc /var ext4
defaults 0 2
UUID=efe83f50-165c-4377-adf5-5783637f540b /srv/clonezilla ext4
defaults 0 2
UUID=014b239b-8027-416a-9d5a-55e1ec140977 /home ext4
defaults,noauto,x-systemd.automount 0 2
UUID=b3fcce22-2ec9-438e-9795-d89152a32c1c none swap
sw 0 0
EOF
chroot /mnt apt update
chroot /mnt apt -y install lvm2
chroot /mnt grub-install /dev/sda
chroot /mnt update-grub
chroot /mnt update-initramfs -u -k all
chroot /mnt sed -i '/GRUB_DISABLE_OS_PROBER=true/d' /etc/default/grub
chroot /mnt apt clean
chroot /mnt fstrim -av
umount -iR /mnt
Saluti,
Michael