Fedora Advent Calendar day 3

Have you seen this message when you are installing Fedora by Live CD? This message is shown when you don't choose ext4 file system as / file system. I just wanted to know why it doesn't allow to use other file system for / from source code.

At first, I checked which function checks this. It is in sanityCheck() in Storage class at pyanaconda/storage/__init__.py
In sanityCheck() there is a check logic to compare file system type.

1118         if (root and
1119             self.liveImage and
1120             root.format.type != self.liveImage.format.type):
1121             errors.append(_("Your / partition does not match the "
1122                             "the live image you are installing from.  "
1123                             "It must be formatted as %s.")
1124                           % (self.liveImage.format.type,))

self.liveImage come from this code.

 688     @property
 689     def liveImage(self):
 690         """ The OS image used by live installs. """
 691         _image = None
 692         if flags.livecdInstall and hasattr(self.anaconda, "methodstr"):
 693             _image = self.devicetree.getDeviceByPath(self.anaconda.methodstr[9:])
 694         return _image

I added some string in the message to know root and self.liveImage.

1118         if (root and
1119             self.liveImage and
1120             root.format.type != self.liveImage.format.type):
1121             errors.append(_("Your / partition does not match the "
1122                             "the live image you are installing from.  "
1123                             "It must be formatted as %s.[%s][%s]")
1124                           % (self.liveImage.format.type,root.format.type,self.liveImage.format.type))


As you can see root.format.type is btrfs and self.liveImage.format.type is ext4 means root is a disk to be partitioned and self.liveImage is the LiveCD's file system. It is no problems so far. This function only checks file system type is ok or not.
Ok, let's move other file which does install process on LiveCD. The pyanaconda/livecd.py has doInstall() it may has reason to use ext4 file system.

 139     def doInstall(self, anaconda):
 140         log.info("Preparing to install packages")
 141 
 142         progress = anaconda.intf.instProgress
 143         progress.set_label(_("Copying live image to hard drive."))
 144         progress.processEvents()
 145 
 146         osfd = os.open(self.anaconda.storage.liveImage.path, os.O_RDONLY)
 147 
 148         rootDevice = anaconda.storage.rootDevice
 149         rootDevice.setup()
 150         rootfd = os.open(rootDevice.path, os.O_WRONLY)
 151 
 152         readamt = 1024 * 1024 * 8 # 8 megs at a time
 153         size = self.anaconda.storage.liveImage.format.currentSize * 1024 * 1024
 154         copied = 0
 155         done = False
 156         while not done:
 157             try:
 158                 buf = os.read(osfd, readamt)
 159                 written = os.write(rootfd, buf)
 160             except (IOError, OSError):
 161                 rc = anaconda.intf.messageWindow(_("Error"),
 162                         _("There was an error installing the live image to "
 163                           "your hard drive.  This could be due to bad media.  "
 164                           "Please verify your installation media.\n\nIf you "
 165                           "exit, your system will be left in an inconsistent "
 166                           "state that will require reinstallation."),
 167                         type="custom", custom_icon="error",
 168                         custom_buttons=[_("_Exit installer"), _("_Retry")])
 169 
 170                 if rc == 0:
 171                     sys.exit(0)

This function reads data block from device and write to disk instead of copying each file. I think that is why / file system must be ext4 because _doFilesystemMangling() doesn't depend on file system type. IIRC DVD iso can select other file system for /, can't it? so LiveCD requires / should be ext4 is not any problem for me because I use ext4 for / and others.