How to boot Parted Magic 2018 using PXE and NFS support!

Avoid the Gates of Hell. Use Linux

How to boot Parted Magic 2018 using PXE and NFS support!

Ahoy friends.

I’m a convinced user of Parted Magic, but now i wanted to use it on my GRUB PXE server.

Unfortunately it was very slow because of lack of nfs support.

So i was searching for a solution and got the following idea.

I was able to boot Parted Magic using PXE but unfortunately it was really really slow, because the files are transfered by the TFTP protocoll only which is the slowest of all available options.

 

Why is there no nfs support and what it’s the cause?

The drivers which are necessary to boot a system are included in the initial ramdisk file, usually just called initrd.

In case of Parted Magic the drivers which are needed for a boot from a nfs root, or fetching a squashfs file, are not included.

So there is no easy way to get rid of it. Take care! Only for advanced users who know what they are doing.

 

Get NFS support for Parted Magic PXE

I have chosen the easy way, to get the Kernel file of an system which already supports NFS boot.

So Clonezilla was my option. It offers NFS root support as well as networking to fetch squashfs files by using http.

My first try was to replace the bzImage64 file from Parted Magic by the vmlinuz Kernel image of Clonezilla.

This didn’t work well, because of following problem.

Inside of the init file the Parted Magic initrd uses a different way to deal with paths. In this case it looks like this.

export PATH="/bin:/sbin:/usr/bin:/usr/sbin"

But in case of Clonezilla they look like that.

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

So there’s a difference. But now after all it works like i wanted it to work.

How to get rid of this Problem?

 

Get The newest Clonezilla image from https://clonezilla.org/downloads.php

After having downloaded the iso (!) file mount it on /mnt using

mount clonezilla.iso /mnt

Unpack the initrd file into a new working directory.

First, create a temporary work directory and switch into it. This will be the location where the initramfs/initrd contents will be viewed, edited, and re-compressed if required.

mkdir /tmp/initrdclonezilla

First we need to check out which kind of compression our initrd file uses.

So we use:

file /mnt/live/initrd.img
  • In case of a gzip file we switch into the newly working directory and use
    zcat /mnt/live/initrd.img | cpio -idmv
  • However, if the file is using xz compression you have to use this command.
    xz -dc < /mnt/live/initrd.img | cpio -idmv

To uncompress the initrd file.

Now we only care about the init file, let’s open it.

The first line is important, the part dealing with the paths.

#!/bin/sh

# Default PATH differs between shells, and is not automatically exported
# by klibc dash. Make it consistent.
# Furthermore, this PATH ends up being used by the init, set it to the
# Standard PATH, without /snap/bin as documented in
# https://wiki.ubuntu.com/PATH
# This also matches /etc/environment, but without games path
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

That’s the way how Clonezilla deals with paths, but we need to know how Parted Magic does.

So we need to do the same for the Parted Magic ISO file.

First we have to unmount the current Clonezilla ISO using

umount /mnt

We’ll mount our Parted Magic ISO using the same way like we did before.

mount pmagic_2018_01_08.iso /mnt

We’ll create another working directory for our Parted Magic initial ramdisk file.

mkdir /tmp/initrdpmagic

Let’s switch into the newly created directory using cd (i won’t mention this simple command here.)

So now we want to uncompress the Parted Magic initrd file as well, it’s called initrd.img as well.

To check out which command to use, to uncompress the file, check out our previous steps.

In this case we should have a gzip compressed initrd file, so we use:

zcat /mnt/initrd.img | cpio -idmv

Here we check out our init file as well, also the first line like we did before.

Now you should notice some difference, it should look like that.

export PATH="/bin:/sbin:/usr/bin:/usr/sbin"

So what now? We will just take this like and replace it by the old one in the Clonezilla init file.

After having done this part just save the Clonezilla init file.

Now we have to compress our newly created initrd file.

Just switch into the initrdclonezilla working directory and perform this command.

find . | cpio -o -c | gzip -9 > /home/new.img

Now we have got a new initrd deploying NFS root support.

So in case of our PXE Parted Magic directory we replace the existing bzImage64 file by vmlinuz file from Clonezilla.

And also our initrd.img file from Parted Magic will be replaced with our newly created new.img initrd file. But don’t forget to rename it to initrd.img.

Because of the difference of Clonezilla how to deal with squashfs files, we need to copy the SQFS file from our currently mounted Parted Magic ISO.

We need to create a directory called live inside of our Parted Magic PXE directory.

Now we copy the SQFS file into this directory doing:

cp /mnt/pmodules/2018*.SQFS /var/lib/tftpboot/programs/pmagic/live

Note: You may have to adjust the paths in your case. Common sense is necessary!

 

Now your grub.cfg or default file (in case of pxelinux) may look like this.

menuentry "Parted Magic (64-Bit)" {
echo 'Trying to boot via nfs ...'
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
echo 'Loading Linux ...'
linux /programs/pmagic/bzImage64 root=/dev/nfs ip=dhcp rw netboot=nfs nfsroot=192.168.2.55:/var/lib/tftpboot/programs/pmagic/ nomodeset rw boot=live username=user union=overlay config components noswap
fetch=http://192.168.2.55/pmagic/live/filesystem.squashfs
initrd /programs/pmagic/initrd.img
echo 'Loading initial ramdisk ...'
}

That’s just all you have to do to get Parted Magic booting properly on PXE systems.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.