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 files are not booted into so hangs, and I found that using command line fdisk to create a new empty DOS partition first, then rebooting solves the issue.

e.g.

sudo fdisk /dev/sda

You can then use Garted to do the other ops like partition, format and set a boot flag, before copying the Win install files to the drive and booting into it.

See the original Post here:

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

 

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 depending..it 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 from USB 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 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 workingsystem 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!:

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

stevee@QuadMint ~ $ cat /etc/*release

DISTRIB_ID=LinuxMint
DISTRIB_RELEASE=18.2
DISTRIB_CODENAME=sonya
DISTRIB_DESCRIPTION="Linux Mint 18.2 Sonya"
NAME="Linux Mint"
VERSION="18.2 (Sonya)"
ID=linuxmint
ID_LIKE=ubuntu
PRETTY_NAME="Linux Mint 18.2"
VERSION_ID="18.2"
HOME_URL="http://www.linuxmint.com/"
SUPPORT_URL="http://forums.linuxmint.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/linuxmint/"
VERSION_CODENAME=sonya
UBUNTU_CODENAME=xenial
cat: /etc/upstream-release: Is a directory

$ env
XDG_VTNR=7
SSH_AGENT_PID=1339
XDG_SESSION_ID=c1
XDG_GREETER_DATA_DIR=/var/lib/lightdm-data/stevee
QT_STYLE_OVERRIDE=gtk
TERM=xterm-256color
SHELL=/bin/bash
VTE_VERSION=4205
QT_LINUX_ACCESSIBILITY_ALWAYS_ON=1
GJS_DEBUG_OUTPUT=stderr
WINDOWID=83887126
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
GTK_MODULES=gail:atk-bridge
USER=stevee
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
QT_ACCESSIBILITY=1
XDG_SESSION_PATH=/org/freedesktop/DisplayManager/Session0
XDG_SEAT_PATH=/org/freedesktop/DisplayManager/Seat0
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
SESSION_MANAGER=local/QuadMint:@/tmp/.ICE-unix/1175,unix/QuadMint:/tmp/.ICE-unix/1175
DEFAULTS_PATH=/usr/share/gconf/cinnamon.default.path
XDG_CONFIG_DIRS=/etc/xdg/xdg-cinnamon:/etc/xdg
PATH=/home/stevee/bin:/home/stevee/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
DESKTOP_SESSION=cinnamon
QT_QPA_PLATFORMTHEME=qgnomeplatform
XDG_SESSION_TYPE=x11
PWD=/home/stevee
LANG=en_GB.UTF-8
GDM_LANG=en_GB
MANDATORY_PATH=/usr/share/gconf/cinnamon.mandatory.path
GDMSESSION=cinnamon
CINNAMON_VERSION=3.4.6
XDG_SEAT=seat0
HOME=/home/stevee
SHLVL=1
LANGUAGE=en_GB:en
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
GTK_OVERLAY_SCROLLING=1
XDG_SESSION_DESKTOP=cinnamon
LOGNAME=stevee
XDG_DATA_DIRS=/usr/share/cinnamon:/usr/share/gnome:/usr/local/share/:/usr/share/
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-FikLZYVc4d,guid=ed321c4786066f00c1ac24805a747460
LESSOPEN=| /usr/bin/lesspipe %s
XDG_RUNTIME_DIR=/run/user/1000
DISPLAY=:0
XDG_CURRENT_DESKTOP=X-Cinnamon
LESSCLOSE=/usr/bin/lesspipe %s %s
XAUTHORITY=/home/stevee/.Xauthority
_=/usr/bin/env

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… 

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
[homes]
[MountedDrives]
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_TIMEOUT=10
GRUB_DISTRIBUTOR=lsb_release -i -s 2> /dev/null || echo Debian
GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""

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
</Directory>

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 stevepedwards.com -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 ;
exit

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.
listen=YES
#
# 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 !!
#listen_ipv6=YES

# Uncomment this to allow local users to log in.
local_enable=YES

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

sudo service vsftpd restart

for; Call to undefined function mb_regex_encoding()

sudo apt install php-mbstring

stevee@quad ~ $ nmap 192.168.1.11

Starting Nmap 7.01 ( https://nmap.org ) at 2018-01-31 01:47 GMT
Nmap scan report for 192.168.1.11
Host is up (0.00015s latency).
Not shown: 995 closed ports
PORT STATE SERVICE
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
Enable
Mode
Service Name
Protocol
WAN IP
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
/usr/bin/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.
; http://php.net/post-max-size
post_max_size = 0

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
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]
</IfModule>

# 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

2 sudo apt update
3 sudo apt upgrade
4 sudo locale-gen –purge –no-archive
7 sudo apt-get install k3b
8 sudo vi /etc/nsswitch.conf
9 sudo smbpasswd -a stevee
10 sudo vi /etc/samba/smb.conf
11 ssh-keygen
12 nbtscan 192.168.1.0/24
13 ssh-copy-id -i ~/.ssh/id_rsa.pub PIQUADRA
16 sudo vi /etc/default/grub
17 sudo update-grub2
18 inxi -Fxz
19 sudo passwd root
20 sudo sensors-detect
21 cat /proc/cpuinfo
22 sudo apt-get remove thunderbird* –purge
23 sudo apt-get install ssh nmap vim automake autoconf module-assistant nbtscan locate libnss-winbind winbind g++ libcurl3 gparted testdisk hardinfo
24 sudo reboot

vi .bash_aliases

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:
Workstations:
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
Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

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…GDBus.Error:org.free.desktop…blah

Try installing MATE…

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