]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/commitdiff
installer: add partitions as installation source
authorArne Fitzenreiter <arne_f@ipfire.org>
Sun, 16 Jan 2022 13:46:36 +0000 (13:46 +0000)
committerArne Fitzenreiter <arne_f@ipfire.org>
Sun, 16 Jan 2022 13:46:36 +0000 (13:46 +0000)
This add compatiblity for rufus usb-keys that convert the
iso to fat or ntfs partition.

Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
src/installer/dracut-module/module-setup.sh
src/installer/hw.c
src/installer/main.c

index 5550ec7630b687f1bcd34890106c41dd8c7d77fb..c68b51d260c6d2d8c07e7b795b8f69f940f9c666 100755 (executable)
@@ -31,7 +31,7 @@ install() {
 
     # Filesystem support
     inst_multiple parted mkswap mke2fs mkreiserfs mkfs.xfs mkfs.vfat
-    instmods ext4 iso9660 reiserfs vfat xfs
+    instmods ext4 iso9660 reiserfs vfat xfs ntfs3
 
     # Extraction
     inst_multiple tar gzip zstd
index b532bb16e25a10157f623234664d83f211d7ac65..17e0bbb01ef35fddff59cc787a1c1881331b72fb 100644 (file)
@@ -202,6 +202,15 @@ int hw_umount(const char* source, const char* prefix) {
 static int hw_test_source_medium(const char* path) {
        int ret = hw_mount(path, SOURCE_MOUNT_PATH, "iso9660", MS_RDONLY);
 
+       if (ret != 0) {
+               // 2nd try, ntfs for a rufus converted usb key
+               ret = hw_mount(path, SOURCE_MOUNT_PATH, "ntfs3", MS_RDONLY);
+       }
+       if (ret != 0) {
+               // 3rd try, vfat for a rufus converted usb key
+               ret = hw_mount(path, SOURCE_MOUNT_PATH, "vfat", MS_RDONLY);
+       }
+
        // If the source could not be mounted we
        // cannot proceed.
        if (ret != 0)
@@ -275,6 +284,20 @@ struct hw_disk** hw_find_disks(struct hw* hw, const char* sourcedrive) {
        struct hw_disk** ret = hw_create_disks();
        struct hw_disk** disks = ret;
 
+       // Determine the disk device of source if it is a partition
+       char* sourcedisk = NULL;
+       char syssource[PATH_MAX];
+       (void)snprintf(syssource, sizeof(syssource) - 1, "/sys/class/block/%s", sourcedrive + 5);
+       struct udev_device* s_dev = udev_device_new_from_syspath(hw->udev, syssource);
+       const char* s_devtype = udev_device_get_property_value(s_dev, "DEVTYPE");
+       if (s_devtype && (strcmp(s_devtype, "partition") == 0)) {
+               struct udev_device* p_dev = udev_device_get_parent_with_subsystem_devtype(s_dev,"block","disk");
+               if (p_dev) {
+                       sourcedisk = udev_device_get_devnode(p_dev);
+               }
+       }
+       if (!sourcedisk) sourcedisk = sourcedrive;
+
        struct udev_enumerate* enumerate = udev_enumerate_new(hw->udev);
 
        udev_enumerate_add_match_subsystem(enumerate, "block");
@@ -298,8 +321,8 @@ struct hw_disk** hw_find_disks(struct hw* hw, const char* sourcedrive) {
                        continue;
                }
 
-               // Skip sourcedrive if we need to
-               if (sourcedrive && (strcmp(dev_path, sourcedrive) == 0)) {
+               // Skip sourcedisk if we need to
+               if (sourcedisk && (strcmp(dev_path, sourcedisk) == 0)) {
                        udev_device_unref(dev);
                        continue;
                }
index fabc0ef524824a63c3f467f0d7e291f635f9d33a..b31b096a54a26770bb4c7d6f9a9069cd215e6e64 100644 (file)
@@ -415,7 +415,8 @@ int main(int argc, char *argv[]) {
        }
 
        // Load common modules
-       mysystem(logfile, "/sbin/modprobe vfat"); // USB key
+       mysystem(logfile, "/sbin/modprobe vfat");  // USB key
+       mysystem(logfile, "/sbin/modprobe ntfs3"); // USB key
        hw_stop_all_raid_arrays(logfile);
 
        if (!config.unattended) {
@@ -555,7 +556,10 @@ int main(int argc, char *argv[]) {
        assert(sourcedrive);
 
        int r = hw_mount(sourcedrive, SOURCE_MOUNT_PATH, "iso9660", MS_RDONLY);
-       if (r) {
+       if (r) r = hw_mount(sourcedrive, SOURCE_MOUNT_PATH, "ntfs3", MS_RDONLY);
+       if (r) r = hw_mount(sourcedrive, SOURCE_MOUNT_PATH, "vfat", MS_RDONLY);
+       if (r)
+               {
                snprintf(message, sizeof(message), _("Could not mount %s to %s:\n  %s\n"),
                        sourcedrive, SOURCE_MOUNT_PATH, strerror(errno));
                errorbox(message);