We use some essential cookies to make our website work.

We use optional cookies, as detailed in our cookie policy, to remember your settings and understand how you use our website.

squidg
Posts: 23
Joined: Sat Jul 08, 2023 12:36 pm

Emergency mode after moving swap to USB drive

Fri Aug 11, 2023 7:15 am

I followed this guide https://www.addictivetips.com/ubuntu-li ... ian-linux/ to move the Swap Memory to a USB drive but once I rebooted I got stuck in emergency mode.

Is there a way to fix this or do I need to start over?
https://prnt.sc/WN86RQ6xvnOh

squidg
Posts: 23
Joined: Sat Jul 08, 2023 12:36 pm

Re: Emergency mode after moving swap to USB drive

Fri Aug 11, 2023 9:59 am

Thanks. I might need to start again...
Do you know of any tutorials i can follow to add the swap on USB without having this type of issue in future?

User avatar
thagrol
Posts: 14863
Joined: Fri Jan 13, 2012 4:41 pm

Re: Emergency mode after moving swap to USB drive

Fri Aug 11, 2023 10:24 am

squidg wrote:
Fri Aug 11, 2023 7:15 am
I followed this guide https://www.addictivetips.com/ubuntu-li ... ian-linux/ to move the Swap Memory to a USB drive but once I rebooted I got stuck in emergency mode.

That's very out of date. It uses sysV init but most modern Linux (including RPiOS) use systemd and were doing so in 2020.
Is there a way to fix this or do I need to start over?
Yes:
  1. Write a clean desktop RPiOS image to a different SD card.
  2. Put the broken card into a USB card reader
  3. Disconnect the USB drive
  4. Boot from the new SD card. Let the first boot wizzard run.
  5. Connect the card reader. The desktop should automatically mount the broken SD card's partitions under /media/username
  6. Undo the changes you made.
  7. Shutdown
  8. Remove card reader
  9. Swap SD cards
  10. Boot
  11. Find a better tutorial and back up your SD card before applying it.
I suspect the problem is in the modification to /etc/fstab but without more of the boot log I cannot be sure.

Personally, if I were moving swap to a USB drive I'd use a swap partition not a swap file. But what makes you think you need additional swap space at all? Many (most?) folks run RPiOS happily with the default 100MB. And remember, you could just increase the size of the existing swap file and leave it where it is.
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

squidg
Posts: 23
Joined: Sat Jul 08, 2023 12:36 pm

Re: Emergency mode after moving swap to USB drive

Fri Aug 11, 2023 10:29 am

Personally, if I were moving swap to a USB drive I'd use a swap partition not a swap file. But what makes you think you need additional swap space at all? Many (most?) folks run RPiOS happily with the default 100MB. And remember, you could just increase the size of the existing swap file and leave it where it is.
For what I need to do I need more memory otherwise my Pi just keeps freezing. When I increase the swap directly on the SD Card it wore it out pretty quickly.... So for this, I should create a swap partition on the USB drive?

User avatar
rpdom
Posts: 25272
Joined: Sun May 06, 2012 5:17 am

Re: Emergency mode after moving swap to USB drive

Fri Aug 11, 2023 10:36 am

For swap on a USB drive I'd use an old-fashioned spinning rust disk drive. They don't have the same write issues as flash based devices.
Unreadable squiggle

squidg
Posts: 23
Joined: Sat Jul 08, 2023 12:36 pm

Re: Emergency mode after moving swap to USB drive

Fri Aug 11, 2023 10:59 am

rpdom wrote:
Fri Aug 11, 2023 10:36 am
For swap on a USB drive I'd use an old-fashioned spinning rust disk drive. They don't have the same write issues as flash based devices.
But it can also be done on a USB drive if done correctly seeing as the tutorial I followed was out of date right?

User avatar
rpdom
Posts: 25272
Joined: Sun May 06, 2012 5:17 am

Re: Emergency mode after moving swap to USB drive

Fri Aug 11, 2023 11:08 am

squidg wrote:
Fri Aug 11, 2023 10:59 am
rpdom wrote:
Fri Aug 11, 2023 10:36 am
For swap on a USB drive I'd use an old-fashioned spinning rust disk drive. They don't have the same write issues as flash based devices.
But it can also be done on a USB drive if done correctly seeing as the tutorial I followed was out of date right?
Yes, definitely. I haven't tried it recently, but it should be easy enough.
Unreadable squiggle

User avatar
thagrol
Posts: 14863
Joined: Fri Jan 13, 2012 4:41 pm

