Git Product home page Git Product logo

antonio-petricca / buddy-linux Goto Github PK

View Code? Open in Web Editor NEW
24.0 4.0 2.0 92 KB

Do you remember "Wubi Ubuntu Installer"? This project is both a replacement and an improvement of Wubi. You will be able to install your Debian (or derived) distribution on a PC without repartitioning it, simply by using a secondary/external boot device (like a USB drive).

License: GNU General Public License v3.0

Shell 100.00%
linux dracut initramfs loopback wubi usb-drive grub grub2 boot-partition shutdown

buddy-linux's Introduction

Buddy Linux

Introduction

Do you remember Wubi Ubuntu Installer?

This project is both a replacement and an improvement of Wubi, obviously with its pros and cons.

You will be able to install your Debian or derived distribution (I have used Linux Mint Mate 18.3 64 bit) on a PC without repartitioning it, simply by using a secondary/external boot device.

PROs

  • The Grub 2 bootloader can be installed on any device partition, external or internal.
  • You can host your loopback device files on any partition type, not only on NTFS ones.
  • Loopback device files partecipate to a LVM physical volume cluster, so after a successfully installation, you can increase your logical volume size as you need (by booting with any Linux Live Distribution to extend it).
  • Dracut can be choosen (it is the default one) as initramfs infrastructure. By its implementation of the Systemd Shutdown process the loopback devices are safely released without any data loss.
  • Your OS can be upgraded to all future distributions (Wubi were pinned on a not upgradable Ubuntu release).

CONs

  • A bit of Linux knowledge is required to follow instructions.

Pre-requisites

  • Boot from a Live Ubuntu or derived distribution.
  • Insert a USB drive for bootloader, then umount it (if you want to boot from an external device).

Clone repository

sudo apt-get install git

git clone https://github.com/antonio-petricca/buddy-linux.git
cd buddy-linux

Become friend of the install script

The automated install script will guide you through the whole setup process.

You should simply follow the instructions provided by it. Even if something will go wrong, due to an error or by a negative answer to some question, you can resume the setup from the line number printed out by the script (--resume).

Here is the parameteres list...

install [OPTIONS]

    Executive arguments:

      -h | --help                   : this screen.
      -c | --clean                  : clean already performed steps.
      -r | --resume                 : resume execution from a given line number.

    Mandatory arguments:

      -b | --boot-device            : boot (USB) device (eg: /dev/sdc).
      -u | --host-uuid              : loop files host device UUID (got by blkid).
      -f | --host-fs-type           : host device filesystem type (default: "ntfs-3g").
      -s | --loopback-file-size     : loopback main file size (in Gigabytes).
      -w | --swap-file-size         : swap file size (in Gigabytes).

    Optional arguments:

      -g | --boot-device-grub-index : boot device grub index (eg: 0 for '(hd0,msdos1)'; default: 0).
      -p | --boot-partition-index   : boot partition index (default: 1).
      -i | --initrd-tool            : InitRD tools => 1 = initramfs-tools, 2 = dracut (default: 2).
      -o | --host-fs-options        : host device filesystem options (default: "noatime").
      -d | --loops-dir              : host device loopback files root relative folder (default: ".linux-loops").
      -v | --volume-group-name      : volume group name (default: "vg_system").
      -l | --logical-volume-name    : root logical volume name (default: "lv_root").

An example is worth a thousand words

Suppose we want to take advantage of Linux on our company notebook equipped with Windows that we absolutely cannot repartition.

For the same reason we cannot make a dual boot system.

We have to gather some information to pass to install script, so...

Get the UUID of the host disk

The host disk is the notebook internal drive partition where we want to create the (first) loopback file where we will install our Linux.

$ sudo blkid | grep -i ntfs

/dev/sda1: LABEL="ESP" UUID="E00C-5421" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="fb4ed2b9-80ee-4585-ba9a-98ad5fff9577"
/dev/sda2: LABEL="DIAGS" UUID="6C3A-F782" TYPE="vfat" PARTLABEL="Basic data partition" PARTUUID="90215d40-b38b-4491-b8da-0aa0b1e49f22"
/dev/sda4: LABEL="WINRETOOLS" UUID="4CE43CC1E43CAED8" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="9153f739-1837-4e62-94f7-0c303920be7b"
/dev/sda5: LABEL="OS" UUID="C69E53819E536947" TYPE="ntfs" PARTUUID="1f2bc4d8-3919-4bd1-8d7f-14a16f1ea89e"
/dev/sda6: UUID="FCD2CC27D2CBE3CC" TYPE="ntfs" PARTUUID="2a28eaa5-f129-4a31-a0a2-71bbb25a1cf0"
/dev/sda7: LABEL="PBR Image" UUID="FCACE750ACE7044C" TYPE="ntfs" PARTLABEL="Microsoft recovery partition" PARTUUID="b4df6e39-9c55-4eb5-a374-113026760c60"

/dev/sda5 is what we are searching for, so the UUID is C69E53819E536947.

Get the (USB) drive device name

The USB drive is the disk where Grub will be installed and that will host the boot partition (/boot).

So,

$ lsblk

NAME                MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sdb                   8:16   1   7,5G  0 disk
└─sdb1                8:17   1  1000M  0 part /media/817697da-efa5-49da-baeb-ca175d9b587b
sda                   8:0    0 931,5G  0 disk
├─sda4                8:4    0   750M  0 part
├─sda2                8:2    0    40M  0 part
├─sda7                8:7    0     7G  0 part
├─sda5                8:5    0 922,7G  0 part
├─sda3                8:3    0   128M  0 part
├─sda1                8:1    0   500M  0 part
└─sda6      8:6    0   459M  0 part

$ sudo umount /dev/sdb1

Thus, /dev/sdb will host the Grub bootloader, and /dev/sdb1 the boot partition (--boot-partition-index 1).

Define the remaining parameters

Our notebook is equipped with a 1 Tb SATA disk (formatted as NTFS) and 8Gb of RAM, so we choose:

  • 250 Gb for the (first) loopback device file.
  • 16 Gb for the swap file (2 x installed RAM).
  • ntfs-3g file system type.
  • Dracut as initramfs infrastructure (better shutdown process handling).

Run the install script

Is time to go...

$ sudo ./install  \
  --host-uuid C69E53819E536947 \
  --boot-device-grub-index 0 \
  --boot-device /dev/sdb \
  --boot-partition-index 1 \
  --host-fs-type ntfs-3g \
  --loopback-file-size 250 \
  --swap-file-size 16

Pay much attention to the Ubiquity step and at parameter --boot-device-grub-index (which usually should left at default value, depending on your hardware layout), then enjoy with your Linux setup!

Disaster recovery

Using your buddy linux, the boot drive, especially if it is a USB device, may fail, so you should have a valid restorable backup.

Backup your boot drive

The boot-drive-backup script provides you a simple script to backup your boot device into a tar.xz file. That file can be restored by the script boot-drive-restore.

Here is a simple usage example:

$ ./boot-drive-backup

boot-drive-backup [Compressed boot image file basename]

$ sudo ./boot-drive-backup ${HOME}/Dropbox/my-boot-drive

It will create a file named my-boot-drive.tar.xz (e.g. which you can store on DropBox or preferred cloud), that you may provide to boot-drive-restore to restore your boot drive, or clone a new one.

Restore drive

In order to restore the boot drive onto the currently mounted boot device, please look at the following example:

$ ./boot-drive-restore

boot-drive-restore [Boot device] [Boot partition mount point] [Boot image compressed file name]

So, using then data gathered from the installation example, and assuming our backup file is ${HOME}/Dropbox/my-boot-drive.tar.xz, we should restore our boot device by running this command:

$ ./boot-drive-restore /dev/sdb /boot ${HOME}/Dropbox/my-boot-drive.tar.xz

Clone / Create a backup boot device

A bit more tricky, but more useful, is to create a backup boot device.

It may be accomplished by following the following rules:

  • Take a new (USB) drive.
  • Destroy all partitions (e.g. by GParted).
  • Create a new, at least 512Mb size, ext4 partition.
  • Flag it as BOOTable (else you will get an "Invalid partition table" warning at boot time that you may skip by pressing ESC key).
  • If you wish, partition remaining space as you need (for other use cases).

