Linux recovery usb stick

Unix etc.

Create a Recovery USB Stick in Linux

A recovery USB stick is a bootable USB drive that can be used to rescue a system or perform critical maintenance. It’s a useful tool to have around. Typically, a system of interest is booted from the USB stick, maintenance is performed, then the repaired system is rebooted from its own disk. Below is a simple guide to creating a number of rescue USB sticks.

A Rescue stick can help fix many system problems, such as a system that won’t boot, a broken GRUB configuration, a disk or other hardware problem. By allowing the whole operating system to be taken offline, a rescue USB allows maintenance of a kind that cannot be performed any other way.

It is easy to create a bootable USB stick in Linux. In these examples, I used a Raspberry Pi, but any Linux PC would do equally well.

Select a Spare USB Stick

Find a suitable USB stick. It doesn’t have to be anything fancy. An old one is fine. Make sure it is USB 2.0 (or 3.0) and at least 2 GB in size. In these examples I am using an old Bytestore 2 GB.

Choose the Rescue System

A wide range of bootable environments are available. We are going to look at three of them. The first is GParted, a small Linux distro designed specifically for partitioning your disk. The next, SystemRescueCD, is larger. It can partition disks too, but comes with many other recovery tools and a more usable environment then GParted. Linux Mint os the third environment and will be looked at last. It is a full Linux distribution.

Download GParted

Open a browser and surf to the GParted download page. About half way down is a table of Stable Releases. Click on the latest 32 bit version, and save the file. At the time of writing (May 2019), the latest version is 0.33.0-2. By the time you read this, it might well have been updated. (Note that the download redirects to SourceForge).

Alternatively, and it might be a bit easier, just grab the file with one command. Right-click on the download link, choose “Copy link location”, then use wget and paste the URL:

The GParted download is about 350 MB.

Write the Image to USB

Plug in your USB stick. If it mounts, unmount it. Use fdisk –l to check the device name, as follows.

fdisk -l prints lots of stuff about all disks and partitions on my system. I can identify that the USB stick is /dev/sdb because that is the only device that is close to 2 GB in size, and my USB stick, as stated above, is 2.0 GB. (It shows up as 1.9 GB here).

Warning: The following command will erase all data currently on your USB stick. If you need to keep that data, do not proceed. Also, before typing the following command, be absolutely certain that you are using the correct device (/dev/sdb in this example, but it might well be different on your system). If you were to use the wrong device with this dd command, it could potentially destroy your system by overwriting part of your root disk. Please take care.

Having identified the right device, proceed as follows to write the image to it.

The dd command should take about 5 minutes on less. On a Raspberry Pi 2 it was just over 2 minutes.

Boot from USB

Put the USB stick into a convenient PC or laptop. Switch the machine on. (You might have to fiddle with the BIOS settings to tell the system to look for bootable USB devices). If it is working, you will see the USB boot menu, briefly, followed by a boot sequence. Click “Ok” when it asks about keymaps. The select a keyboard (I chose “02” for British), then choose option “0” to go straight into a graphical desktop.

In a minute the GParted screen appears. The GParted application itself is running in a Window. Apart from that, you are looking at Fluxbox, a sparse (but very compact) graphical window system. Right click anywhere to open a terminal or other application. At your disposal are Netsurf, a basic browser, various terminals, but not much else. When you have finished messing about, shut the system down and remove your USB.

Читайте также:  Изменить вид linux mint

SystemRescueCD

The GParted environment is fine, but is really just intended for disk partitioning. SystemRescueCD offers a richer environment and comes with a bigger variety of tools. Download the latest ISO from the SystemRescueCD downloads page. The image size is about 800 MB. At the time of writing (May 2019), release 6.0.3 is the latest, so I will just grab it directly:

As before, write the ISO to the USB stick. This should take 5 minutes or so:

Put the newly created SystemRescueCD USB stick into the PC of interest and boot from it. You will see the boot menu – press [Enter] to accept the default. A textual screen appears. To start the graphical environment, type “startx“, as instructed. In a few moments you will be looking at an XFCE graphical interface.

This is a much richer environment than GParted/Fluxbox. For a start, Firefox is available, instead of Netsurf. So is the GParted disk partitioning tool, in fact, as well the LVM subsystem and various applications useful in a rescue situation.

Linux Mint

Putting a full Linux distribution onto a USB key is just as easy. You just need a bigger drive though. In this example, Linux Mint MATE is installed. Instead of a 2.0 GB stick, I will use a 32GB Corsair drive. As before, download the latest version of Linux mint, then dd it onto the stick.

For this example I will grab it with wget. You should probably use a browser,

Writing to the USB stick takes about 10 minutes:

Afterwards, put the drive into your PC of interest and power on. It should boot into Linux Mint 19.2 without further intervention. Mint is, of course, a full desktop distribution. Not necessarily intended for use in a rescue or maintenance situation. But it could be used in one, coming with GParted, the LVM subsystem and many useful tools.

Conclusion

Having a SystemRescueCD USB drive around is always handy. It is a good idea to pack one in your laptopn bag. And update update it every so often. SystemRescueCD is a live project and new releases are quite frequent.

2 thoughts on “ Create a Recovery USB Stick in Linux ”

So is that just for Linux system or can i write a ISO win 10 boot to the USB as i seem not to be able to get a working win 10 USB and i want to replace my Linux system.

Hi Darrel. The procedure is for Linux only.

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Источник

программный ремонт usb flash накопителей в linux

Довольно таки часто занимался программным восстановлением usb flash накопителей на Windows, ну и заинтересовался как можно это реализовать на Linux. Как раз под рукой лежала флэшка JetFlash TS4GJF160 на 4Gb, которая не хотела работать

И так для начала разберемся что же есть программный ремонт. В любой флэшке установлена микросхема-контроллер. Она отвечает за передачу данных между компьютером и флэш-памятью. В случае различных сбоев питания, неправильного извлечения и других причин – происходит сбой контроллера. В результате чего контроллер блокируется и не отвечает на запросы операционной системы. Также, блокировка может произойти из-за износа микросхемы памяти — появления дефектных блоков или превышения порога циклов записи (тогда контроллер сам метит блок как неиспользуемый и часто блокирует флэш на запись). И при попытке доступа к нему из операционной системы можно увидеть следующие сообщения «Вставьте диск» или «Нет доступа к диску», «Диск не отформатирован». Но при попытке отфарматировать выдается сообщение типа «Диск защищен от записи»

Так как же боротся с этим?! Весьма просто…

Вставляем usb flash накопитель в компьютер и определяем какое имя ему присваивается При подключении usb flash накопителя к компьютеру, Linux присваивает ему имя типа sdX (первому устройству присваивается sda, второму sdb и так далее. Но чтобы узнать какое имя он ему присвоил наверняка, используем 1 из способов:

Из этого всего нам нужна только 1 строка:

которая и говорит нам что присвоено имя устройству sdc1

Аналогично первой команде ищем среди последних строк:

Имхо самый оптимальный вариант, выведет весь список смонтированных устройств и в самом конце видим следующее:

Думаю тут все понятно, /dev/sdc1 то что нам и нужно

Забиваем usb flash накопитель нулевыми байтами, набирая:

После чего нам выдаст следующее:

На ошибку можете не обращать внимание, мы же не указали необходимый размер

Форматируем usb flash накопитель, командой:

Создаем новый раздел, командой n:

Просматриваем что получилось, командой p:

Так как Linux раздел нам никчему сменим его, командой t:

Смотрим результат, командой p:

Ну и записываем таблицу разделов на usb flash накопитель, командой w:

Форматируем usb flash накопитель, командой:

После форматирования в раздел FAT16, выведет следующее:

Команда для форматирования в FAT32:

После выполнения этих пунктов, в WinXP usb flash накопитель выдал «Диск не отформатирован» и только после того как я отформатировал стандартными средствами Win все заработало

Вот вообщем-то и все… Удачи в восстановлении!)

Для дополнительной информации об устройстве, введите:

Источник

Восстановление флешки в Linux

Для многих начинающих пользователей система Linux является непривычной средой, в связи с чем, в зависимости от дистрибутива данной операционной системы, многие функции могут выполняться иначе, нежели в Windows. В частности, при использовании съемных носителей информации возникают нередко вопросы об их подключении, форматировании и восстановлении.

Читайте также:  Отключение проверки цифровой подписи для драйвера windows x64

Существует немало способов, как выполнить данные операции с флешкой в системе Linux, но остановимся на самых простых и распространенных.

Форматирование с помощью командной строки

После запуска консоли необходимо прописать следующую команду: «# dmesg | tail», благодаря которой системой определяется имя устройства. В командной строке отобразятся данные, где присвоенное системой имя флешки указано в квадратных скобках – в данном случае [sdb]. Это выглядит следующим образом:

Далее необходимо прописать операцию форматирования, однако пользователю должен быть известен файловый формат, заданный на устройстве – FAT32 или NTFS. Каждый формат имеет собственную команду:

  • «$ sudo mkfs.vfat/dev/имя устройства» – для FAT32;
  • «$ sudo mkfs.ntfs /dev/имя устройства» – для NTFS.

Утилита Palimpsest

С помощью данной программы можно легко и быстро восстановить устройство. Для этого достаточно воспользоваться функцией форматирования, а именно:

  • Подключить съемный носитель к компьютеру и запустить программу.
  • Выбрать устройство в программе и нажать функцию «Форматировать раздел», после чего откроется окно с параметром «Файловая система», полем ввода имени флеш-накопителя и кнопкой «Форматировать».

Программа Gparted

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

Утилита «Управление дисками» (gnome-среда)

Графическая среда Gnome – довольно распространенная оболочка во многих операционных системах Linux. Она отличается большим количеством удобных приложений, инструментов и утилит по управлению системой компьютера, среди которых имеется замечательная программа «Disk Utility» («Дисковая утилита» или «Управление дисками»). Потому, чтобы восстановить флеш-накопитель, достаточно запустить «Диск Утилити», подключить устройство к компьютеру и проделать следующие действия:

1. Выбрать устройство в специальном поле устройств слева, затем нажать кнопку «Настройки» (иконка с шестеренками).

2. Далее в открывшейся вкладке с пунктами выбрать первый «Форматировать раздел…».

3. Затем задать необходимые параметры: ввести любое имя для тома и определить тип файловой системы. После чего кликнуть по кнопке «Далее» и начать операцию восстановления.

Заключение

Перечисленные в статье способы восстановления могут отлично применяться по разным причинам:

  • ошибки;
  • проверка на дефекты;
  • и в случаях, когда компьютер не видит флешку.

Перед тем как проводить форматирование устройства, обязательно удостоверьтесь, что на флешке нет важных для вас файлов. В противном случае, вы рискуете потерять все записанные ранее данные. Ну а если вам необходимо восстановить файлы, то это можно сделать с помощью других специальных программ: TestDisk, Extundelete, R-Studio, R-Linux, DMDE, Foremost, Mondo Rescue и т. д.

Источник

How to Repair a Corrupted USB Drive in Linux

Everyone has a flash drive. They’re great little things, and they make moving data around easy. However, sometimes flash drives can get corrupted or just flat-out quit working. Thankfully, if you’re using Linux, you already have access to an array of tools that can help you fix the problem. We are using Ubuntu for this tutorial, but everything applies to most modern Linux distributions. Here is how you can repair a corrupted USB drive in Linux.

In this article, we prioritize the safety of your data. First, you’ll see how you can back up your flash drive’s contents and then proceed to various fixes for the problem at hand. This way, if an attempt at fixing the problem ends up making it worse, you may still be able to revert to the snapshot of the current state of your flash drive.

Take a Compressed Full Backup Image

In Linux, there are many tools for backing up any storage device. However, the tried-and-tested approach relies on dd and GunZip (better known as gzip).

1. To make a backup of your flash drive, first connect it to your computer. Fire up your favorite terminal (or press CTRL + Alt + T ).

2. Locate your flash drive:

4. To back up your flash drive to an image file compressed with ZIP in a single command, use:

5. To restore the backup, you’ll have to reverse the two commands’ sequence and define your flash drive as the output device. The full command will look like this:

Fix Corrupted Filesystem with FSCK

With the flash drive’s contents backed up, it’s time to try fixing it. For that, you can turn to fsck . This tool is great for removing bad file blocks, as most (if not all) corruption and unreadability comes from problems like this.

For this command, you’ll have to define the partition instead of the full drive. You’ll find it with a similar name as your device by issuing:

Then, run fsck on it with:

In this command:

  • sudo fsck runs the fixing tool with administrative rights.
  • -v tells it to show us detailed information about the proceedings.
  • -a states we want it to automatically try repairing any errors it finds.
  • /dev/disk… is the partition that will be checked for errors.
Читайте также:  Когда исправят проблемы с windows 10

Format USB Drive with Fdisk/MKFS from the Terminal

If fsck didn’t manage to repair the device’s filesystem, you can try to format it to use it as if it is new.

1. The first step is to erase any existing filesystem structures and recreate them from scratch. You can use fdisk for this. Run it with sudo on your device with:

2. Press o followed by Enter to create a new DOS partition table on it to have your USB drive readable everywhere. If you only want to use it on your modern computer and OS, you can replace o with g to create a new GPT partition table instead.

3. Press n followed by Enter to make a new partition, then p to make it a primary one. If you used e instead of p , it would be created as an extended partition, but there’s no point in doing so if you aren’t planning to create more than three partitions on the drive. Then, you can just press Enter when asked about the partition’s number, first and last sectors, to accept the defaults and have the partition span the whole USB drive.

4. Press p and then Enter to check out the new storage structure in your USB drive. Then, press w followed by Enter to write the changes to the USB drive and exit fdisk.

5. Your partition will be unformatted, and since it won’t have a filesystem yet, it will be unusable. To create a filesystem, you can use one of the mkfs tools that come with all modern Linux distributions. To format your partition as FAT32, usable by most devices, use:

6. To format your partition with NTFS, for use with modern versions of Windows, or with EXT4, for use only with Linux, use:

The GUI Way to Check and Fix USB Drive with Disks

If you don’t like typing commands, you can turn to the Disks tool for checking and formatting your USB drive. Disks is pre-installed on Ubuntu.

1. Visit your apps menu and search for “disks.” Launch the app when you locate it.

2. Choose your USB drive from the list on the left and click on the icon with the two cogs. Choose “Repair Filesystem” and follow the steps of the wizard to fix the filesystem.

3. In our case, we weren’t dealing with a hardware problem but with filesystem corruption. Although the issue was beyond repair, we could reformat our USB drive and keep using it. To do that with disks, with the USB drive selected, click on the icon with the two cogs again and choose “Format Partition … “

4. Enter a name for your USB drive in the Volume Name field and choose from the three most popular filesystems for it:

  • Ext4 for use with Linux
  • NTFS for use with modern versions of Windows
  • FAT for use with both, as well as other types of devices (from smartphones to gaming consoles)

5. Note the “Erase” option. Leave it disabled for a quick format. Flick it to On for a complete format that will fully erase your device’s contents. When dealing with corrupted devices that could also have some bad blocks, it’s better to go for the full erase option.

Rejuvenated USB Drive

Now that you have repaired your corrupted USB drive, you can use it again like a brand new drive. And if you are looking to create a Linux Live USB drive, follow the instructions here.

OK’s real life started at around 10, when he got his first computer — a Commodore 128. Since then, he’s been melting keycaps by typing 24/7, trying to spread The Word Of Tech to anyone interested enough to listen. Or, rather, read.

6 comments

Amazing the weird stuff you can do to a USB drive such as turning one into an installer, then later finding the drive’s been dramatically reduced in size. This can easily be fixed; still seems odd it happens.

Good tips here for Linux.

Once in a great while, a USB drive just dies…hardly ever, though.

Any flash technology will eventually die, even SSD hard drives. Yet they fail less often than HDD hard drives.
“All flash devices can sustain a finite number of writes and erasures, also called program/erase cycles, or (P/E cycles). ”
storageswiss

Maybe I missed something along the way BUT how can you do a reliable backup of the USB drive if it is corrupted?

Thanks! Genius! This fixed my undetectable flash drive and made it detectable again.

fsck gives me a ‘super block size’ error.
fdisk is giving me a ‘input/output error’.
Is there anything else I can try or is the drive completely shot?

Thank you! I’ve been trying for hours to get my flash drive up and running again. I tried several other suggestions found online, to no avail. Your guide worked perfectly. Much appreciated!

Источник

Оцените статью