Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
DEAL: For $25 - Add A Second Phone Number To Your Smartphone for life! Use promo code SLASHDOT25. Also, Slashdot's Facebook page has a chat bot now. Message it for stories and more. Check out the new SourceForge HTML5 internet speed test! ×
User Journal

Journal Journal: Linux PXE server P2V: Debian Testing + Vmware Workstation 11

Keeping older hardware useful:
P2V and V2P with an old Debian Testing PXE server and Vmware Workstation 11
By Dave Bechtel / Kingneutron

MARCH 2017 â" so I've had an old PXE server (an âoeASUS S-pressoâ - Pentium-4, 32-bit portable box) sitting around for the last few years, and got a wild hair to do a P2V on it â" make sure it still works right and test an upgrade of Debian Testing to modern standards. Last time this box was booted was November 2013 â" and it was provisioned with Dreamlinux 5 back in January of 2012.

--Thankfully, the SATA drive and CMOS battery have survived with apparently no ill effects, since the box has been moved around through a couple of house changes with no special storage arrangements â" it's basically been unpowered sitting in a corner.

( My unit has a PCI slot on the right that has a Gig Ethernet card in it, and an unused AGP video card slot on the left. Motherboard only supports 100Mbit Ether. )

--Rather than using the antiquated PS/2 ports, I used an adapter to combine a USB keyboard and mouse into (1) USB port.

STEP 1: BACKUP the physical PC

--This box is so old, I had to install fsarchiver (my preferred backup) manually. Incidentally, it's also heavy as hell with a DVD drive and a standard SATA hard drive, so removing the DVD and converting to an SSD (or laptop drive) to save weight would be recommended if I wanted to haul it around.

(Physical box, bash shell, as root)
# apt-get update; apt-get install fsarchiver

# ddir=/mnt/extra
# outfile=spresso-p2v-backup-20170302.fsarchive.fsa
# rootdev=/dev/sda3

# time fsarchiver -o -A -z 1 -j 2 savefs \
    $ddir/$outfile \
    $rootdev

# cd $ddir
# fsarchiver archinfo $outfile 2> flist--$outfile.txt

--I then copied âoespresso-p2v-backup-20170302.fsarchive.fsaâ to my ZFS server (method omitted), since we will need it later for the restore.

--Also, since all of my Squid cache and ISO files for PXE are on /mnt/extra, I made a tar backup of those to my ZFS server.

# cd /mnt/extra
# time tar czpf /mnt/bkpspace/spresso-mnt-extra-bkp-20170302.tgz *

-------------

STEP 2: Setup the P2V VM in Vmware Workstation 11 and restore the backup

--I tried as much as possible to duplicate the physical box, but in this case I already had a P2V VM of my daily workstation (Ubuntu 14.04) that I wasn't using, so adding a 3rd virtual drive to the existing VM and re-using the existing GRUB saved me some steps. Running ' update-grub ' on the Ubuntu side after restoring enabled me to boot my restored environment.

VM details:

RAM: 1.5GB
Processors: 1
SCSI1: 23.5GB (this is the Ubuntu drive)
SCSI2: 20GB ( this is /home and swap )
SCSI3: added as new and then Expanded from 10GB to 60GB (after running out of space)

Net1: Bridged (gets DHCP address from my LAN)
Net2: Started out as Host-only and ended up as LAN Segment â" this enabled the âoeclientâ bare VM to boot over the network.

--I used Systemrescuecd to boot the VM, issued ' startx ' and used ' gparted ' to make 2 partitions that fairly closely matched my physical layout.

PROTIP: In hindsight, I should have made the root partition around 15-20GB because of all the package upgrades that needed to be downloaded. (I ran out of space on root once during the upgrade and had to issue an ' apt-get clean ' to free up space.)

sdc3: 10GB ext4 (restored root) â" make yours bigger.
sdc4: 50GB ext4 (/mnt/extra)

PROTIP: ' tune2fs -m1 /dev/sdc3 ' -- this will reduce the reserved space for ext4 and give you some extra usable free space.