Now run the boot-drive-restore script as follow (assuming that the backup device maybe /dev/sdc, mounted on /media/my-2nd-boot-drive):

$ sudo ./boot-drive-restore /dev/sdc /media/my-2nd-boot-drive ${HOME}/Dropbox/my-boot-drive.tar.xz

...

$ sudo umount /media/my-2nd-boot-drive

Tips & Tricks

NTFS driver update

I suggest you to keep the NTFS-3G driver updated to the latest release (if you need it).

Improve NTFS performances

As you may know the NTFS-3G is a FUSE driver, which is not the best in terms of performances (because of the calls from User Space to Kernel Space).

To improve your file NTFS file system access you should use the Paragon NTFS3 native driver shipped since kerne 5.15.0.

Extend Logical Volume

This is a trivial task, but not impossibile for anybody!

You may add as much space as you need by creating new loopback files by following the instruction provided (for the first "0-index" one) into the README-EXPERTS.md guide, at System loop files setup paragraph (look at dd command).

In order to do this you have to:

  • Boot your preferred live distribution.
  • Create one ore more additional loopback files (as stated above).
  • $ losetup -f {{NEW_LOOPBACK_FILE(S)_FULL_PATH}}.
  • Install system-config-lvm.
  • Initialize new files.
  • Add new files to the Virtual Group.
  • Extend the Logical Volume.
  • Reboot your Buddy Linux.

Known issues

  • Paragon driver not included in initramfstools.

buddy-linux's People

Contributors

antonio-petricca avatar company-service-account avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

buddy-linux's Issues

Help regarding writing a HelloWorld dracut module

Hi @antonio-petricca,

I am certain this is not the right place, but being a novice operator with "dracut," I thought I could gain some help from a maintainer who knows the ins & outs of it.

I want to write a very preliminary module that just does an echo command to get myself started with dracut. It would be of great help if you could help/point me to the right resources.

# #My new module is 90avi
# pwd
/usr/lib/dracut/modules.d/90avi

# cat module-setup.sh
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
check() {
    return 0
}
depends() {
    echo base lvm
    return 0
}
install() {
    inst_hook cmdline 90 "${moddir}/subroot.sh"
}

# cat subroot.sh
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
. /lib/dracut-lib.sh
info "This is a sample info tag!!!"

# cat /proc/cmdline
BOOT_IMAGE=/boot/vmlinuz-5.10.61-1.ph4 root=PARTUUID=89e99bcd-d182-4769-8752-20650ca6d0cd init=/lib/systemd/systemd ro loglevel=5 rd.debug no-vmw-sta console=tty0 console=ttyS0,115200 net.ifnames=0 plymouth.enable=0 systemd.legacy_systemd_cgroup_controller=yes

However, as per the Serial Console logs, I have collected, I am unable to see the This is a sample info tag!!! log. I am not sure if my module never got inserted to initrd (or) if it is getting executed however, my cmdline args are obscuring it.

I ran dracut -f command to kick start the inird building. Also, I am able to grep my module using dracut --list:

# dracut --list | grep avi
dracut: Executing: /usr/bin/dracut --list
avi

Could you please help?

Thanks

NTFS-3G not working after upgrading to Linux Mint 19.1

I don't know why, but after upgrading to Linux Mint 19.1 the host device is mounted as read-only.

Workaround:

  • Reboot.
  • Select the GRUB entry you want (the ntfs-3g one).
  • Enter edit mode by pressing E.
  • Change lvm_loops_host_fsoptions=noatime to lvm_loops_host_fsoptions=noatime,rw
  • Boot by pressing F10.

After booting:

  • Edit file /etc/default/grub.d/buddy-linux.cfg.
  • Change HOST_DEV_FSOPTIONS=noatime to HOST_DEV_FSOPTIONS=noatime,rw.
  • Run sudo update-grub.
  • Reboot.

Ubuntu Grub configuration

Seems there is a difference in location of grub configuration files between Ubuntu and Mint distribution. With Ubuntu distros this prevent the correct execution of the installation script indeed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.