Author Topic: Minor suggestion for check_swap.sh  (Read 1349 times)

urkomasse

  • Full Member
  • ***
  • Posts: 81
    • View Profile
Minor suggestion for check_swap.sh
« on: November 20, 2012, 07:40:51 PM »
Change the line for "swapon" so it happens as long as there is a /home/.swapfile

Delete it from where it currently is, and add this at the end.
Code: [Select]

if [ $MEMTOTAL -lt 1000000 ]; then
        if [ ! -e /home/.swapfile ]; then
                dd if=/dev/zero of=/home/.swapfile bs=1k count=524288 >/dev/null 2>&1
                mkswap /home/.swapfile >/dev/null 2>&1
        fi
fi
if [ -e /home/.swapfile ]; then
        swapon /home/.swapfile
fi

If the user has chosen to create a swapfile at some point, we should use it, right?

jnetman1

  • Administrator
  • Hero Member
  • *****
  • Posts: 285
    • View Profile
Re: Minor suggestion for check_swap.sh
« Reply #1 on: November 21, 2012, 09:32:17 PM »
Am thinking it might be better instead to just create and enable swap on all hdd systems, since it wouldn't likely have any significant impact. Would need to figure out a way to detect hard disks vs. flash-based storage, but don't think that would be too difficult. What do you think?

urkomasse

  • Full Member
  • ***
  • Posts: 81
    • View Profile
Re: Minor suggestion for check_swap.sh
« Reply #2 on: November 22, 2012, 01:43:42 AM »
The trick there would be to detect:
- If it's a hard disk.
- If the user has already run the "enable hibernate" script.

Or the "enable hibernate" script needs to take into account the possibility that the swap file already exists. Not too hard either.

For detecting the drive, "hdparm -i" might be the way to go. I don't have any netbook with flash drive to try.

But yes, I agree, having swap with any netbook with a hard drive makes sense. Maybe just forget the checking for type of hard drive, and always create the swap if the /home/ partition has more than, let's say, 20Gb free?

I don't think we'll be seeing SSDs of that size in budget netbooks anytime soon.