--Now, since I had plenty of space to work with, I copied my fsarchive backup file from my ZFS server to the 50GB VM partition.

(still in Systemrescuecd, in the VM)

# mkdir /mnt/tmp
# mount /dev/sdc4 /mnt/tmp
# cd /mnt/tmp

# ifconfig # Make note of my IP address
# nc -l -p 32100 |tar xpvf -
##Netcat - Listen on port 32100 and untar

(Now on my ZFS server)
# tar cpf - spresso-p2v-backup-20170302.fsarchive.fsa |nc -w 5 192.168.1.95 32100
## (tar to stdout and stream a copy of the backup file to the VM's IP address)

--This is basically a quick-and-dirty way to transfer files over the network without resorting to FTP or slow SSH file copies â" the fsarchive backup file ended up being around 3GB and transferred in less than a minute over Gig Ethernet.

--Now to restore the backup:

(still in Systemrescuecd, in the VM)
# time fsarchiver restfs spresso*.fsa id=0,dest=/dev/sdc4

--And that's half the battle right there. Now we just need to make some changes to the restored /etc/fstab so it will boot. ( If we were doing a full migration, we would also need to adjust things like /etc/network/interfaces , /etc/rc.local , /etc/hostname , /etc/hosts )

--For completeness, here's more info on how to do a Linux bare-metal backup and restore:
http://crunchbang.org/forums/viewtopic.php?id=24268

--So now I ' reboot ' into the VM's already-installed Ubuntu 14.04 and edit my Dreamlinux /etc/fstab.

# mkdir /mnt/tmp
# mount /dev/sdc3 /mnt/tmp

# screen -aAO # PROTIP: GNU screen is invaluable for switching between virtual terminal windows

# fdisk -l # check out our disks
# blkid # get partition labels and UUIDs /dev/sdb2: LABEL="swapb" UUID="f0eb7148-4ff2-4eeb-a82c-349d384a5255" TYPE="swap" PARTUUID="ff1ca075-02" /dev/sdc3: LABEL="root" UUID="38f1d4be-3293-4272-ab79-4ad76cbd5a36" TYPE="ext4" PARTUUID="3a3b65f3-03" /dev/sdc4: LABEL="extra" UUID="603a61fc-4436-4cb0-baac-ef9170754228" TYPE="ext4" PARTUUID="3a3b65f3-04"

--NOTE that fsarchiver will by default restore the same UUID and filesystem label, so no worries.

( Now Hit Ctrl-A, then c to create a new Screen )

# cd /mnt/tmp/etc
# jstar fstab # use your own editor here, I happen to like Wordstar key bindings ;-)

--Now we can switch between those 2 virtual terminal windows and even copy/paste text without using the mouse. See ' man screen ' for more details.

--To make a long story short, I added or verified the following to SpressoVM's /etc/fstab to enable my existing swap partition and double-check that the root filesystem would be mounted as expected.

LABEL=swapb none swap sw,pri=2 0 0
LABEL=extra /mnt/extra ext4 defaults,noatime,rw 0 2

--While I'm here, I also restored the /mnt/extra files from their tar backup as well.

# umount /mnt/tmp # we're done with restored root

# mount /dev/sdc4 /mnt/tmp
# cd /mnt/tmp
# nc -l -p 32100 | tar xzpvf -

( then on my ZFS Server )

# cd /mnt/bkpspace; time cat spresso-mnt-extra-bkp-20170302.tgz |nc -w 5 192.168.1.95 32100

( now back in the VM )

# update-grub # make sure ubuntu knows how to boot dreamlinux
# reboot

--And that's pretty much it. After that, to make a long story short, I went through several cycles of
' apt-get upgrade ' and ' apt-get dist-upgrade ' making VM Snapshots along the way, and had to make allowances for files that were provided in more than one package.

