Sailfish OS 4.x: How to revert the default user account from defaultuser to nemo
This example uses a VMWare installation of Alpine Linux to modify the flashable SailfishOS image.
I used Alpine because it’s the go-to distro for small virtual systems (docker images use it extensively), and as such rather quick to set up.
If you already have a Linux system, you can skip most of part 1, but will have to make sure the tools are installed from your distro packages.
Part One: set up the Linux environment:
1. Install Alpine Linux in VMWare
- Create new VM, ~1G RAM, 2 CPUs, minmimum 3GB Disk, NAT networking
- Boot from install ISO
- run setup-alpine
- follow the wizard
- when asked about the disk type, choose
sys
- finish wizard
- reboot
2. add community repo in /etc/apk/repositories
http://dl.alpinelinux.org/alpine/v3.15/main
http://dl.alpinelinux.org/alpine/v3.15/community
#http://dl.alpinelinux.org/alpine/v3.15/testing
3. install VMWare tools
apk update
apk add open-vm-tools
apk add open-vm-tools-guestinfo
apk add open-vm-tools-deploypkg
apk add open-vm-tools-hgfs
4. mount shared folders
/etc/fstab:
vmhgfs-fuse /mnt/vm fuse defaults,allow_other 0 0
5. extract sailfishos.img001 to VMWare shared folder
6. mount shared folder
modprobe fuse
mount /mnt/vm
7. add android and image tools
apk update
apk add util-linux
apk add util-linux-misc
apk add multipath-tools
apk add lvm2
apk add android-tools
Part Two: convert and mount the image
1. convert image
simg2img /mnt/vm/sfos/sailfishos.img001 /var/tmp/sailfishos.img
losetup -f /var/tmp/sailfishos.img
2. mount SFOS LVM partitions
lvscan
kpartx -a -v /dev/loop0
mkdir -p /mnt/sailfishos/root
mkdir -p /mnt/sailfishos/home
mount /dev/sailfishos/root /mnt/sailfishos/root
Part Three: manipulate the image contents
1. Find defaultuser references on image
grep -a -r defaultuser /mnt/sailfishos/root/ 2>/dev/null
# just to make sure it isn't actually in the image
grep defaultuser /mnt/sailfishos/root/etc/passwd
grep defaultuser /mnt/sailfishos/root/etc/group
grep 100000 /mnt/sailfishos/root/etc/passwd
grep 100000 /mnt/sailfishos/root/etc/group
List of files:
-
MOUNT_ROOT/usr/lib/startup/start-autologin
← that’s the main one
MOUNT_ROOT/etc/connman/connman-vpn.conf
-
/var/lib/rpm/Packages
← ignore this, harmless
-
/usr/lib/libsepol.so.1
← ignore this, harmless
2. change files
Use your favourite editor to change the references to your preferred user account.
Part Four: convert image back to flashable sparse image:
umount /mnt/sailfishos/root
losetup -d /var/tmp/sailfishos.img
img2simg /var/tmp/sailfishos.img /var/tmp/my_sailfishos.img
Part Five: flashing
- Enter your “flashing” folder (extracted Release zip with Sony Binaries .img added)
- Copy the new image over the original sailfishos.img001
- execute
md5sum sailfishos.img001
- open md5.lst in a text editor
- replace the MD5 sum part in md5.lst
- save md5.lst
- execute the flashing script as usual