Как работать с полной установкой USB и подкачкой

При создании USB-накопителя с полной установкой с помощью компьютера с разделом подкачки программа-установщик Ubiquity форматирует каждый раздел подкачки на компьютере и добавляет их пути в fstab. Это включает в себя существующие разделы подкачки на компьютере и разделы подкачки, созданные в процессе установки.

Если на компьютере уже есть разделы подкачки, Ubiquity не создает новый файл подкачки. для USB-накопителя. Если USB-диск загружается на компьютер, на котором нет раздела подкачки, свободного места подкачки нет.

Что мне делать? Должен ли я создать новый файл подкачки и добавить его в fstab? Если так, я должен просто удалить любые существующие разделы подкачки из fstab или я должен оставить их? Есть ли проблемы с безопасностью, может ли следующий человек, использующий компьютер, скопировать мои данные подкачки, банковские счета и т. Д.

0
задан 5 June 2020 в 13:02

1 ответ

Bootable USB and Swap Space

A computer can have multiple swap partitions and a fresh install of Ubuntu will use them all, even if they are not listed in fstab, In addition the computer can use a single swap file if it is listed in fstab.

Even Live and Persistent bootable USB devices will use all the swap partition(s) they find.

Ubuntu 20.04 will create a swap file during installation as long as there are no swap partitions on the computer. (This is another reason to unplug the internal HDD/SSD when installing).

Once the swap file has been added to fstab the computer will not use any swap partition that are not listed in fstab.

Security:

A flash drive can be easily lost or misplaced. If you use a pendrive when dealing with sensitive data, the drive should be fully encrypted.

A swap partition can be copied or cloned just like any other file or partition.

A swap file is part of the root partition and automatically gets encrypted along with it.

It is generally not a good idea to encrypt the swap partition on someone else's computer, when using a bootable USB. To prevent any data from being left in the host computer's swap partitions, a swap file should be used or swap should at least be turned off before exiting: sudo swapoff -a.

To replace a swap partition with a swap file on a bootable USB:

  • Check the swap that is in use:

    sudo swapon -s

  • If swap partition(s) found:

    sudo swapoff -a

    sudo nano -Bw /etc/fstab

  • Add "# " before the UUID of the swap partition(s):

    # UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX none swap sw 0 0

  • Add a line for the swapfile:

    swapfile none swap sw 0 0

  • Create the swap file:

    sudo fallocate -l XG /swapfile

Where X is the swapfile size in GB

    sudo mkswap /swapfile

    sudo chown 0600 /swapfile

    sudo swapon /swapfile
  • Reboot:

    sudo reboot

To enable Hibernation:

  • Increase swap file size to match RAM size up to 8GB per above as required.

  • Edit /etc/default/grub to add resume location and offset to grub.cfg:

GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX resume_offset=XXXXX"

  • Use UUID from root.

  • Use offset from sudo filefrag -v /swapfile

cscameron@cscameron-T:~$ filefrag -v /swapfile Filesystem type is: ef53 File size of /swapfile is 4819255296 (1176576 blocks of 4096 bytes) ext: logical_offset: physical_offset: length: expected: flags: 0: 0.. 0: 303104.. 303104: 1: 1: 1.. 2047: 303105.. 305151: 2047: unwritten 2: 2048.. 4095: 311296.. 313343: 2048: 305152: unwritten

  • resume_offset=303104

  • Update GRUB

    sudo update-grub

  • Test hibernation

    sudo systemctl hibernate

A hibernate button can be added using gnome extensions.

NOTES:

  • There is a slight possibility of getting holes in a swapfile when creating it with fallocate. /var/log/syslog can be searched for the phrase swapon: swapfile has holes to ensure there will be no data loss.

  • For the best chance of successful resume, plug the USB into the same slot it was in while hibernating. It should be okay to run the host machine from it's own OS while the USB is in hibernation.

0
ответ дан 19 June 2020 в 21:30

Другие вопросы по тегам:

Похожие вопросы: