[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

badblocks on hd using USB-flash... Re: improved lower memory install tip



"hd" stands for "hard drive" in case anyone didn't realize that already

On Tue, Nov 28, 2017 at 6:00 AM, Michael Paoli <Michael.Paoli@cal.berkeley.edu> wrote:

> Yes, I'd considered possibly creating and *using* swap on
> the target install drive *while* doing the installation.

> That does have some key advantages, notably there's generally ample
> space there, and generally faster and more reliable than USB flash,
> less write wear on the USB flash, etc.

   
In addition to using a liveUSB flashdisk a) to initially check a hard-drive for surface integrity before full hd-installation and b) to test-out that good hd's swap partition for speedier full hd-installation, I consider at least these three real-life cases for initially using a liveUSB flashdisk:
1. You want/need to backup the pre-existing *data only* on the hd on any and/or all given partitions before Linux hd-installation, whether that's from a pre-existing Windows installation or from a pre-existing Linux installation.
The extra required steps here are performing the mounting of hd partitions where the data resides, selecting all folders and files that are to be saved, and then performing the actual backup onto external media (DVD, USB, tape, ...etc.) 

2. You want/need to keep around and test the actual pre-existing installed OS('s) before Linux hd-installation/hd-reinstallation, whether of Windows or of another Linux distro.
This case comes up fairly frequently, and is usually the most complicated case.
It requires that you a) test each OS to see if that OS boots correctly (or at all), b) backup data and possibly re-adjust configuration-type files for that OS-to-be-saved, c) sometimes perform a badblocks-equivalent within that booted-up OS itself (e.g.,running Windows' "scandisk" and "filesystem check" utilities), and then d) perform some sort of partitioning utility to resize the partitions of pre-existing installed OS('s). In prepping a hd that has a pre-existing OS-to-be-saved before a Linux hd-install, I usually and effectively use the liveUSB flashdisk's 'gparted' utility for such repartitioning.    

3. You want/need *neither* the data *nor* the pre-existing OS on that hd before performing the full Linux hd-install.
This is usually the simplest case, because fewer extra steps are required using the USB flashdisk to prep that hd for a full hd-Linux install. A simple wipe/shred/zeroing-whatever, then repartitioning (fdisk, gedit, ...) and then badblocks-checking may be all that's really necessary.


On Tue, Nov 28, 2017 at 6:00 AM, Michael Paoli <Michael.Paoli@cal.berkeley.edu> wrote:

>  ... badblocks.  If one is going to use badblocks or equivalent, I'd
>  generally recommend using it *before* formatting (e.g. before mkswap).
>  Actually, what I often like to do - particularly on larger drives,
>  and when not in any great rush (probably more on this later, but ...):

That's one of the major drawbacks with performing disk integrity checks using badblocks on each individual online, non-RAIDed/non-md'd hd .
Even for Windows' "scandisk" and "filesystem check" utilities, it takes an awful-long time to finish a complete scan of each 1 TB+ hd.
It really comes down to an assessment of whether you can trust that the hd is and will be sufficiently around for awhile after hd-Linux installation as well as around for storing your data, without undergoing eventual disk read errors/hd-crash and/or showing up in BIOS S.M.A.R.T. utilities as the scary-sounding "impending disk failure".
   
If you use that liveUSB flashdisk to perform a badblocks surface integrity check on the first several GBs of that hd +and+ badblocks shows bad sectors near the start of that hd, then you can replace that defective hd *ASAP* rather than later. 
Considering this and the rest of what I've written above, I think it's best to perform most if not all prep steps for that Linux hd-install *specifically* using a rescue-type liveUSB flashdisk *beforehand* (ahem ahem KNOPPIX!), rather than relying upon the Linux distro-of-choice installation USB to "assist" you with these prepping steps  :-)
   

-A

Previously
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
I've found that another easier and faster option is to use a partition on the pre-existing hard-disk drive that's dedicated to swap.
How might you go about this?

1. You'd first have to obtain a good live-media (liveUSB) rescue-type distro to dedicate onto a separate USB flash drive.
I myself highly recommend using KNOPPIX for this [1] because this distro is so incredibly versatile for this and for practicaliy any other task you
might want to perform with such live-media (see [2]). KNOPPIX 8.x is also flexible enough to support low-memory i686 machines in addition to
low-memory machines with amd64 CPU's. Another good live-media rescue-type distro I and many others have used for this purpose in the past is
SystemRescueCd [3].

2. Once you've downloaded and successfully created your liveUSB flash drive, you'd use it to boot up your machine in question; preferably using
the option to boot into a command-line for a low-memory machine ---- for an amd64 machine using KNOPPPIX, that's entering "knoppix64 2" at the initial
boot-prompt.  I'm assuming for the sake of these instructions that the pre-existing hard-disk drive is recognized as "/dev/sda".

3. Once you have just the command-line (a.k.a., the terminal) up and running, you'd then probably want to repartition the pre-existing hard drive -- maybe by running fdisk/cfdisk -- to delete and recreate a few of the drive's partitions that you'll need. You can almost always go back to resize these very hard drive partitions using gparted from your installed desktop environment/window manager at a later time. I myself like to create a 1GB /boot partition on /dev/sda1 (default type 83) followed by the required swap partition on /dev/sda2 (sized as 1.5 x physical RAM, type 82). Once this initial partitioning is complete, then I'd **immediately** run a formatting and disk integrity check on both partitions using something like
'mke2fs -t ext4 -ccvv /dev/sda1 && mkswap /dev/sda2 && badblocks -svvn /dev/sda2'
(a better check on the swap partition if you have more time is using the write option on the badblocks command, as in 'badblocks -svv*w* /dev/sda2')

-----> Please check the results of this disk integrity check!
If the badblocks disk integrity check on both partitions finishes without error
  then you'd go ahead and activate the swap partition with 'swapon
/dev/sda2'
Else (if the disk integrity checks shows disk errors on **either** (partition)
  then you should seriously reconsider using that particular hard drive for
your Linux installation

4. Once you've successfully activated the hard disk's swap partition using your liveUSB flash drive, then you would shutdown your machine, remove this
rescue-type USB drive, grab your *installation* USB with your Linux distro of choice, and then boot up your machine using the latter.  On the vast majority of every Linux distros I've used (Debian, Ubuntu, Mint, Slackware, Arch-based, RPM-based, ...etc.), there's almost always an opportunity to activate that pre-existing hard drive swap partition in order to gain more useful memory resources before proceeding with a full distro installation on low-memory machines.  IIRC, Ubuntu and Mint allow you to run an xterminal session from the initial GUI (before full installation is started) and to then switch to the root user via 'sudo su -' before running 'swapon /dev/sda2' to activate the required hard drive swap partition.  Other distros allow you to open a command-line virtual terminal during installation to activate the swap partition, e.g., by hitting the Ctl-Alt-F2 keyboard combination, becoming the root user if not already, and then entering 'swapon /dev/sda2'.  Yes, if the full hard-drive distro's installation process is terminal-based (e.g., Slackware, Arch, Debian's non-GUI choices), you would instead hit the Alt-F2 keybd combo *omitting* the "Ctl-", before performing the next step(s) of activating the hard drive's swap partition .

Using such a hard drive swap partition instead of a USB flash drive's might even save a bit of wear-and-tear for repeated installations using that same
USB flash drive.

[1] http://www.knopper.net/knoppix-mirrors/index-en.html
[2] http://www.knopper.net/knoppix-info/index-en.html
[3] http://www.system-rescue-cd.org/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

--
You received this message because you are subscribed to the Google Groups "BerkeleyLUG" group.
To unsubscribe from this group and stop receiving emails from it, send an email to berkeleylug+unsubscribe@googlegroups.com.
To post to this group, send email to berkeleylug@googlegroups.com.
Visit this group at https://groups.google.com/group/berkeleylug.
For more options, visit https://groups.google.com/d/optout.