Gentoo

How to chroot in Sabayon Linux

how to chroot in sabayon linux - How to chroot in Sabayon Linux

Example 1: Sabayon Linux was installed in conventional partitions

Let’s say, for example, that the installation has three partitions: /dev/sda1 (EFI System Partition formatted with FAT32); /dev/sda2 (root partition formatted with ext4); /dev/sda3 (linuxswap). Modify the mount command below accordingly if the root directory is on a different partition. In this example, /boot is on the same partition as root (/) and therefore does not need to be mounted separately.

Boot a Sabayon Linux LiveDVD or LivePenDrive, open a terminal window and enter the following commands:

sabayonuser@sabayon ~ $ su
sabayon sabayonuser # fdisk -l # Ascertain the partitioning scheme.
sabayon sabayonuser # mkdir /mnt/mychroot
sabayon sabayonuser # mount /dev/sda2 /mnt/mychroot
sabayon sabayonuser # mount --rbind /dev /mnt/mychroot/dev
sabayon sabayonuser # mount --make-rslave /mnt/mychroot/dev
sabayon sabayonuser # mount -t proc /proc /mnt/mychroot/proc
sabayon sabayonuser # mount --rbind /sys /mnt/mychroot/sys
sabayon sabayonuser # mount --make-rslave /mnt/mychroot/sys
sabayon sabayonuser # mount --rbind /tmp /mnt/mychroot/tmp
sabayon sabayonuser # chroot /mnt/mychroot /bin/bash
sabayon / # source /etc/profile
sabayon / # env-update
>>> Regenerating /etc/ld.so.cache...
sabayon / # export PS1="(chroot) $PS1"
(chroot) sabayon / # 

Now you can enter whatever commands you want in the chrooted environment. When you have finished, exit the chroot as follows:

(chroot) sabayon / # exit
exit
sabayon sabayonuser # umount -R /mnt/mychroot/tmp /mnt/mychroot/sys /mnt/mychroot/proc /mnt/mychroot/dev /mnt/mychroot
sabayon sabayonuser # shutdown -h now

Example 2: Sabayon Linux was installed in a logical volume

Let’s say, for example, that the installation has three partitions: /dev/sda1 (EFI System Partition formatted with FAT32); /dev/sda2 (/boot partition formatted with ext4); /dev/sda3 as the LVM Physical Volume with Volume Group sabayon_sabayon containing Logical Volumes root (formatted as ext4) and swap (linuxswap). Modify the mount commands accordingly if the structure is different in your case. In this example, /boot is not on the same partition as root (/) and therefore needs to be mounted separately.

Boot a Sabayon Linux LiveDVD or LivePenDrive, open a terminal window and enter the following commands:

