3
# uname -r
5.13.0-27-generic
# lsb_release -a
LSB Version:    core-11.1.0ubuntu3-noarch:security-11.1.0ubuntu3-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 21.10
Release:    21.10
Codename:   impish
# swapon
/swapfile file  12G   0B   -2
# clonezila
(...)
# swapon
(nothing)
# swapon /swapfile
# swapon
/swapfile file  12G   0B   -2

Why does running Clonezilla on my Ubuntu environment disable swapfile? Is there a way to prevent this behavior? I just want to backup/restore some data on some microSD cards while doing something else at the same time.

EDIT: swapfile is disabled when I select restoredisk or savedisk.

Logan
  • 482
TNT
  • 235

1 Answers1

2

The answer is very simple. It happened to me like you, and I didn't see why at the very first moment.

Your swap is not in a partition, it is in a swapfile in /, named swapfile. As a file, it is part of the filesystem. In order to save or restore, the filesystem has to be unmounted, / not accessed live, as changes to a live filesystem while cloning may result in data being corrupted in the target.

I tested it in a VM. I was assuming that yours was a swap partition (I read your question very quickly and didn't realize it was not a partition) and I downloaded Clonezilla in the VM to try to repeat the behavior. I checked the Clonezilla script and documents to see if that was expected and, when I double checked your output to follow your exact steps, I realized that your swap is based on a file.

It seems that the latest Ubuntu releases are creating swap this way automatically. My VM with Ubuntu 20.04 LTS is also using a file:

swapon
NAME      TYPE SIZE USED PRIO
/swap.img file 2.9G   0B   -2
Carles Mateo
  • 1,677
  • 1
    And is there a way to disable this behavior? I often use Clonezilla to backup/restore Raspberry Pi cards. – TNT Feb 16 '22 at 17:44
  • Yes @TNT the best way is to create a partition dedicated for swap instead of using a swapfile. You can do this when you install the Operating System, or repartition later. But to resize the partitions the filesystem needs to be unmounted. Maybe you still have free space in your SD card, depending on the image you toasted. Or you can clone your SD card to a bigger SD card, and then boot with the new one and make a new partition for swap. You will be able to disable the old swap file removing it from /etc/fstab – Carles Mateo Feb 17 '22 at 22:14
  • I'm using Ubuntu with a swapfile, not a Clonezilla Live. I'm not cloning my root partition. The SD cards are from Raspberry Pi, without swap file or swap partition. – TNT Feb 18 '22 at 19:50
  • My understanding is that you're using ubuntu in a pc, and working with SD that you'll use in Raspberrys, right?. I installed clonezilla 3.35.2-1 in Ubuntu 20.04 LTS and I cannot reproduce the behavior you describe. Can you detail what operations you do inside clonezilla?.
    NAME      TYPE SIZE USED PRIO
    /swap.img file 2.9G   0B   -2
    carles@ansiblemaster:~$ sudo clonezilla
    Clone mode is not selected!!!
    Program terminated!!
    Press Enter to exit...
    carles@ansiblemaster:~$ swapon
    NAME      TYPE SIZE USED PRIO
    /swap.img file 2.9G   0B   -2```
    
    – Carles Mateo Feb 18 '22 at 19:55
  • Yes. That's no point in creating a swap partition in the SD card I'm cloning. – TNT Feb 18 '22 at 19:56
  • swapfile is disabled only after I select restoredisk or savedisk. You could check on another terminal while still running Clonezilla. – TNT Feb 18 '22 at 20:11
  • Can you confirm what version of clonezilla are you running?. – Carles Mateo Feb 18 '22 at 20:31