0

I have next partitions:

/dev/sda1 → /boot

/dev/sda2 → LUKS → LVM
    /dev/vg1/root → /
    /dev/vg1/home → /home
    /dev/vg1/opt → /opt
    /dev/vg1/var → /var
    /dev/vg1/tmp → /tmp
    /dev/vg1/swap → swap

/dev/sdb1 - SSD disk, currently not in use

I get an SSD drive. Already copy everything from "/" (using LVM snapshot) to SSD "/dev/sdb1" using

cp -ax …

command.

So, how do I make "/dev/sdb1" to be root directory during OS bootup with possibility to fall back to old root if needed?

1 Answer 1

0

For situation described in question I used script. You need copy data to SSD and change /etc/fstab there.

#!/bin/bash
# Stop script on single error
set -e
# Script must be run from root user
if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root"
   exit 1
fi
# Temporary mount point for guest root
MountDir="/media/root"
# Create mount point if not exist
if [ ! -d "$MountDir" ]; then
    mkdir -p "$MountDir"
fi
# Set ownership
chown root:root "$MountDir"
# Mount guest root (change for your system)
mount /dev/sdb1 "$MountDir"
# Mount other paritions (change for your system)
mount /dev/sda1 "${MountDir}/boot"
mount /dev/mapper/vg1-var "${MountDir}/var"
mount /dev/mapper/vg1-opt "${MountDir}/opt"
mount /dev/mapper/vg1-tmp "${MountDir}/tmp"
mount /dev/mapper/vg1-home "${MountDir}/home"
# Mount some system in-memory directories for correct operation of guest system
mount -B /proc "${MountDir}/proc"
mount -B /dev "${MountDir}/dev"
mount -B /sys "${MountDir}/sys"
# Enter to guest root and run commands to update OS boot configuration
chroot "$MountDir" /bin/bash -c "update-initramfs -u; update-grub"
# Unmount partitions (change for your system)
umount "${MountDir}/boot"
umount "${MountDir}/var"
umount "${MountDir}/opt"
umount "${MountDir}/tmp"
umount "${MountDir}/home"
# Unmount in-memory directories
umount "${MountDir}/proc"
umount "${MountDir}/dev"
umount "${MountDir}/sys"
# Unmount guest root
umount "$MountDir"

Thats basically written from other answers:

https://askubuntu.com/a/118928/27255 - copying

https://askubuntu.com/a/3409/27255 - but udpate-grub is not enough, You need to run update-initramfs -u first…

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .