GParted MBR Weirdness with New MSDOS Partition on Some Hard Disks

Just documenting the behaviour of Gparted that I have seen many times, with no logical explanation for a new MBR not being written correctly(?) or not overwriting a prior GRUB MBR correctly (?) so not leading to correct booting, with some hard drives but not others.

Normally you write a new partition table for a Windows install (especially if you had linux on the disk) if you want to copy install files from a Win.iso to then boot and install, from the Device menu of Gparted.

Sometimes this fails to work as the Win install files are not booted into so hangs, and I found that using command line fdisk to create a new empty DOS partition first, then using Gparted again for recreating and formatting a say, 10GB Recovery partition for the install files, setting the boot flag, then rebooting solves the issue.


sudo fdisk /dev/sda

Seen after Win install, but showing the 10GB REC partition:

See the original Post here:

Re-install Win 7 With No DVD and Replace Laptop Auto Recovery Partition


Rescue Your System from an MBR corruption? grub rescue>

At the failed grub boot prompt you can assume the the non booting drive is /dev/sda1 to start and see if the insmod files are found: 

set prefix=(hdX,Y)/boot/grub

Or use the values determined by attaching the drive to a working linux install to find the partition order:

sudo fdisk -l
Disk /dev/sda: 119.2 GiB, 128035676160 bytes, 250069680 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x64a1f25a

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 231241727 231239680 110.3G 83 Linux
/dev/sda2 231241728 250068991 18827264 9G 5 Extended
/dev/sda5 231243776 250068991 18825216 9G 82 Linux swap / Solaris


sudo blkid
[sudo] password for stevee:
/dev/sda1: UUID="1d9ac196-b1df-4dd0-994d-b9c9b1e8f23f" TYPE="ext4" PARTUUID="64a1f25a-01"
/dev/sda5: UUID="82fc41dd-56d4-41e4-99a8-85338bbdf01b" TYPE="swap" PARTUUID="64a1f25a-05"
/dev/sdb1: UUID="f92a3d3c-adf4-48e0-8964-83f2b52e251c" TYPE="ext4" PARTUUID="b060933f-01"
/dev/sdb5: UUID="e1a2c04b-3517-47aa-9636-3d713b864cdd" TYPE="swap" PARTUUID="b060933f-05"

Back in the failed grub menu, type:

Example: If the Ubuntu system is on sda1, enter: set prefix=(hd0,1)/boot/grub

set root=(hdX,Y)

Confirm the correct X,Y values and press ENTER.

Example: If the Ubuntu system is on sda5, enter: set root=(hd0,5)

insmod normal

Load the normal module.

If the module loads there will be no message.

If the module fails to load, try the full path: insmod (hdX,Y)/boot/grub/normal.mod


Transition to the normal GRUB 2 mode with increased functionality.

If the module loads there will be no message, and may go to the next stage boot menu as normal.

If not, but the module loads, HELP, TAB completion and command recall using the UP/DN keys should be available. Check current settings:


(Optional) Review the current settings.

insmod linux

Load the linux module. An error message usually means the path is incorrect.

linux /vmlinuz root=/dev/sdXY ro

Selects the latest kernel.

Example: linux /vmlinuz root=/dev/sda5 ro

If the vmlinuz symlink does not exist in /, use the full path to the kernel in /boot

Example: linux /boot/vmlinuz-3.2.0-14-generic root=/dev/sda1 ro

initrd /initrd.img

Selects the latest initrd image.

If the initrd symlink does not exist in /, use the full path to the initrd image in /boot

If successful, after ENTER there will be a slight delay and no messages.


Boot to the latest kernel on the selected partition.

In the worst case, you may need to re-install grub via a working system, say a bootable USB drive then find the drive with the broken grub menu (say /dev/sda) and:

sudo grub-install.real /dev/sda


sudo update-grub2

This will allow the USB pen drive to boot the broken drive from the USB pen grub menu. When back in the prior broken system if it boots OK, remove the USB pen drive and re-run:

sudo update-grub2

You should now be able to reboot into this drive as the only drive on a system.

Quickest Cloning of Working Mint System

The only command I know of that clones an active system drive is DD, but it is very slow at about 30GB / hr, system specs can do this unlike rsync or cp -vr because it doesn't get stopped by it's own process in /proc or /sys.

The fastest way I have found to get another clone of your perfectly setup system is by fresh installing a new system on a new drive from USB install image (10 mins), then using rsync as below to update the missing files from your system drive to the clone. This means MYSQL DB's, updates, home dirs etc. can be transferred as rsync's default is to copy newer files over old ones and as most of your working system's files don't yet exist on the new install, they get transferred also.

After you have fresh installed from USB image to the clone drive, do the full updates to your working system so your files are definitely newer or the same versions as the new drive install (don't update the new install!!), or use an older installed version from your spare backup drives and mount that on the working system you want to clone. 

All files from the fully working system drive will transfer to the clone-to-be using rsync except those in bold (assuming your spare drive is mounted at /media/home/user, so it doesn't loop copy /media/home/user files over and over until full!).

The excluded are in bold, and {-n=dry-run} ALWAYS!:

sudo rsync /* /media/stevee/1586c82b-01d5-46cb-822d-81dbe57c5951/ –exclude={dev,media,proc,run,sys,tmp} -vahn

Note! the UUID number of the system drive will be copied to GRUB /boot/grub/grub.cfg file and /etc/fstab.

Change them before you boot the new drive as it will now have the UUID value of the cloned drive!

sudo blkid

/dev/sdb1: UUID="1341613a-6c85-4b03-837e-d0636ecf6adb" TYPE="ext4" PARTUUID="f4b5a292-01"

It's EASY to edit grub's files in vim:

Replace all cloned drive UUIDs in /the new drive's /etc/fstab and /boot/grub/grub.cfg with the new drive's UUID:

sudo vi /media/stevee/de1ea326-7478-4297-8bce-79cb77d682c9/boot/grub/grub.cfg

In vim, press : then add at the :


g for global means substitute every occurrence of "oldstring" on every line.

sudo vi /media/stevee/de1ea326-7478-4297-8bce-79cb77d682c9/etc/fstab

OR you can edit the GRUB boot menu of the new drive by BIOS booting to it then pressing E at the GRUB menu and removing all references to UUIDs and replace with root=/dev/sdb1 format and change the relevant (hd0,1) formats to the correct partition values and boot with F10 ensuring to sudo update-grub2 once the new drive has booted correctly.

Cool Command #11 – cat /etc/*release; env

stevee@QuadMint ~ $ cat /etc/*release

DISTRIB_DESCRIPTION="Linux Mint 18.2 Sonya"
NAME="Linux Mint"
VERSION="18.2 (Sonya)"
PRETTY_NAME="Linux Mint 18.2"
cat: /etc/upstream-release: Is a directory

$ env
LESSOPEN=| /usr/bin/lesspipe %s
LESSCLOSE=/usr/bin/lesspipe %s %s

My Rsync Local WordPress Backup Examples

Make sure drives are MOUNTED first!

rm -vr –i=no /home/stevee/.cache/google-chrome/Default/Cache/*

mysqldump -u root -p wp > /var/www/quadwp.sql
mysqldump -u root -p DebianAdmin > /var/www/quadDA.sql

Always dry-run with -n first! Check the copy does what it should!!

sudo rsync /var/www/*  /media/stevee/87b55176-f602-48db-ac1c-4fe0101b1a79/www/ -vahn

sudo rsync /* /media/stevee/51800665-dd6d-4c80-adf4-cf8c0061d0be/ –delete-excluded –exclude={dev,media,proc,sys,home/stevee/.*} -vahn

rsync /var/www/* /1500/www/ –delete-excluded -vahn

sudo rsync /var/www/* /media/stevee/WinData/www/ –delete-excluded -vahn

New Mint Install? Want WordPress at Home? Full Steps I Take… 


I PERSONALLY DO ALL THIS POST steps, more or less in order, for a new Mint install, BEFORE MINT UPDATES or Backing up other files to this new install, so I can continue working on the stuff after like file edits, while the first step sudo apt installs in blue, are downloading first (lots!) to get all the functions I require.

All the steps below also enable a full install of your WPress DB at home if you do a full backup from your site that contains the content directories and the database. If you don't want to get involved in the DB side, you "could" always install WP from scratch in Mint, then import your Exported backup xml files (Posts, Pages etc.) using WPs import function and rebuild the site with a different theme for example…more time consuming.

sudo apt-get install ssh nmap vim automake autoconf module-assistant x11vnc nbtscan locate libnss-winbind winbind g++ libcurl3 gparted testdisk hardinfo k3b intel-microcode amd64-microcode sensors-applet totem vlc chromium-browser mysql-server wordpress apache2 libapache2-mod-php php-mbstring vsftpd php-curl php php-mysql

sudo passwd root

sudo smbpasswd -a stevee

vi /etc/samba/smb.conf
path = /media/
writeable = 1
browseable = 1

sudo mkdir /Share
sudo chown stevee.stevee /Share -R

WIFI stuff: modprobe -r iwl3945 iwl4965
modprobe iwl3945 ; modprobe iwl4965

sudo vi /etc/default/grub

GRUB_DISTRIBUTOR=lsb_release -i -s 2> /dev/null || echo Debian

sudo update-grub2

sudo vi /etc/nsswitch.conf
hosts: files wins mdns4_minimal [NOTFOUND=return] dns

sudo vi /etc/apache2/sites-enabled/000-default.conf

DocumentRoot /var/www
Alias "/DebianAdmin" "/var/www/DebianAdmin"

sudo vi /etc/apache2/apache2.conf

ServerName quad
<Directory /var/www>
Options FollowSymLinks
AllowOverride All
Require all granted

sudo service apache2 restart

Assume all wp files are unpacked into /var/www/ (or in a Backup):

Set all dirs/files to replace correct perms from 777 or other wrong install perms:

sudo cp -vr Backup/www    /var/
sudo chown stevee.www-data -R /var/www

sudo find /var/www/ -type d -exec chmod 755 -R {} \;

sudo find /var/www/ -type f -exec chmod 644 {} \;

/var/www/Search-Replace-DB-master $ ./srdb.cli.php -h localhost -n DebianAdmin -u root -p pass -s -r quad

or before DB import – g is global for every occurrence on every line:

sed -i 's/oldURL/newURL/g' quadDA.sql 

Import DB
cp -v Backup/www/*sql /var/www/
ls -l /var/www
mysql -u root -p
show databases ;
create database wp ;
create database DebianAdmin ;
use DebianAdmin ;
source /var/www/quadDA.sql ;
use wp ;
source /var/www/quadwp.sql ;

sudo service mysql restart

Export DB
sudo mysqldump -u root -p DebianAdmin > /var/www/quadDA.sql

sudo apt install vsftpd

sudo vi /etc/vsftpd.conf

# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
# This directive enables listening on IPv6 sockets. To listen on IPv4 and IPv6
# sockets, you must run two copies of vsftpd with two configuration files.
# Make sure, that one of the listen options is commented !!

# Uncomment this to allow local users to log in.

# Uncomment this to indicate that vsftpd use a utf8 filesystem.

sudo service vsftpd restart

for; Call to undefined function mb_regex_encoding()

sudo apt install php-mbstring

stevee@quad ~ $ nmap

Starting Nmap 7.01 ( ) at 2018-01-31 01:47 GMT
Nmap scan report for
Host is up (0.00015s latency).
Not shown: 995 closed ports
21/tcp open ftp

Config your router for ports 21 NAT to your PC IP addr/name so WP can get in/out for plugins, updates etc.:

Index No. 8
Service Name
Public Port 21
Private IP 192.168.1.x?
Private Port xxx

For Optimus:

sudo apt install php-curl

sudo service apache2 restart

Is php installed??

stevee@QuadMint ~ $ which php

sudo apt install php php-mysql

Importing Posts over WP limit – again, search for these lines in vim/nano pressing ":" then paste the line to search for…press N for next for duplicate strings. e.g.

:post_max_size (Rtn)

sudo vi /etc/php/7.0/apache2/php.ini

; Maximum size of POST data that PHP will accept.
; Its value may be 0 to disable the limit. It is ignored if POST data reading
; is disabled through enable_post_data_reading.
post_max_size = 0

; Maximum allowed size for uploaded files.
upload_max_filesize = 20M

sudo service apache2 restart

stevee@quad ~ $ sudo vi /var/www/DebianAdmin/.htaccess

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /DebianAdmin/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /DebianAdmin/index.php [L]

# END WordPress

for Permalink postname failure:

sudo a2enmod rewrite

sudo service apache2 restart

Post Install Mint Sonya 18.2 Additions

Mint 18.3 is now a lot more stable than when I last looked 1 yr back

alias BIGducks='du -cBG * | sort -nr | head -11'
alias duse='for i in G M K; do du -hsx * | grep "[0-9]$i\b" | sort -nr; done'
alias ducks='du -cks * | sort -rn | head -11'
alias bupiquadra='rsync -e ssh –progress /home/stevee/* stevee@bupiquadra:/home/stevee/Quadra/stevee/ –exclude='.' –exclude='Videos' -vah'

Pi3 – Can't Log In To Desktop Except User Pi

Setting to Desktop login for user stevee via raspi-conf then rebooting I cannot login.

The default pi user can though…

Looking at:

sudo vi .Xauthority

It retains the old hostname in MIT magic cookie. Seems there are a few issues with the latest Raspbian Lite eh?

This may also explain the inability to highlight/copy/paste text via SSH also.

Let's delete it, set auto Dtop login via raspi-config, then see if a new one is created on reboot and try again…

Nope – didn't autologin and I still can't login…

sudo vi .xsession-errors

No win managers? That explains a lot!

stevee@pi3:~ $ sudo apt install lightdm

[sudo] password for stevee:
Reading package lists… Done
Building dependency tree
Reading state information… Done
lightdm is already the newest version (1.18.3-1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Already installed – just not working? Already latest dist:

stevee@pi3:~ $ sudo apt dist-upgrade

Reading package lists… Done
Building dependency tree
Reading state information… Done
Calculating upgrade… Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

stevee@pi3:~ $ sudo dpkg-reconfigure lightdm

stevee@pi3:~ $ sudo apt install desktop-base
Reading package lists… Done
Building dependency tree
Reading state information… Done
desktop-base is already the newest version (9.0.2+deb9u1).
desktop-base set to manually installed.

Fuck's sake – this Raspbian Lite – just that! Very Lite on function! But it's still 1.9GB large – same size as Mint install that HAS Cinnamon…what App crap have they filled it with I wonder – over the basics?

They've even removed Ctrl-Alt-Backspace for Xserver respawn! No startx either?? try another DM:

stevee@pi3:~ $ sudo apt install lxde

Just in case it still requires what it said was missing above after…

stevee@pi3:~ $ touch .xsession

stevee@pi3:~ $ sudo reboot

Nope – same…

Let's remove and re-install lightdm:

stevee@pi3:~ $ sudo apt remove lightdm* –purge

stevee@pi3:~ $ sudo apt install light-locker lightdm lightdm-gtk-greeter

stevee@pi3:~ $ sudo raspi-config (Set dtop auto login)
stevee@pi3:~ $ sudo reboot

Nope! As there is a login issue – check security related logs…?

stevee@pi3:~ $ sudo cat /var/log/auth.log | grep fail
Oct 4 23:15:14 piinteg3 login[555]: pam_unix(login:auth): authentication failure; logname=LOGIN uid=0 euid=0 tty=/dev/tty1 ruser= rhost= user=stevee
Oct 5 16:40:30 piinteg3 login[555]: FAILED LOGIN (1) on '/dev/tty1' FOR 'stevee', Authentication failure

There is the retention of the old device name again as was in /etc/hosts for the wifi Post!

As it's PAM db related I'll add my user using:

stevee@pi3:~ $ sudo pdbedit -a stevee
new password:
retype new password:
Unix username: stevee
NT username:
Account Flags: [U ]
User SID: S-1-5-21-4262368663-1680611761-3889941877-1000
Primary Group SID: S-1-5-21-4262368663-1680611761-3889941877-513
Full Name:
Home Directory: \\pi3\stevee
HomeDir Drive:
Logon Script:
Profile Path: \\pi3\stevee\profile
Domain: PI3
Account desc:
Munged dial:
Logon time: 0
Logoff time: never
Kickoff time: never
Password last set: Sun, 08 Oct 2017 23:30:24 BST
Password can change: Sun, 08 Oct 2017 23:30:24 BST
Password must change: never
Last bad password : 0
Bad password count : 0

stevee@pi3:~ $ sudo reboot

Looking at tail syslog via SSH while logging in locally all I see of possible relevance is:

Oct 8 23:34:16 pi3 systemd[1]: Created slice User Slice of lightdm.
Oct 8 23:34:16 pi3 systemd[1]: Starting User Manager for UID 109…
Oct 8 23:34:16 pi3 systemd[1]: Started Session c9 of user lightdm.
Oct 8 23:34:16 pi3 systemd[1278]: Starting D-Bus User Message Bus Socket.
Oct 8 23:34:16 pi3 systemd[1278]: Reached target Paths.
Oct 8 23:34:16 pi3 systemd[1278]: Listening on GnuPG cryptographic agent and passphrase cache.
Oct 8 23:34:16 pi3 systemd[1278]: Listening on GnuPG cryptographic agent and passphrase cache (restricted).
Oct 8 23:34:16 pi3 systemd[1278]: Listening on GnuPG cryptographic agent (ssh-agent emulation).
Oct 8 23:34:16 pi3 systemd[1278]: Reached target Timers.
Oct 8 23:34:16 pi3 systemd[1278]: Listening on GnuPG cryptographic agent (access for web browsers).
Oct 8 23:34:16 pi3 systemd[1278]: Listening on D-Bus User Message Bus Socket.
Oct 8 23:34:16 pi3 systemd[1278]: Reached target Sockets.
Oct 8 23:34:16 pi3 systemd[1278]: Reached target Basic System.
Oct 8 23:34:16 pi3 systemd[1278]: Reached target Default.
Oct 8 23:34:16 pi3 systemd[1278]: Startup finished in 80ms.
Oct 8 23:34:16 pi3 systemd[1]: Started User Manager for UID 109.
Oct 8 23:34:16 pi3 systemd[1278]: Started D-Bus User Message Bus.
Oct 8 23:34:16 pi3 org.a11y.atspi.Registry[1295]: SpiRegistry daemon is running with well-known name – org.a11y.atspi.Registry
Oct 8 23:34:16 pi3 dbus-daemon[1293]: Activating via systemd: service name='org.gtk.vfs.Daemon' unit='gvfs-daemon.service'
Oct 8 23:34:16 pi3 systemd[1278]: Starting Virtual filesystem service…
Oct 8 23:34:16 pi3 dbus-daemon[1293]: Successfully activated service 'org.gtk.vfs.Daemon'
Oct 8 23:34:16 pi3 systemd[1278]: Started Virtual filesystem service.

It's not an auth/password issue as I get a warning with a login with an incorrect password, so user auth is ok, but next required service for user stevee won't allow access.

Rebooting to user stevee auto console login is ok, and running:

sudo lightdm –test-mode

Warning: Failed……blah

Try installing MATE…

Fuck this…Make do with pi login for now to view FAware..