sabayonuser@sabayon ~ $ su
sabayon sabayonuser # fdisk -l # Ascertain the partitioning scheme.
sabayon sabayonuser # pvdisplay --- Physical volume --- PV Name /dev/sda3 VG Name sabayon_sabayon PV Size 39.31 GiB / not usable 2.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 10064 Free PE 1 Allocated PE 10063 PV UUID 489QRE-rvgD-JUXz-ZYad-1DM7-XNwr-lDFVNw sabayon sabayonuser # vgdisplay --- Volume group --- VG Name sabayon_sabayon System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size 39.31 GiB PE Size 4.00 MiB Total PE 10064 Alloc PE / Size 10063 / 39.31 GiB Free PE / Size 1 / 4.00 MiB VG UUID oZ2s2c-fm35-VBCT-ef3i-n8OJ-79a2-IOJ5iW sabayon sabayonuser # lvdisplay --- Logical volume --- LV Path /dev/sabayon_sabayon/swap LV Name swap VG Name sabayon_sabayon LV UUID dNoMjX-yv7i-3UVR-vG2s-jsJG-PHfX-BvCYs9 LV Write Access read/write LV Creation host, time sabayon, 2018-01-05 22:55:16 +0000 LV Status available # open 0 LV Size 2.00 GiB Current LE 512 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 251:0 --- Logical volume --- LV Path /dev/sabayon_sabayon/root LV Name root VG Name sabayon_sabayon LV UUID Lf81Ni-LfMu-Pifu-UUzl-ypKK-xSUc-pPfawz LV Write Access read/write LV Creation host, time sabayon, 2018-01-05 22:55:17 +0000 LV Status available # open 0 LV Size 37.31 GiB Current LE 9551 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 251:1 sabayon sabayonuser # pvscan
File descriptor 16 (socket:[30370]) leaked on pvscan invocation. Parent PID 2635: bash PV /dev/sda3 VG sabayon_sabayon lvm2 [39.31 GiB / 4.00 MiB free] Total: 1 [39.31 GiB] / in use: 1 [39.31 GiB] / in no VG: 0 [0 ]
sabayon sabayonuser # vgscan
File descriptor 16 (socket:[30370]) leaked on vgscan invocation. Parent PID 2635: bash Reading volume groups from cache. Found volume group "sabayon_sabayon" using metadata type lvm2
sabayon sabayonuser # vgchange -ay
File descriptor 16 (socket:[30370]) leaked on vgchange invocation. Parent PID 2635: bash 2 logical volume(s) in volume group "sabayon_sabayon" now active
sabayon sabayonuser # lvscan
File descriptor 16 (socket:[30370]) leaked on lvscan invocation. Parent PID 2635: bash ACTIVE '/dev/sabayon_sabayon/swap' [2.00 GiB] inherit ACTIVE '/dev/sabayon_sabayon/root' [37.31 GiB] inherit
sabayon sabayonuser # mkdir /mnt/mychroot
sabayon sabayonuser # mount /dev/sabayon_sabayon/root /mnt/mychroot
sabayon sabayonuser # mount /dev/sda2 /mnt/mychroot/boot
sabayon sabayonuser # mount --rbind /dev /mnt/mychroot/dev
sabayon sabayonuser # mount --make-rslave /mnt/mychroot/dev
sabayon sabayonuser # mount -t proc /proc /mnt/mychroot/proc
sabayon sabayonuser # mount --rbind /sys /mnt/mychroot/sys
sabayon sabayonuser # mount --make-rslave /mnt/mychroot/sys
sabayon sabayonuser # mount --rbind /tmp /mnt/mychroot/tmp
sabayon sabayonuser # chroot /mnt/mychroot /bin/bash
sabayon / # source /etc/profile
sabayon / # env-update
>>> Regenerating /etc/ld.so.cache...
sabayon / # export PS1="(chroot) $PS1"
(chroot) sabayon / # 

Now you can enter whatever commands you want in the chrooted environment. For example:

(chroot) sabayon / # equo version
319

When you have finished, exit the chroot as follows:

(chroot) sabayon / # exit
exit
sabayon sabayonuser # umount -R /mnt/mychroot/tmp /mnt/mychroot/sys /mnt/mychroot/proc /mnt/mychroot/dev /mnt/mychroot/boot /mnt/mychroot
sabayon sabayonuser # equo version
310
sabayon sabayonuser # shutdown -h now

In the example above I have used the ‘equo version‘ command in the chroot environment and in the LiveDVD environment, simply to illustrate that the two environments are not the same. As you can see, the LiveDVD I used has the package equo-310 installed, whereas the installation on the HDD has equo-319 installed.

By the way, if using the Sabayon Linux KDE LiveDVD/LivePenDrive, I discovered that the LVM command ‘vgchange -ay‘ can be omitted if I launch the KDE Partition Manager:

sabayon sabayonuser # partitionmanager

I just look at the partitions in the KDE Partition Manager’s GUI and quit the application (‘File’ > ‘Quit’).

Advertisements

<!–
–>

Sending
User Review
0 (0 votes)