Problems with USB flash drive, LUKS and backups

Quick to answer questions about finding your way around Linux Mint as a new user.
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions use the other forums in the support section.
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
Phairnix
Level 1
Level 1
Posts: 23
Joined: Tue Jul 07, 2020 6:24 am

Problems with USB flash drive, LUKS and backups

Post by Phairnix »

Hi,

I have been trying to make backups on an USB flash drive with LUKS encryption. I did manage to create a system snapshot with Timeshift and back up /home and data with Back In Time, but then the creation of backups stopped working properly. I still can continue copying files to the drive but Timeshift and Back In Time do not finish the processes anymore.

The procedure is as following:

I connect the USB flash drive and and I open it with the password (until logout). The drive is mounted with permissions for root.

When I run Timeshift, the snapshot can be created to start with, but gives finally these errors:

Code: Select all

[19:08:47] E: Error opening file “/run/timeshift/backup/timeshift/snapshots/2021-04-09_19-03-55/rsync-log-changes”: Read-only file system
[19:08:47] E: Failed to write file: /run/timeshift/backup/timeshift/snapshots/2021-04-09_19-03-55/rsync-log-changes
[19:08:47] E: rsync returned an error
[19:08:47] E: Failed to create new snapshot
[19:08:47] Failed to create snapshot
and Back In Time (as root):

Code: Select all

[E] Error: rsync: write failed on "/media/...": Read-only file system (30)
Also, when I try to copy a large amount of files to the drive, there are errors at some point.

It seems to me that there is something wrong how the permissions are handled, as the device changes to read-only after a while, but I don't know what to do about it. My search for similar problems has been inconclusive so far. Could it be something else altogether? How can fsck be run safely, if deemed necessary?

Code: Select all

System:
  Kernel: 5.4.0-70-generic x86_64 bits: 64 compiler: gcc v: 9.3.0 
  Desktop: MATE 1.24.0 info: mate-panel wm: Compiz 0.9.14.1 
  dm: LightDM 1.30.0 Distro: Linux Mint 20.1 Ulyssa base: Ubuntu 20.04 focal 
Machine:
  Type: Laptop System: Acer product: Aspire E1-530 v: V2.06 serial: <filter> 
  Mobo: Acer model: EA50_CX v: V2.06 serial: <filter> UEFI: Insyde v: 2.06 
  date: 10/08/2013 
Battery:
  ID-1: BAT1 charge: 20.5 Wh condition: 20.5/37.0 Wh (55%) volts: 17.1/14.8 
  model: SANYO Li_Ion_4000mA type: Li-ion serial: <filter> status: Full 
CPU:
  Topology: Dual Core model: Intel Pentium 2117U bits: 64 type: MCP 
  arch: Ivy Bridge rev: 9 L2 cache: 2048 KiB 
  flags: lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx bogomips: 7183 
  Speed: 798 MHz min/max: 800/1800 MHz Core speeds (MHz): 1: 1107 2: 1060 
Graphics:
  Device-1: Intel 3rd Gen Core processor Graphics 
  vendor: Acer Incorporated ALI driver: i915 v: kernel bus ID: 00:02.0 
  chip ID: 8086:0156 
  Display: x11 server: X.Org 1.20.9 driver: modesetting unloaded: fbdev,vesa 
  compositor: compiz v: 0.9.14.1 resolution: 1366x768~60Hz 
  OpenGL: renderer: Mesa DRI Intel HD Graphics 2500 (IVB GT1) 
  v: 4.2 Mesa 20.2.6 compat-v: 3.0 direct render: Yes 
Audio:
  Device-1: Intel 7 Series/C216 Family High Definition Audio 
  vendor: Acer Incorporated ALI driver: snd_hda_intel v: kernel 
  bus ID: 00:1b.0 chip ID: 8086:1e20 
  Sound Server: ALSA v: k5.4.0-70-generic 
Network:
  Device-1: Broadcom and subsidiaries NetXtreme BCM57786 Gigabit Ethernet 
  PCIe 
  vendor: Acer Incorporated ALI driver: tg3 v: 3.137 port: 2040 
  bus ID: 02:00.0 chip ID: 14e4:16b3 
  IF: enp2s0f0 state: down mac: <filter> 
  Device-2: Qualcomm Atheros QCA9565 / AR9565 Wireless Network Adapter 
  vendor: Lite-On driver: ath9k v: kernel port: 2040 bus ID: 03:00.0 
  chip ID: 168c:0036 
  IF: wlp3s0 state: up mac: <filter> 
  Device-3: Lite-On Atheros AR3012 Bluetooth type: USB driver: btusb 
  bus ID: 1-1.1:7 chip ID: 04ca:300b 
Drives:
  Local Storage: total: 931.51 GiB used: 40.46 GiB (4.3%) 
  ID-1: /dev/sda vendor: Western Digital model: WD10JPVX-22JC3T0 
  size: 931.51 GiB speed: 6.0 Gb/s rotation: 5400 rpm serial: <filter> 
  rev: 1A01 scheme: GPT 
Partition:
  ID-1: / size: 91.17 GiB used: 14.44 GiB (15.8%) fs: ext4 dev: /dev/sda2 
  ID-2: /home size: 273.84 GiB used: 1.79 GiB (0.7%) fs: ext4 dev: /dev/sda3 
Sensors:
  System Temperatures: cpu: 48.0 C mobo: N/A 
  Fan Speeds (RPM): N/A 
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Phairnix
Level 1
Level 1
Posts: 23
Joined: Tue Jul 07, 2020 6:24 am

Re: Problems with USB flash drive, LUKS and backups

Post by Phairnix »

So, I found out that I can check

Code: Select all

cat /etc/fstab
and I saw that the option

Code: Select all

errors=remount-ro
is included, which means that the drive is remounted as read-only if an error occurs. I suspect that this would explain the behaviour that I described.

Consequently, I would like to run fsck in order to check the USB flash drive, but I am not quite sure how to do it exactly. I found some guides that describe the handling of encrypted disks or LVM installations, but I'd rather be safe than sorry when trying something out. My current understanding is the following:

I should not mount the USB flash drive, but I would need to open the LUKS volume first:

Code: Select all

cryptsetup luksOpen /dev/(whatever) someName
where someName is the name of the plaintext device that I can run fsck on thereafter. I can check the status:

Code: Select all

cryptsetup -v status someName

Code: Select all

/dev/mapper/someName
Running fsck:

Code: Select all

fsck -fyv /dev/mapper/someName
where -f is used to force checking even if the file system seems clean, -v makes explain what is happening and -y makes confirm automatically the prompts to repair an error.

I can also

Code: Select all

sudo fsck -N -y
to run it without making any changes first.

Is this the correct way how to do it?

For reference:

https://en.wikibooks.org/wiki/Cryptsetup
https://man7.org/linux/man-pages/man8/cryptsetup.8.html
https://askubuntu.com/questions/1188496 ... g-fsck-f-y
viewtopic.php?t=256123
Locked

Return to “Beginner Questions”