Re: Emergency mode after moving swap to USB drive

Fri Aug 11, 2023 11:09 am

rpdom wrote:
Fri Aug 11, 2023 10:36 am
For swap on a USB drive I'd use an old-fashioned spinning rust disk drive. They don't have the same write issues as flash based devices.
Yeah, so would I. Swap on flash (of any sort) is a recipe for trashing the drive.

@OP: hit your favourite search engine for how to add a swap partition on Linux. It isn't Pi specific.

If you want to go the USB drive formatted to ext4 with a swap file route start by understanding how to use fstab: Using fstab A Beginner's Guide
Knowledge, skills, & experience have value. If you expect to profit from someone's you should expect to pay for them.

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

squidg
Posts: 23
Joined: Sat Jul 08, 2023 12:36 pm

Re: Emergency mode after moving swap to USB drive

Sat Aug 12, 2023 12:03 am

So the USB drive will also wear out quickly just like the SD card is that correct?
With the spinning disk drive, do I get one of these for example with a USB docking station or USB cable connector? I only need 5-10gb max.
Image

User avatar
rpdom
Posts: 25272
Joined: Sun May 06, 2012 5:17 am

Re: Emergency mode after moving swap to USB drive

Sat Aug 12, 2023 9:32 am

squidg wrote:
Sat Aug 12, 2023 12:03 am
So the USB drive will also wear out quickly just like the SD card is that correct?
With the spinning disk drive, do I get one of these for example with a USB docking station or USB cable connector? I only need 5-10gb max.
I'd probably go for a 80GB or higher SATA 2.5" laptop drive and use a good (ASMedia) USB to SATA adaptor. The big drives in your picture need higher current at 5V an 12V. The Pi can't provide 12V, so if you are going to use one of those get a powered enclosure.

This is a drive I've been using with a Pi 400 when I needed a large amount of swap for a big compilation.
Pi_swap_disk.jpg
Pi_swap_disk.jpg (112.51 KiB) Viewed 768 times
Unreadable squiggle

squidg
Posts: 23
Joined: Sat Jul 08, 2023 12:36 pm

Re: Emergency mode after moving swap to USB drive

Sat Sep 09, 2023 8:20 am

I got given a Kingston UV400 2.5"" SSD drive 120GB. Would this also be ok to use or do I really need a spinning disk drive?

redvli
Posts: 2988
Joined: Thu Sep 03, 2020 8:09 am

Re: Emergency mode after moving swap to USB drive

Sat Sep 09, 2023 9:26 am

squidg wrote:
Sat Sep 09, 2023 8:20 am
I got given a Kingston UV400 2.5"" SSD drive 120GB. Would this also be ok to use or do I really need a spinning disk drive?
You will have to look at the specifications of that SSD. How many datablocks can be written in its lifetime. Smaller SSD's have lower numbers, but you will have a hard time writing that SSD to death with a Pi.

The quite popular 1T Samsung SSDs can be written to much more than specified in datasheet. There are simply people who have done that. From detailed analysis and extrapolation, once done by a tech site, it was clear that this SSD will outlive its user.

I have used my 1T Samsung as bcache for 3 4T HDDs for years, and it is still doing fine in an other role as LVMcache for an 8T HDD. And swap and 3x VM block storage and rootfs.

Code: Select all

ID# ATTRIBUTE_NAME          FLAGS    VALUE WORST THRESH FAIL RAW_VALUE
  5 Reallocated_Sector_Ct   PO--CK   100   100   010    -    0
  9 Power_On_Hours          -O--CK   079   079   000    -    106015
 12 Power_Cycle_Count       -O--CK   099   099   000    -    74
177 Wear_Leveling_Count     PO--C-   064   064   000    -    428
179 Used_Rsvd_Blk_Cnt_Tot   PO--C-   100   001   010    Past 0
181 Program_Fail_Cnt_Total  -O--CK   100   100   010    -    0
182 Erase_Fail_Count_Total  -O--CK   100   100   010    -    0
183 Runtime_Bad_Block       PO--C-   100   100   010    -    0
187 Uncorrectable_Error_Cnt -O--CK   100   100   000    -    0
190 Airflow_Temperature_Cel -O--CK   066   037   000    -    34
195 ECC_Error_Rate          -O-RC-   200   200   000    -    0
199 CRC_Error_Count         -OSRCK   100   100   000    -    0
235 POR_Recovery_Count      -O--C-   099   099   000    -    45
241 Total_LBAs_Written      -O--CK   099   099   000    -    472823410212

Return to “Troubleshooting”