1

We have a Ubuntu image with LTSP that is used to boot about 60 classroom PCs (Ubuntu fat clients).

The most difficult part we face is to maintain the bootable image (keeping latest security changes) and for professors to test the images while they are outside the university premises.

I was wondering if a teacher could setup a tailor made disk image using Virtualbox that could be deployed using our LTSP server.

0
1

Your question is very interesting.

I'm running about 120 LTSP fat clients in two buildings using Ubuntu 16.04.6 LTS server.
All fat clients use recommended MATE DE.

So my server has all necessary LTSP components.

I have just tested that it is possible to convert /opt/ltsp/images/amd64.img SquashFS image to VirtualBox harddrive.
Below is the procedure I have used to convert it to VM.

1. Mount LTSP SquashFS image and copy its contents to new empty raw harddisk

1.1. Operations on host system

Create mount point

mkdir ~/ltsp_sfs

and mount squashfs LTSP image file:

sudo mount -o loop /opt/ltsp/images/amd64.img ~/ltsp_sfs

Create empty raw hard disk and copy squashfs to it.

Allocate 20 Gb of space:

fallocate -l 20G ~/ltsp.raw

Create partitions on raw disk with any software. Below is fdisk method:

(
echo n # new partition
echo p # it is primary
echo   # and first
echo   # starts at default
echo   # ends at end
echo w # write changes
) | fdisk ~/ltsp.raw

Create loop-devices for ~/ltsp.raw file using kpartx:

sudo kpartx -a -v ~/ltsp.raw

and format its first partition (check exact device name with losetup) with label:

sudo mkfs.ext4 /dev/mapper/loop1p1 -L LTSP

then mount it

mkdir ~/ltsp_ext4
sudo mount /dev/mapper/loop1p1 ~/ltsp_ext4

Copy squashfs contents to new ext4 partition

sudo cp -a ~/ltsp_sfs/* ~/ltsp_ext4/

and set correct partition label in /etc/fstab:

echo "LABEL=LTSP  /  ext4  noatime  0  1" | sudo tee ~/ltsp_ext4/etc/fstab

1.2. Operations in chroot

Chroot to copied filesystem:

sudo mount --types proc /proc ~/ltsp_ext4/proc
sudo mount --bind /sys ~/ltsp_ext4/sys
sudo mount --bind /dev ~/ltsp_ext4/dev

sudo chroot ~/ltsp_ext4/

Install GRUB bootloader into virtual drive:

sudo grub-install /dev/loop1
grub-mkconfig -o /boot/grub/grub.cfg

Create new ltsp user as member of sudo group with password:

useradd -m -G users,audio,sudo -s /bin/bash ltsp
passwd ltsp

Exit from chroot

exit

unmount its partition and detach loopback devices:

sudo umount ~/ltsp_ext4/proc
sudo umount ~/ltsp_ext4/sys
sudo umount ~/ltsp_ext4/dev

sudo umount ~/ltsp_ext4/
sudo kpartx -d -v ltsp.raw

2. Boot resulting virtual harddrive in virtual machine

2.1. Using QEMU-KVM

Launch LTSP image using QEMU-KVM:

kvm -m 1024 -drive file=~/ltsp.raw,format=raw

and login to system as ltsp user.

Do not touch system services, to keep image compatible with LTSP init-scripts.

2.2. Using VirtualBox VM

Create new VMDK harddisk as linked to our raw harddisk:

VBoxManage internalcommands createrawvmdk -filename ~/ltsp.vmdk -rawdisk ~/ltsp.raw

then attach it to VirtualBox VM and boot it.

3. Use contents of changed drive to create new LTSP image

Then you can try to modify the contents of new virtual hardrive and copy them back to /opt/ltsp/amd64 of the server. Then try to call sudo update-ltsp-images amd64 to get it converted back to squashfs file-system.

I'm sorry I do not have resources to check this. I hope you got the idea.

1
  • Thanks, We'll give it a try. – dodecaplex Apr 14 '19 at 13:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.