--I also upgraded the kernel from 3.10-3-686-pae to linux-image-4.9.0-1-686. The full saga is documented with errors and fixes, so email me if you want to know more (but it's a pretty long read.)

# apt-cache search 4.9.0 |awk '{print $1}'

# apt-get install linux-headers-4.9.0-1-686 linux-headers-4.9.0-1-686-pae linux-headers-4.9.0-1-all \
linux-headers-4.9.0-1-common linux-support-4.9.0-1 linux-image-4.9.0-1-686-pae

STEP 3: Test PXE booting with another VM using a dedicated network segment

--The end result of all this: I created a âoeblankâ VM with the capability to boot from network (needed to modify the VM's BIOS for this) and after switching the 2nd network adapter to âoeLAN segmentâ I successfully booted the VM from PXE! Mission Accomplished!
--Now, since I've done all the heavy lifting in the VM and my original box is still working the same as it was (but running old software) I can use pretty much the same procedure to do a V2P (Virtual to Physical) to a spare 500GB laptop drive instead of having to repeat the upgrade all over again.

--For brevity, these are the instructions I include in my bkpsys-2fsarchive script:

# time fsarchiver restfs backup-root-sda1--ubuntu1404*.fsa id=0,dest=/dev/sdf1
Statistics for filesystem 0
* files successfully processed:....regfiles=159387, directories=25579, symlinks=49276, hardlinks=25, specials=108
* files with errors:...............regfiles=0, directories=0, symlinks=0, hardlinks=0, specials=0
real 4m26.116s
( 3.9GB )

# mkdir /mnt/tmp2
# mount /dev/sdf1 /mnt/tmp2

# grub-install --root-directory=/mnt/tmp2 /dev/sdf
# mount -o bind /dev /mnt/tmp2/dev; mount -o bind /proc /mnt/tmp2/proc; mount -o bind /sys /mnt/tmp2/sys
# chroot /mnt/tmp2 /bin/bash
# update-grub
[[
Generating grub configuration file ...
Warning: Setting GRUB_TIMEOUT to a non-zero value when GRUB_HIDDEN_TIMEOUT is set is no longer supported.
Found linux image: /boot/vmlinuz-4.2.0-36-generic
Found initrd image: /boot/initrd.img-4.2.0-36-generic
Found linux image: /boot/vmlinuz-3.19.0-25-generic
Found initrd image: /boot/initrd.img-3.19.0-25-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found Ubuntu 14.04.4 LTS (14.04) on /dev/sda1
done
]]

# grub-install /dev/sdf # from chroot

^D
# umount -a /mnt/tmp2/*

# DON'T FORGET TO COPY /home and adjust fstab for swap / home / squid BEFORE booting new drive!
# also adjust etc/network/interfaces , etc/rc.local , etc/hostname , etc/hosts

--Once I had Knoppix up and running in the âoeblankâ VM, I used ' gparted ' to make a 768MB Swap partition and used the rest as a âoedataâ ext4 partition.

--NOTE that while the PXE boxes are running a 32-bit processor and environment, CLIENT boxes can boot a 64-bit kernel and environment as long as the CLIENT processor is capable.

STEP 4: Reverse the process and upgrade the physical box

--I haven't done the âoeV2Pâ part yet, but that's not a high priority at this point since I have everything pretty much the way I like it right now.

User Journal

Journal Journal: Holy Cow Apple are Total Fucks 6

So I'm playing with this antique iMac because whee shit and I'm trying to download the 1GB developer tools DMG and Apple sure makes it a gigantic pain in the arsehole, don't they? You can't just download the URL with wget without rigamarole which I haven't gone through yet. I can't actually load the site in Safari at all because of some kind of https error. And my download just failed somehow in the last seconds, which means I get to download it all over again. And then it may fail again. Other downloads are working fine, it's just Apple that's incompetent here somehow.

This is the kind of thing that convinces me that anyone who gives Apple money is either a moron or a masochist. Luckily, I got this machine for free, so all I'm wasting is time.

User Journal

Journal Journal: No more /. subscriptions? 2

I realized that I had not topped up my /. subscription in some time and went to do so. Saw this:

"Please Note: Buying or gifting of a new subscription is not available
at the moment. We apologize for the inconvenience. This downtime though
does not effect your current active subscription in any way. We will
keep you posted on the latest"

Any idea what's going on? Are they sticking to a pure ad model (all blocked anyhow, but I did like to subscribe as I like the ol' barn.)

User Journal

Journal Journal: Best simple SID to USB connection? 3

That may not be a good way to describe it but... I have a C64 I never use and I think I shall desolder its SID before consigning it to recycling since they are now officially hard to come by. What can I put it on that will let me use it efficiently?

User Journal

Journal Journal: The lameness filter is broken (again) 13

Your comments "spectacularly brain-damaged suggestion" and "drug-fueled" are why I consider your post troll like.

The above quote rendered one of my comments unpostable...

User Journal

Journal Journal: HOWTO safe rm in Linux 1

--HOWTO safe rm on Linux (at least):

- Interactive:
o Use Midnight Commander. Works from a text terminal, no GUI needed.
Insert to mark files/dirs, F8 to delete. Never had a misfire, even as root.

- Script (for the paranoid, and want a log):
IF you have a known dir " destdir=/tmp/blah " with a subdir " /tmp/blah/1 "
$ cd $destdir && cd 1 && cd .. && rm -rv 1/* |tee /tmp/rm.txt

- REALLY safe rm, with find:
# find multiple (known) names of files > 40 days old in a given directory and delete them
bkpath="/mnt/bkpdrive"
pathh="$bkpath/work/bkpsys-laptop-p2400-thinkpad-xubuntu-14-04-LTS--64--sda7"
cd $pathh && \
        find $pathh/* \( -name "bkp*gz" -o -name "bkp*bz2" -name "bkp*lzop" -o -name "flist*" \) -type f -mtime +40 -exec /bin/rm -v {} \;

--If you need to delete multiple levels of subdirectories, or dotfiles -- do it interactively, and use MC.

User Journal

Journal Journal: Best Foakleys? 5

Surely someone around here knows where's the best slightly-reputable site to buy some knockoffs of the Oakley M2 XLs. I want to try them out for a while and see how they feel on my head. The sites I've found so far are registered straight outta China. Oakley has successfully driven the fakes off eBay and Amazon... the problem is, I'm not going to drop two hundred bucks on some glasses that might give me a headache, like most glasses do.

User Journal

Journal Journal: Apple ID being used for harassment and ID theft 9

Apple is now actively, willingly, and deliberately aiding in online harassment and identity theft against me. They refuse to destroy an Apple ID which has been created with my email address, to which I do not have the answers to the "secret questions". They will not permit me to proceed any further without having an attorney.

What do I do now? Who do I call for relief? I can't afford a legal battle with Apple. I don't have an attorney on retainer.ï

User Journal

Journal Journal: Vroom.

Finally, I got my A8 Quattro up to the point where I could get it smogged. Registration and rubber to follow imminently. Crap, this thing is quick.

User Journal

Journal Journal: Punitive Between-Comment delay? 4

I have Excellent karma, as usual, but I have a five minute delay between my posts. It seems to have appeared on my account again after the last time I said something mean about a Slashdot "editor". Is this something that Slashdot has done to everyone recently, or is it a punitive action against me specifically by one of the "editors"?

User Journal

Journal Journal: Why libressl is stupid 2

I really want to like libressl. But it pretends to be openssl badly. They refused a patch that would have mitigated this whole RAND_egd problem by simply returning that it doesn't work when someone tries to use it, which means that you commonly need a patch to use it at all. If it's not going to work like openssl, then it shouldn't occupy the same space in the filesystem.

User Journal

Journal Journal: OMFG GNOME3 is asstacular

This is not news to most people, but I just tried it for the first time on my first-ever normal Debian Wheezy install (I've always done minimal, netinst etc. and built it up from there for a purpose) and wow, GNOME3 is amazingly horrible. It makes Unity look usable. If that was the idea, mission accomplished, I guess.

Slashdot Top Deals

Usage: fortune -P [-f] -a [xsz] Q: file [rKe9] -v6[+] file1 ...

Working...