[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Installers, fstab and swap.



I have never had this issue so I'm assuming it is something new.

Late last year I ran on one machine 3 versions of Ubuntu (current LTS, current non-LTS stable, and current testing), 3 versions of Debian (Testing-which was Squeeze, Sid, Sid/Experimental), and LMDE (which was based on Testing-Squeeze at that time). I installed each individually and always allowed the installer to format SWAP. All installations were able to use the SWAP without any difficulty or any alterations by me to the fstab.

I know this is of no assistance to you at this time but it may help to identify when the issue crept into the installer.

Cheers
Michael.

On 13 April 2011 09:36, Anthony <salinelinux@gmail.com> wrote:
It has been pointed out to me that my installer, the Debian installer and the LMDE installer all format swap during the installation process.  This changes the UUID of the swap partition and makes all entries in the /etc/fstab files in other distributions on the disk invalid if they were also using that swap partition. Since its generally a waste to have multiple swap partitions on the same hard disk, I believe this behavior to be a bug. I was hoping to get a discussion going amongst the derivatives  this effects (And, Debian proper as it exists there as well) on what the "best" solution to this problem is.  Considering all the installers are formatting swap, I assumed there is a good reason for this, but haven't been able to personally think of one. I have written up code to mount all partitions on the hard disk I am targeting for root minus the swap partition and any extended partitions.  It then searches for /etc/fstab on each partition and if found replaces the UUID for swap with the new one.






## Copyright 2011 Anthony Nordquist http://www.salineos.com salinelinux@gmail.com
## Distributed under the terms of the GNU public license v2
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
## The GPL V2 can be read in its entirety at http://www.gnu.org/licenses/gpl-2.0.html

for i in $PARTINST; do
  ## Ensure that the partitions aren't already mounted
  umount /dev/$i
  ## Mount all partions that are on the same disk I am installing / to.
  mkdir -p /UUIDTEMP/$i
  mount /dev/$i /UUIDTEMP/$i
  ## First check if /etc/fstab exists on the partition.
 if [ -f /UUIDTEMP/$i/etc/fstab ]; then
  ## Parse the UUID line out of fstab.
  UUIDLINE=`grep -B 0 "swap" /UUIDTEMP/$i/etc/fstab`
  ## Determine the old UUID so we can use sed to replace it.
  UUIDLESS=`echo $UUIDLINE | awk -F "=" '{print $2}'`
  OLDUUID=`echo $UUIDLESS | awk -F " " '{print $1}'`
   if [ "$OLDUUID" != "" ]; then
    sed -i -e "s/UUID=${OLDUUID}/UUID=${TARGETSWAPUUID}/g" /UUIDTEMP/$i/etc/fstab
   fi
  ## Unmount the partition
  umount /UUIDTEMP/$i
 fi
done


I don't know if this is the absolute best solution to this issue, but I do think it needs addressed in some form. Obviously feel free to use this code as you see fit, $PARTINST and $TARGETSWAPUUID will need changed to whatever they are in other installers. And, might be useless depending on the language your installer is in. As it stands now our installers don't even play nice with other installs of our own OS. Any input or discussion on this issue would be greatly appreciated.

P.S. This doesn't do anything for second or third drives that might be using that particular swap partition. I haven't been able to think up a solution that deals with that without causing issues when targeting a USB key (Or having one plugged in that may have an OS on it).

                                                                                                                                  Cheers


Reply to: