Skip to content

Check if the SD card is writable before starting the install

Martijn Braam requested to merge feature/locked-sd-check into master

This makes pmbootstrap error on locked sd cards before installing. Saving me a bunch of time because the sd card adapters sometimes (a lot of the times) have a lock switch that moves when inserting the card into the computer.

This changes this:

$ pmbootstrap install --no-fde --sdcard /dev/sdc
[15:10:51] *** (1/5) PREPARE NATIVE CHROOT ***
[15:10:52] *** (2/5) CREATE DEVICE ROOTFS ("raspberry-pi3") ***
[15:10:56] (rootfs_raspberry-pi3) install
[15:10:58] (rootfs_raspberry-pi3) install
[15:11:00] (rootfs_raspberry-pi3) write /etc/os-release
[15:11:01] (rootfs_raspberry-pi3) install
[15:11:03] (rootfs_raspberry-pi3) mkinitfs rpi
[15:11:07]  *** SET LOGIN PASSWORD FOR: 'martijn' ***
New password: 
Retype new password: 
passwd: password updated successfully
[15:11:12] NOTE: No valid keymap specified for device
[15:11:14] *** (3/5) PREPARE INSTALL BLOCKDEVICE ***
[15:11:14] (native) mount /dev/install (host: /dev/sdc)
[15:11:14] WARNING: This device has a previous installation of pmOS. CONTINUE? (y/n) [n]: y
[15:11:17] (native) partition /dev/install (boot: 52M, root: the rest)
[15:11:18] (native) format /dev/installp2
[15:11:18] NOTE: The failed command's output is above the ^^^ line in the log file: /home/martijn/.local/var/pmbootstrap/log.txt
[15:11:18] ERROR: Command failed: (native) % mkfs.ext4 -O ^metadata_csum -F -q -L pmOS_root -N 100000 /dev/installp2
[15:11:18] See also: <https://postmarketos.org/troubleshooting>
Run 'pmbootstrap log' for details.

into this:

$ pmbootstrap install --no-fde --sdcard /dev/sdc
[15:09:03] ERROR: /dev/sdc is read-only, Is the sdcard locked?
[15:09:03] See also: <https://postmarketos.org/troubleshooting>
Run 'pmbootstrap log' for details.

Merge request reports