Partition base number order restoration (sda2 > sda1)

I decided to remove Windows. It was at the beginning of my hard drive, so I deleted the first partition, then I extended the second partition down to the beginning of the hard drive. I assumed that doing this operation (the second partition becomming the first, and it being moved the beginning of the drive) that it would inherit the base partition number (i.e. the kernel device name of sda1). However I’ve learned that disk utilites are generally uninterested in doing this, and instead preserve partition numbers. I believe the likely reason for this is because the designers know that some configurations define partitions (fstab and bootloader configs, for example) and are thence hesitant to alter a bootable configuration. I, however, like order. And thankfully, the order can be re-based.

The easy way

First thing to do is add a partition, afterward the partition table can be re-based.

Adding a partition

Disk utilities generally follow the pattern that when they create a partition they begin with the first available number; hence, a new partition should be named sda1. Here’s what my partitions looked like originally:

01-sda2-&-sda3

Since it’s quicker to create a partition at the end of the drive… add a partition to the end… and get sda1:

02-sda_2-3-1

Fixing the partition order

The only disk utilites I know that have this available operation are fdisk and gdisk. They have an option to re-order partition numbers (i.e. the first partition is one…). Boot from a install CD or rescue disk and run fdisk:

# fdisk /dev/sda
...
Command (m for help): p  # prints partition table
...
Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1       625133568 625141759      8192     4M 83 Linux
/dev/sda2  *         2048 608364543 608362496 290.1G 83 Linux
/dev/sda3       608364544 625133567  16769024     8G 82 Linux swap / Solaris

Partition table entries are not in disk order.

Notice that sda1 Starts and Ends after the other partitions. From here enter the expert menu:

Command (m for help): x

And fix the partition order:

Expert command (m for help): f
Done.

Expert command (m for help): r
Command (m for help): p
...
Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1  *         2048 608364543 608362496 290.1G 83 Linux
/dev/sda2       608364544 625133567  16769024     8G 82 Linux swap / Solaris
/dev/sda3       625133568 625141759      8192     4M 83 Linux

The easy but hold-on-tight way

I’ve heard of someone doing this but haven’t tried it myself. What is done is that the partition table values is written down, the partition table wiped, then the partition table values are re-entered. Since you’re creating a new partition table from scratch the correct partition order will be created. This actually is perfectly safe to do.. if the values are gotten right. The partition table is written on the first sectors of the disk so the partition contents are perfectly safe. I’ve known this to be done before; however, I have not tried it so please use at your own risk. To learn more about this read: Fix MSDOS partition manually.

Configurations with partition definitions

Afterward, be sure to adjust the partition definitions in any configurations that have them. Also some bootloaders may store this value in the header region of the drive requiring a re-install of the bootloader.

Resources

rback – a generic, local, rsync-based, backup and restore script

rback

Description

rback is a generic backup and restore script. rback wraps common functions of rsync to aggregate backup necessities. rback defines:

  1. The copy options.
    2. The source and destination directories.
    3. The file, folders… to include or exclude.

rback is repository-based to allow for multiple backup types (like full system backups, configurations…), and is only for local backups (i.e. the same computer that it resides on).  Additionally, rback includes a diff method for working with text files.

Usage

rback - a generic, local, rsync-based, backup and restore script
  -r, --repo    - repository select                     : -R repository new
  -i, --include - include list add files, folders...    : -I include list edit
  -e, --exclude - exclude list add files, folders...    : -E exclude list edit
  -x, --xecute  - execute a: restore, backup, or diff
  = overrides  =
  -c, --confdir - configuration dir. from livecd, e.g.  : -C configuration edit
  -s, --srcdir  - source directory,  alternate specify
  -d, --dstdir  - destination dir.,  alternate specify
  -j, --justdo  - no confirm

For more information, rtfw (read the fun manual). :)

  • Download from the AUR.

gurl – a curl general download wrapper

Because I don’t need another download program (and sometimes I find it not installed) I built this:


#!/usr/bin/bash
# A curl general download wrapper
# -l : redirect automatically
# -O : output filename is remote name
# -# : progress bar
# -w : (--write-out) print filename
# -A : user agent
#    : resume difficult (wget -c, better): http://tinyurl.com/7umwyl3

for u in "$@"do
  curl -l -O -# -w "%{filename_effective}\n" -A "Mozilla/4.0" "$u"
done

And it looks like this:

# gurl http://.../archlinux-2014.09.03-dual.iso
###############################                                           43.4%

WTFM (Write the Fine Manual) with Pod2man text-converter

Todd Partridge (Gently):

Post before was a jetsam, added a bit and touched-up.

Originally posted on Linux Tidbits:

Note: This is a guide from a lightly-proficient manual writer that’s targeted for beginning users: it’s formatting method is easy and conversion method is basic. This method may also be helpful for those that use github because it has rendering support for this method. For a more traditional approach, nixCraft has an article for that.

Because it was the authors first effort to write a man page, talk was that it was good to use Pod2Man. Pod2man is an application that converts text using Plain Old Document (POD) formatting to traditional manual (man) pages. POD markup is easy to do and pod2man is conveniently pre-installed on most Linux distributions (as it is part of the Perl package).

An example

To get a good idea of what to do, here is a basic example demonstrating the formatting (of a fictitious program dr-smile):

 dr-smile - output platitudes to…

View original 467 more words

Gentoo Linux Tidbits

Todd Partridge (Gently):

Updated bash script and generally

Originally posted on Linux Tidbits:

I’ve been using Gentoo for about two years now and I took notes on managing my box. These are those notes. If you’re interested in installing Gentoo take a look at Gentoo Quick Install.

Update: bash script

This section is an addition. I’ve since created a bash script that does many of the functions and make reading the rest less necessary. The script is self-explanatory: link.

About Portage

Gentoo Linux uses a package management system called Portage. Portage offers one of the most extensible and customizable package systems available in Linux.

System Update

Update all packages on the computer. This process involves: syncing Portage, creating a text file to review updates, updating the system, merging new configuration files, remove orphaned dependencies.

Sync the portage tree

emerge --sync # or
eix-sync      # preferrable for faster searches (eix search)

Examine update before install

emerge --pretend --verbose --update --newuse --deep @world…

View original 806 more words

Vim colorscheme tuneup

I hadn’t thought about it for awhile but today I updated by Vim colorscheme for the first time in about two years. In the process I found a few that were notable:

rdark-terminal

vcs_1_rdark-terminal

link

gruvbox

vimcs_2_gruvbox

link

synic

vcs_4_synic

I think this one is based on neon. link

kolor

vcs_5_kolor

link

jellybeans blueberry

vcs_7_jellybean-blueberry

This is what I decided on. It’s jellybeans with a twist. I put this in my ~/.vimrc for the adjustments:

colorscheme jellybeans
" Jellybeans colorscheme edits (not working)
"let g:jellybeans_overrides = {
"\   'Normal': { 'ctermbg': '242' }, 
"\   'CursorLine': { 'ctermbg': '238' },
"\}
highlight Normal     ctermbg=323232
highlight Normal     ctermbg=303030
highlight CursorLine ctermbg=238
highlight Visual     ctermbg=240

Others may have different results though as the theme alters dynamically as per background (mine is #323232 btw).

Download

I got these from a collection today and have put them in the AUR

arpa: (Ar)ch (pa)ckages – generic package tasks wrapper script

Todd Partridge (Gently):

Arch wrapper for pacman updated, very well tuned now.

Originally posted on Linux Tidbits:

I once saw a wrapper-script for pacman in the forums that was basically a short-hand version of common pacman tasks. Over the last couple years, I’ve expanded on it. It does just about everything I need it to and its real basic. I call it arpa and here are the tasks it covers:

arpa [option] [*package] - generic package tasks wrapper script -e, --explicit - install a package as explicit -g, --get - only download package files : -G for upgrade files -i, --install - install a package : -I for deps, *.pkg.tar.* -l, --list - list files installed by a package : -L genlist inst. pkgs -n, --info - information about a package -o, --owns - owning package of a file -q, --query - query for an installed package : -Q adds description -r, --remove - remove a pkg and its deps : -R force, no param orphs -s…

View original 43 more words

Follow

Get every new post delivered to your Inbox.

Join 52 other followers